Export (0) Print
Expand All
ATL
Expand Minimize

MESSAGE_HANDLER 

Defines an entry in a message map.


MESSAGE_HANDLER( 
      msg, 
      func  
)

Parameters

msg

[in] The Windows message.

func

[in] The name of the message-handler function.

MESSAGE_HANDLER maps a Windows message to the specified handler function.

Any function specified in a MESSAGE_HANDLER macro must be defined as follows:

LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

The message map sets bHandled to TRUE before MessageHandler is called. If MessageHandler does not fully handle the message, it should set bHandled to FALSE to indicate the message needs further processing.

NoteNote

Always begin a message map with BEGIN_MSG_MAP. You can then declare subsequent alternate message maps with ALT_MSG_MAP. The END_MSG_MAP macro marks the end of the message map. Every message map must have exactly one instance of BEGIN_MSG_MAP and END_MSG_MAP.

In addition to MESSAGE_HANDLER, you can use COMMAND_HANDLER and NOTIFY_HANDLER to map WM_COMMAND and WM_NOTIFY messages, respectively.

For more information about using message maps in ATL, see Message Maps.

class CMyClass : ...
{
public:
   ...

   BEGIN_MSG_MAP(CMyClass)
      MESSAGE_HANDLER(WM_PAINT, OnPaint)
      ...
   END_MSG_MAP()

   // When a CMyClass object receives a WM_PAINT
   // message, the message is directed to
   // CMyClass::OnPaint for the actual processing.
   LRESULT OnPaint( ... )
   { ... }

};

Community Additions

ADD
Show:
© 2014 Microsoft