The order in which messages are processed in the MFC Application

Source: Internet
Author: User
MFC ApplicationProgramThe order in which messages are processed

1. afxwndproc ()    This function is used to receive messages, locate the cwnd object to which the message belongs, and call afxcallwndproc.

2. afxcallwndproc ()This function is used to save a message (the content mainly contains the message identifier and message parameters) and then calls the windowproc () function.

3. windowproc ()    This function is used to send messages to the onwndmsg () function. if the message is not processed, the defwindowproc () function is called.

4. onwndmsg ()      The function first sorts messages by byte. For wm_command messages, the oncommand () Message response function is called, and the onnotify () Message response function is called for wm_notify messages. Any missed message is a window message. 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 ()     This function checks whether this is a control notification (the lparam parameter is not null. If the lparam parameter is null, the message is not a control notification). If it is oncommand () the function tries to map messages to the control that creates notifications. If it is not a control notification (or if the control rejects the mapped message) oncommand (), it calls the on1_msg () function.

6. on1_msg ()      Based on the class of receiving messages, the onreceivmsg () function potentially transmits 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 notification messages are also transmitted to the view and document class, and a message processing function is found for the class.

 

The process of creating an MFC application window

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

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

3. ongetminmaxinfo () This function is a message response function that responds to the wm_getminmaxinfo message and allows you to set the maximum or minimum size of the window.

4. onnccreate ()      This function is also a message response function that responds to the wm_nccreate message and sends a message to notify the customer area of the window that is about to be created.

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

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

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

8. onmove ()          The message response function responds to the wm_move message. If this message is sent, it indicates that the window is moving.

9. onchildnotify ()   This function is an overload function and is called as part of message ing to notify the parent window that a window has just been created.

 

The order in which the MFC application closes the window (non-modal window)

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

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

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

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

Order of function calls in the open mode dialog box in the MFC Application

1. domodal ()           Overload function, overload domodal () member function

2. presubclasswindow () Overload function, allowing sub-classification of a window first

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

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

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

6. onsetfont ()         The message response function responds to the wm_setfont message and sends this message to allow you to change the font of the control in the dialog box.

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

8. onshowwindow ()      The message response function that responds to the wm_showwindow message. This function is called by the showwindow () function.

9. onctlcolor ()        The message response function responds 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 ()   Overload function, sent as the result of the wm_ctlcolor message

 

Order of the close mode dialog box in the MFC Application

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

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

3. ondestroy ()    The message response function responds to the wm_destroy message. When a window is about to be destroyed, it is sent.

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

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

Order of opening the modeless dialog box

1. presubclasswindow ()  Overload function, allowing users to subclassify a window first

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

3. onsize ()             The message response function responds to the wm_size message and sends the message to notify the window size of the change.

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

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

All the preceding operations are performed in the given order!

You can only writeCodeKnow when to execute and where to process!

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.