views:

176

answers:

1

I have read about Windows Mobile's X button's behaviour and also about WM_HIBERNATE and WM_CLOSE which are sent on Low Memory Situation to all valid applications.

MSDN on WM_HIBERNATE:

This message is sent to an application when system resources are running low. An application should attempt to release as many resources as possible when sent this message by unloading dialog boxes, destroying windows, or freeing up as much local storage as possible without changing the internal state.

MSDN on WM_CLOSE:

This message is sent as a signal that a window or an application should terminate.

Questions:

  1. Are the messages sent only to the top-level windows or all windows in valid applications?
  2. Where should I catch the message? in the main message pump? in every window? or only some windows?
  3. If I am using MFC, where should I catch it?
+1  A: 

You only need to catch these messages in one form (or one control, native window class etc.). Since you definitely want one that will be around for the lifetime of your application, the main form is an appropriate choice.

MusiGenesis
Thank you for answering. Are the messages sent to all the windows in valid apps?
afriza
http://www.devsource.com/c/a/Using-VS/Working-with-Windows-Messages-in-NET/
MusiGenesis