¿Le resultó útil esta página?
Sus comentarios sobre este contenido son muy importantes. Háganos saber su opinión.
¿Tiene comentarios adicionales?
Caracteres restantes: 1500
Exportar (0) Imprimir
Expandir todo
ATL
Expandir Minimizar
Importante Es posible que este documento no represente los procedimientos recomendados para el desarrollo actual. Puede que los vínculos a las descargas y otros recursos ya no sean válidos. Encontrará aquí la versión que se recomienda en la actualidad.

COMMAND_HANDLER

Defines an entry in a message map.


COMMAND_HANDLER( id, code, func )

Parameters

id

[in] The identifier of the menu item, control, or accelerator.

code

[in] The notification code.

func

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

COMMAND_HANDLER maps a WM_COMMAND message to the specified handler function, based on the notification code and the control identifier. For example:

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

   BEGIN_MSG_MAP(CMyClass)
      COMMAND_HANDLER(IDC_MYCTL, EN_CHANGE, OnChange)
      ...
   END_MSG_MAP()

   // When a CMyClass object receives a WM_COMMAND
   // message identified by IDC_MYCTL and EN_CHANGE,
   // the message is directed to CMyClass::OnChange
   // for the actual processing.
   LRESULT OnChange( ... )
   { ... }

};

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

LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);

The message map sets bHandled to TRUE before CommandHandler is called. If CommandHandler 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 COMMAND_HANDLER, you can use MESSAGE_HANDLER to map a WM_COMMAND message without regard to an identifier or code. In this case, MESSAGE_HANDLER(WM_COMMAND, OnHandlerFunction) will direct all WM_COMMAND messages to OnHandlerFunction.

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

Adiciones de comunidad

AGREGAR
Mostrar:
© 2015 Microsoft