user2854935
user2854935

Reputation: 11

WinAPI Creating another window after destroying previous one

I know how to create child windows. But what if I want to create one window (for example to customise settings) and after destroying it - a second one (based on a HGE engine). If I could break message loop by WM_DESTROY I could create second window after this message loop. But as I know GetMessage returns 0 only in WM_QUIT message and I cannot send this message because it means: "Close the application" not "Close the window". So my question is: How can i break message loop when first window gets WM_DESTROY? Is that actually possible?

Upvotes: 0

Views: 97

Answers (2)

David Heffernan
David Heffernan

Reputation: 612794

It's quite simple really, and you should not be attempting to break out of you message loop.

  • When you handle the WM_CLOSE message for the first window, call CreateWindow etc. to create and show the second window.
  • When you handle the WM_DESTROY message for the second window, call PostQuitMessage to bring things to a close.

Upvotes: 2

KonstantinL
KonstantinL

Reputation: 667

Just use PostMessage.

#define WM_USER_CREATE_NEW_CHILD WM_USER + 1
void OnDestroy() // on destroy first child
{
PostMessage( parentWindow, WM_USER_CREATE_NEW_CHILD, 0, 0 );

Upvotes: 0

Related Questions