Message mapping table

zhaozj2021-02-08  206

Message mapping table

1. For different messages, MFC implements message mapping 2 with different macros. The message mapping table processes the message map defined by this class and the message mapped to its parent class processing by the message defined by this class and the message defined by this class. The macro between Begin _... and End _... The message mapped to the message map must be processed to generate the login entry 4. Macro Category: 1, Standard Windows Messages are processed by macro on_wm_xxx, where xxx is a standard message name 2, macro ON_REGISTERED_MESSAGE is used to handle the user's own registration Windows window message. This macro accepts the NEAR type unsigned integer variable, which is the registered Windows message identifier already registered. The message identifier can be called by the RegisterWindowMessage function to get the unique global message. For example: afx_msg LRESULT OnFind (WPARAM wParam, LPARAM lParam); static UINT NEAR WM_FIND = RegisterWindowMessage ( "COMMONDLG_FIND"); // this function registration message with the range 0XC000 ~ 0XFFFF (Note: WM_FIND be illustrated as NEAR type) BEGIN_MESSAGE_MAP ( ...) ... ON_REGISTERED_MESSAGE (WM_FIND, OnFind) ... END_MESSAGE_MAP 3, WINDOWS message with user-defined macro can be included in the message map ON_MESSAGE #define WM_MYMESSAGE WM_USER 100 ON_MESSAGE (WM_MYMESSAGE, OnMymessage) by: CWnd * PWND = ...; PWND-> SendMessage (WM_MYMESSAGE); to implement 4, the processing of the command message is to use the macro ON_COMMAND, the command message includes the menu command and menu accelerator command, the format is ON_COMMAND (ID, MemberFunction) ON_COMMAND accept commands The logo, the actual command processing function does not bring any parameters, and does not return any type value 5 after processing, the message updated message is the same as the mechanism of the ON_COMMAND, and the different macro ON_UPDATE_COMMAND_UI is used instead of the use of macro ON_COMMAND. The format is: ON_UPDATE_COMMAND_UI (ID, MemberFunction). This member handler belt with a parameter ccmdui * cmdui, but does not return any value. 6, ON_COMMAND_EX not only contains all ON_COMMAND functions, but also provides a macro's function supercoming. Extended command processing The member function only has a parameter, an unsigned integer number containing the command identifier, the function requires returns a Boolean value, if returned to positive, then the message has been processed, for the fake, indicating that this command message is also transmitted. Other command processing functions are further processed. 7. More advanced message macros There is ON_COMMAND_RANGE, ON_COMMAND_RANGE_EX, which allows a command processor to process a certain range of command messages. ClassWizard only identifies on_command, on_UPDATE_COMMAND_UI macro 8, for the sub-control of a window to the notification message to this window, this notification message has an additional information in the message mapping table: the identity of sub-control. It is called only when the message processing function in the message mapping table satisfies two conditions.

转载请注明原文地址:https://www.9cbs.com/read-2491.html

New Post(0)