The order in which messages are processed in the MFC application, the order in which the window is closed (non-modal window) during window creation, and the order of function calls in the open mode dialog box

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 then call afxcallwndproc.

2. afxcallwndproc () This function is used to save messages (the content mainly contains message identifiers and message parameters) for future use,
Then call the windowproc () function.

3. windowproc () this function is responsible for sending messages to the onwndmsg () function. If not processed, call the defwindowproc () function.

4. onwndmsg () This function first sorts messages by byte. For wm_command messages, the oncommand () Message
response function is called, and for wm_notify messages
onnotify () message response function. Any missed message is a window message. The onwndmsg () function searches
the message image of the cable class to find a processing function that can process any window message. If the onwndmsg () function cannot find such a processing function,
return the message 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, it indicates
The message is not a control notification). If it is, the oncommand () function tries to map the message to the control that creates the notification;
If it is not a control notification (or if the control rejects the ing message) oncommand (), the on1_msg () function will be called.

6. Based on the class that receives messages, the onreceivmsg () function is potentially used in a process called command routing.
Send command messages and control notifications.
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 for
Class to find a message processing function

The process of creating an MFC application window

1. precreatewindow () this function is an overload function. You can change the creation parameters in this overload function before the window is created.
(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 a wm_getminmaxinfo message and allows you to set the maximum or
Minimum Size

4. onnccreate () this function is also a message response function. It responds to the wm_nccreate message and sends a message to notify the customer zone of the window.
To be created soon

5. onnccalcsize () this function is also a message response function. It 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. It 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 been
Changed

8. The onmove () Message response function responds to the wm_move message. sending this message indicates that the window is moving

9. onchildnotify () this function is a heavy-duty function and is called as part of message ing to notify the parent window that a window has just been
Create

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, which refers to the wm_destroy message in the response window. When a window is destroyed, this message is sent.

3. onncdestroy () Message response function, which refers to the wm_ncdestroy message in the response window. This message 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. The presubclasswindow () overload function allows users to classify a window first.

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

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

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

6. The onsetfont () Message response function responds to the wm_setfont message and sends the message to allow the font of the control in the dialog box to be changed.

7. The oninitdialog () Message response function 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. The onshowwindow () Message response function responds to the wm_showwindow message, which is called by the showwindow () function.

9. The onctlcolor () 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. The onchildnotify () overload function is sent as the result of the wm_ctlcolor message.

Order of the close mode dialog box in the MFC Application

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

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

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

4. The onncdestroy () Message response function responds to the wm_ncdestroy message and is sent after a window is destroyed.

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

Order of opening the modeless dialog box

1. The presubclasswindow () overload function allows users to subclassify a window first

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

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

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

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

All the preceding operations are performed in the given order!

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.