Using the same message processor but closing only 1 window

Started by
4 comments, last by Aardvajk 10 years, 1 month ago

So I have 2 dialog boxes that use the same dialog processor. The problem is,when one closes,it closes the other too because of the PostQuitMessage().

What can I do to be able to close only one?

Advertisement

Why are you using PostQuitMessage to close a dialog? EndDialog takes a HWND of the dialog to close.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Because I didn't know about EndDialog untill now,so thanks sleep.png

Wait - you have 2 dialog boxes displayed at the same time? So these are non modal dialogs? In that case, using EndDialog is wrong. EndDialog is for modal dialog boxes only.

Good point, to destroy a modeless dialog call DestroyWindow (although you can hide them instead sometimes rather than keep creating and destroying them all the time).

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

PostQuitMessage causes a WM_QUIT to be posted to the message queue, GetMessage() returns false when it finds WM_QUIT so this usually breaks out of the message loop entirely in a normal Win32 application and exits WinMain. Not sure if you have an explicit message loop or not but this is the reason.

This topic is closed to new replies.

Advertisement