views:

37

answers:

1

Hello. I read many articles on the topic, a few of them were here, on stackoverflow, but none of them asked my question. I'll try to be specific.

I need to create an application (native WinAPI) with a main window (of window class "a"). When the user clicks a button there, a window of "b" class pops up. It might be modal or not, I don't care right now.

I tried making an application with two window classes and two window procedures. But the problem is that when I close the second window, the whole application shuts down.

Thank you.

+1  A: 

At a guess, the window procedure for your second window is based on one for a main window, so when it receives a WM_DESTROY, it's calling PostQuitMessage. This is normal for the top-level window, because the user expects destroying it to mean exiting the application. For a child window (modal or otherwise) that's not the case though, so the child should not (again, normally) call PostQuitMessage in its WM_DESTROY handler.

Jerry Coffin
Thank you, that was the solution. Actually, I reversed the class name and title parameters in CreateWindow call (looks like the headache does it's job well). So the popup window used the main window's procedure, which had the PostQuitMessage call. Anyway, thanks.
Talis