Sign in to follow this  
hkBattousai

[Win32 C++] Close Button [SOLVED]

Recommended Posts

Thank you for CS_NOCLOSE idea.

One another way is manipulating WM_CLOSE Windows message.
When user clicks close button WM_CLOSE is sent to queue. DefWindowProc() gets WM_CLOSE and sends WM_DESTROY. In most program code, the program getting WM_DESTROY calls PostQuitMessage() API function. This function causes WM_QUIT to be sent into message queue. GetMessage() function geting WM_QUIT returns zero and exits the loop below :

//const DWORD WM_QUIT 0;
while (GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}


But if you prevent DefWindowProc() getting WM_CLOSE, non of the above happens. You can add your own code and hide the window.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this