Jump to content
  • Advertisement
Sign in to follow this  
jaumzaum

Create a Window - What's the function who really CLOSES the window?

This topic is 2871 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

Hi there!

I'm new on C++ Window Programming and I've recently learned how to create a window, but there 's a thing that doesn't go out my head: What's the function who really CLOSES the WINDOW?

What I'm saying is what function makes the window disappear from the screen, one function that has a command like:

close (%hWnd);

Is it the PostQuitMessage, the end of WinMain, DefWindowProc, WindowProc, GetMessage or PeekMessage... I'm really confused with that, if some one could help...

Thanks,

John

Share this post


Link to post
Share on other sites
Advertisement
DestroyWindow(HWND hWnd) should do the trick.
More info here: MSDN

For future reference, MSDN should be one of your first stops when looking for information about the Windows API. It's pretty well documented for the most part.

Share this post


Link to post
Share on other sites
Thaanks, DOM.
So when I click on the red cross box to close the window, this function is automatically called? And by MSDN, this function only sends the WM_DESTROY and WM_NCDESTROY messages, but there have to be a function who translate these messages and closes the window, is that function WindowProc() or DefWindowProc()?

Share this post


Link to post
Share on other sites
When the red X is clicked, your window's message handler gets sent a WM_CLOSE message. This message says "hey, someone is trying to close this window". Your window proc can totally ignore it, it can hide the window, or you can call DestroyWindow if you want to actually close the window (calling DefWindowProc will so that for you).

When DestroyWindow is called, the window is gone. The WM_DESTROY message you get is just a notification: it doesn't do anything, except for tell you that the window is already dead and never coming back.

Share this post


Link to post
Share on other sites
The message is set to the window procedure. If it's not handled there, it's passed on to DefWindowProc.

[ninja'd by 24 seconds [wink]]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!