Home
Tutorials
Code Snippets
Code Samples
Downloads
Links

The Blog
Our Projects
About
Contact

::Add RageStorm to Favorites!::

The Blog | Our Projects | Guest Book | About | Contact

 
Code Snippet - Handle Window Closing Event
Author:Arkon
Category:Win32API
File Size:608 Bytes
Uploaded at:20-Nov-06 07:21:18 am
Description:
  Shows how to handle the closing event of a window, asks a user if he wants to quit...
  
wndproc:

switch (message)
{
case WM_SYSCOMMAND:
// Early catch of close action.
if (wParam == SC_CLOSE) {
MessageBox(0, "got about-to-close message", 0, 0);
break; // let defwndproc handle it,
// you can return 0, and not let closing your app :(
}
break;
case WM_CLOSE:
// The actual close action.
if (IDYES == MessageBox(0, "quitting?", 0, MB_YESNO)) break;
// return 0, so it won't quit, in case user chose 'no'.
return 0;
case WM_DESTROY:
// cleanup time + tell message loop to quit.
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
User Contributed Comments(None)
NOTE:
Comments that will hurt anyone in any way will be deleted.
Don't ask for features, advertise or curse.
If you want to leave a message to the author use the contacts,
if you have any question in relation to your comments please use the forum.
Comments which violate any of these requests will be deleted without further
notice. Use the comment system decently.

Post your comment:
Name:
email:
Comment:
::Top 5 Tutorials::
Embedded Python[105776]
2D Rotated Rectangles Collision Detection[79024]
Keyboard Hook[68594]
UDP[52667]
HTTP Proxy[35944]

::Top 5 Samples::
2D ColDet Rotated Rectangles[10589]
PS2 Mouse Driver[6083]
Wave Format Player[4968]
Reading FAT12[4855]
CodeGuru[4543]


All rights reserved to RageStorm © 2009