Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 5572 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alright, heres a stupid question. I got my window made, then I wanted to add so when u press the x button it asks if u wanna quit or not. Heres the chunk of code i have a qeustion on. It asks u after the window is destroyed, and after a few times, i have to restart my comp cause the .exe in the debug folder gets somehow protected. HElp Plz! case WM_DESTROY: MessageBox( NULL, "Are you sure you want to quite El Gato?", "Sir?", MB_YESNO | MB_ICONEXCLAMATION ); if( IDCANCEL ) { return 0; } else { PostQuitMessage( 0 ); return 0; } }

Share this post

Link to post
Share on other sites
You have to use the return-value of MessageBox().
Either use this or that.


rs = MessageBox( ..., MB_YESNO | MB_ICONEXCLAMATION );
if( rs == IDYES )


if( MessageBox( ..., MB_YESNO | MB_ICONEXCLAMATION ) == IDYES )

Share this post

Link to post
Share on other sites
Careful now, you shouldn''t ask ths question on a WM_DESTROY message, that''s too late.

Do it on a WM_CLOSE message instead.

Then depending on the reply to your messagebox, toss DestroyWindow(hWnd); and PostQuitMessage(0);
which are the standard ways to deal with a WM_CLOSE message.
(I actually recommend calling ShowWindow(hWnd, SW_HIDE); as well, it helps on some platforms and doesn''t hurt on others)

Be careful not to use DefWindowProc(...) on the WM_CLOSE, otherwise the destroy/quit will be done without your consent.

=^.^= Leaders and teachers should remember: It is best to offer others what they Need, not what they Want.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!