Classification of MFC messages in Visual C + + _c language
Source: Internet
Author: User
Standard (window) message: Window messages are generally related to the internal workings of a window, such as creating a window, drawing a window, destroying a window, usually from a system to a window, or from a window to a system. Send function SendMessage () or PostMessage (). In addition to WM_COMMAND, all messages that begin with WM_. Classes derived from CWnd can receive this type of message. Note: Standard messages do not require us to specify the processing function name, which is the default correspondence.
Command messages: command messages are usually related to processing a user request, and the command message is generated when the user clicks a menu or toolbar. Messages that are sent to a class or function that can handle the message, such as loading text, saving options, and so on, are rendered in wm_command. In MFC, a menu identifier (ID) is used to distinguish between different command messages, and in the SDK, the wparam parameters of the message are identified. Classes derived from CCmdTarget can receive such messages, and their wparam record which menu item the message comes from.
Control message: A message generated by a control, such as a button's click, the selection of a list box, and so on, to notify the occurrence of an event to its parent window (usually a dialog box). Such messages are also rendered in wm_command form. Classes derived from CCmdTarget can receive such messages.
CWnd is a derived class of CCmdTarget, and Cmenuapp and Cmenudoc in a single document program in MFC are derived classes that belong to CCmdTarget and do not contain CWnd classes.
Routing of MFC Command messages: AfxWndProc (replacing the window procedure function)->afxcallwndproc->windowproc->onwnddmsg-> (call OnCommand if it is a command message; Call OnNotify If it is a notification message->oncmdmsg
Distinction between standard and non-standard messages: Standard message: With control followed by operations; non-standard message: Just a simple hint.
You can design a message image form in many categories of the program (each category can have only one message image form, but it may not), and receive and process messages. Any Windows messages can be stopped as long as they are CWnd derived classes. MFC classes that are not window-independent, such as CDocument and CWinApp, must be derived from CCmdTarget if you also want to process messages, and you may only receive WM_COMMAND command messages.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service