The order in which messages are processed in the MFC Application1. 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 (Message identifiers and message parameters are mainly saved) for future use by the application, and then calls the windowproc () function.3. windowproc () this function is responsible for sending messages to the onwndmsg () function.
response is made when the window is to be drawn (for the first time). In the subwindow, you can send an hbrush request to the parent window through wm_ctlcolor.
The order in which messages are processed in the MFC Application
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 (Message identifiers and message parameters are mainly saved) for fut
In the new version of Firefox, the first one in the right-click menu is to punch in the link in the new window, which is inconvenient and you want to open the link in the new tab in advance.
After checking on the internet, menu edit is recommended. In fact, this is not very convenient. At least one plug-in needs to be installed. In addition, this plug-in is replaced when you open the menu, this is not in line with the DIY spirit.
Later, I checked it online and found that many Firefox U
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
The order in which messages are processed in the MFC Application
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 pro
First, oncommand () is in the cwnd class, while on1_msg () is in the c1_target class. If you read the inheritance diagram of the MFC class, you will know that cwnd is inherited from the csf-target class. The following is a piece taken from the source code of MFC. It is not difficult to see that oncommand () in cwnd calls on1_msg ();
//////////////////////////////////////// //////////////////////////////////
limitation of the method proposed at. The response menu still corresponds to the prepared ID and cannot be dynamically increased.
Oncommand
Oncommand processes the message map for control notification and on_command entries, and callthe appropriate member function.
Idea: If we override the oncommand function in the framework class, we can intercept this function
Article reference address: http://blog.csdn.net/maweiqi/article/details/7876175 Windows message processing mechanism The order in which messages are processed in an MFC application1. AfxWndProc () The function is responsible for receiving the message, locating the CWnd object to which the message belongs, and then calling Afxcallwndproc 2.AfxCallWndProc () The function is responsible for saving the message (the content of the message is primarily the information identifier and message parameters
Enterprise Library 4.1 Download Address:
http://www.microsoft.com/downloads/details.aspx?FamilyId=1643758B-2986-47F7-B529-3E41584B6CE5displaylang=en
Sample code, foreground page, foreground for user control
Copy code code as follows:onselectedindexchanged= "Ddlpagesize_selectedindexchanged" gt;Now is oncommand= "Linkbutton_command" gt; Home oncommand= "Linkbutton_command" gt; next page
Dynamically created buttons are processed in the message OnCommand, regardless of the message, will be processed
1\ Create button
Copy Code code as follows:
cbutton* btn = new CButton ();
Btn->create (_t ("method"), Ws_child | Ws_visible, CRect (0,0,50,50), this, 2);
Note the last parameter created
This data represents the ID value of the control that was created, which is equivalent
This data is the only important flag that
value for it, but we will do more on it later.
Next, we'll add a property that holds the page number, and this property gets the value from the deck selectedindex attribute, which corresponds to the current page number. Similarly, we can modify this property to synchronize the SelectedIndex features on the deck. In addition, the text component needs to be updated in real time when the page number changes.
onget="return parseInt(document.getAnonymousNodes(this)[0].childNodes[0].getAttribute('
In this example:
In this example, three menus are dynamically added when the form is created, and the functions of Self-deletion are granted to them.
Resource file (testres. Rc) used in this example ):
Mymenu1 menuexbegin popup " file" begin menuitem "E xit", 101 endend
This exampleCodeFile:
Program project1; {$ R 'testres. res ''testres. RC '} uses Windows, messages; const idm_1 = 1; {define the constants of the three menu items} idm_2 = 2; idm_3
In this example:
Resource file (testres. Rc) used in this example ):
Mymenu1 menuexbegin menuitem "menu", 101 menuitem "Change My prohibition and non-Prohibition status", 102 menuitem "change", 103end
This exampleCodeFile:
Program project1; {$ R 'testres. res ''testres. RC '} uses Windows, messages; {work required to receive the wm_command message} procedure oncommand (H: hwnd; wparam: integer); var ustate: uint; H
. Classes derived from cwnd can receive such messages.
Command MessageMessages from menus, acceleration keys, or toolbar buttons. These messages are all presented as wm_command. In MFC, different command messages are distinguished by the menu item ID. In SDK, messages are identified by the wparam parameter. Classes derived from csf-target can receive such messages.
Announcement messageMessages generated by the control, such as Button clicking and selection of the list box, are generated to not
, unsigned int 12, afx_cmdhandlerinfo * 0x00000000) line 88C0000target: on0000msg (unsigned int 1, int 0, void * 0x00000000, afx_cmdhandlerinfo * 0x00000000) line 302 + 39 bytesCdialog: on1_msg (unsigned int 1, int 0, void * 0x00000000, afx_cmdhandlerinfo * 0x00000000) line 97 + 24 bytesCwnd: oncommand (unsigned int 1, long 656988) line 2088Cwnd: onwndmsg (unsigned int 273, unsigned int 1, long 656988, long * 0x0012f83c) line 1597 + 28 bytesCwnd: wind
UserListLogger .UserListIt is critical to realize that you do not know what the log program will do. There may be one or more listeners that perform other actions. For example, you might have an observer who sends a message to a new user and welcomes the new user to use the system. The value of this approach is to UserList ignore all objects that depend on it, and it focuses on the work of maintaining a list of users and sending messages as the list changes.This mode is not limited to in-memory
modular and general way:
First, defineMsgmap_entryStructure andDimMACRO:
Struct msgmap_entry {Uint nmessage;Long (* PFn) (hwnd, uint, wparam, lparam );};# Define dim (x) (sizeof (X)/sizeof (X [0])
Note:: PFNIs a function pointer. I want to process the function referred to by this pointer.NmessageMessage. This is a specific implementation of encapsulating "data" and "Data Processing Methods" in the object-oriented concept, but it is notC ++Language .]
Next, organize two Ar
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.