Jump to content

mini-howto: implement "Keep Alive"


Guest MrMagoo

Recommended Posts

Guest MrMagoo

here is a snippet from my progs message handler...

case WM_DESTROY: 


   if( gBadBoy == 0 ) 


      PostQuitMessage(0); 


   break; 




case WM_CLOSE: 


   if( gBadBoy == 1 ) 


      break; 




DoDefault: 


default: 


   lResult = DefWindowProc(hwnd, msg, wp, lp); 


   break;

NOTE: gBadBoy is a variable I use to keep track of whether to allow the app to close or not...

gBadBoy = 0 means the opsys can close me down

gBadBoy = 1 means the opsys cannot close me down

so, if i don't want to close i ignore WM_CLOSE and

if i do want to close i fall through into the DefWindowProc code.

The other part of the puzzle is catching WM_DESTROY:

if i dont want to close i dont do anything

and if i do want to close i call PostQuitMessage

simple once u have it really...

hope this helps

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.