Message Processing sequence in MFC

Source: Internet
Author: User

From: http://hi.baidu.com/bellgrade/blog/item/4b1c61c395a7d73ce4dd3b78.html

 

MFCThe order in which messages are processed

1. afxwndproc () receives the message, searches for the cwnd object to which the message belongs, and then calls afxcallwndproc ().

2. afxcallwndproc () Stores messages (Message identifiers and message parameters) for future reference, and then calls windowproc ().

3. windowproc () sends a message to onwndmsg (). If the message is not processed, it is sent to defwindowproc ().

4. onwndmsg () First sorts messages by byte. For wm_command messages, the oncommand () Message response function is called. For wm_notify messages, the onnotify () Message response function is called. Any missed messages will be standard messages. Onwndmsg () function searches for a message image to find a processing function that can process messages in any window. If the onwndmsg () function cannot find such a processing function, the message is returned to the windowproc () function, which sends the message to the defwindowproc () function.

5. oncommand () to check whether this is a control notification (the lparam parameter is not null). If it is, the oncommand () function tries to map messages to the control that manufactures notifications; if it is not a control notification, or the control rejects the ing message, oncommand () calls the on1_msg () function.

6. onnotify () also tries to map messages to the control that creates notifications. If the ing fails, ony y () calls the same on1_msg () function.

7. Based on the message receiving class, the onreceivmsg () function will potentially PASS command messages and control notifications in a process called command routing. For example, if the class that owns the window is a framework class, the command and control notification messages are also transmitted to the view and document class, and a message processing function is found for the class.

See the figure below:

 

MFCSequence of Window Creation

1. precreatewindow () is an overload function. Before a window is created, you can change the creation parameters (you can set the window style and so on) in this overload function ).

2. presubclasswindow () is also an overload function. It allows a submodule to classify a window ongetminmaxinfo () as a message Response Function and respond to a wm_getminmaxinfo message. The maximum or minimum size of the window can be set.

3. onnccreate () is also a message response function. In response to the wm_nccreate message, the message is sent to inform the window that the customer zone is about to be created.

4. onnccalcsize () is also a message response function. It responds to the wm_nccalcsize message and allows you to change the size of the window client.

5. oncreate () is also a message response function. It responds to the wm_create message and sends a message to indicate that a window has been created.

6. onsize () is also the message response function. It responds to the wm_size message and sends the message to indicate that the window size has changed.

7. onmove () is also a message response function, which responds to the wm_move message. sending this message indicates that the window is moving.

8. onchildnotify () is an overload function. It is called as a part of message ing and informs the parent window that a window has just been created.

 

MFCOpening the order of the Modal Dialog Box

1. domodal () is an overload function that reloads domodal () member functions.

2. presubclasswindow () is also an overload function that allows subclassification of a window.

3. oncreate () is a message response function that responds to the wm_create message and sends this message to indicate that a window has been created.

4. onsize () is also the message response function. It responds to the wm_size message and sends the message to notify the window size of the change.

5. onmove () is also a message response function. It responds to the wm_move message and sends this message to notify the window that it is moving.

6. onsetfont () is also a message response function. It responds to the wm_setfont message and sends this message to allow changing the font of the control in the dialog box.

7. oninitdialog () is also a message response function. It responds to the wm_initdialog message and sends this message to allow the control in the initialization dialog box or create a new control.

8. onshowwindow () is also a message response function. It responds to the wm_showwindow message and is called by the showwindow () function.

9. onctlcolor () is also a message response function. In response to the wm_ctlcolor message, the color of the control in the changed dialog box or dialog box is sent by the parent window.

10. onchildnotify () is an overload function that is sent as the result of the wm_ctlcolor message.

 

MFCClosing the order of the Modal Dialog Box

1. onclose () is a message response function that responds to the wm_close message. When the "close" button is clicked, this function is called.

2. onkillfocus () is also a message response function that responds to the wm_killfocus message. It is sent before a window is about to lose the keyboard input focus.

3. ondestroy () is also a message response function. It responds to the wm_destroy message and is sent when a window is about to be destroyed.

4. onncdestroy () is also a message response function. It responds to the wm_ncdestroy message and is sent when a window is destroyed.

5. postncdestroy () is also an overload function. It is called by cwnd as the final action for processing the onncdestroy () function.

 

MFCOpening the order of the non-Modal Dialog Box

1. presubclasswindow () is an overload function that allows you to subclassify a window first.

2. oncreate () is a message response function that responds to the wm_create message and sends this message to indicate that a window has been created.

3. onsize () is also the message response function. It responds to the wm_size message and sends the message to tell the window size to change.

4. onmove () is also a message response function. It responds to the wm_move message and sends this message to notify the window that it is moving.

5. onsetfont () is also a message response function that responds to the wm_setfont message and sends this message to allow you to change the font of the control in the dialog box.

 

MFCTo close the order of the non-Modal Dialog Box

1. onclose () is the message response function. The wm_close message in the response window is sent when the close button is clicked.

2. ondestroy () is also a message response function. The message wm_destroy in the response window is sent when a window is destroyed.

3. onncdestroy () is also a message response function. The wm_ncdestroy message in the response window is sent when a window is destroyed.

4. postncdestroy () is an overload function. It is called by cwnd as the final action for processing the onncdestroy () function.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.