In the recent reading of the "MFC Windows Programming" This book, just see the Update menu items and join menu item accelerator Key This aspect of the content, the following general summary.
MFC provides mechanisms for updating menu items such as the following:
Through the ON_UPDATE_COMMAND_UI macro in the message map table. The ability to assign a selected member function to a single menu item as an update handler, when a drop-down menu is in the user point, MFC captures the WM_INITMENUPOPUP message that occurs, and invokes the update handler for all menu items in the menus.
Each update handler gets a pointer to the CCmdUI object and updates the menu item with the member handler function of the object.
By the way, introduce the CCmdUI class
The following are some of the member functions of the class:
void Enable (BOOL bOn = TRUE);
enables or disables the User-interface item for this command.
Make the menu item of the interface valid or invalid. When the number of parameters Bon = True, the menu item is valid, and vice versa, invalidates.
void SetCheck (int ncheck = 1);
Sets the check state of the User-interface item for this command
Specifies the check state to set. If 0, Unchecks; If 1, checks; And if 2, sets indeterminate
Specifies whether the status of the menu item is selected, when the number of Ncheck = 1 o'clock, the status is selected. Ncheck = 0 o'clock, the status is unchecked, Ncheck = 2 o'clock, the status of the menu item is undefined.
void Setradio (BOOL bOn = TRUE);
Like the SetCheck member function, but operates on radio groups.
The function's settings are similar to SetCheck, but the function is applied to the radio combo box.
void SetText (LPCTSTR lpszText);
Sets the text for the User-interface item for this command.
Sets the body of the menu item as the content of the lpsztext .
Ways to add shortcut keys to a menu item
Click the Resource View tab of the workspace to open the accelerator resource you want to edit
Double-click the blank entry that appears for example in the dialog box
Add the ID of the menu item on which you want to create the accelerator key
Add the virtual key code of the corresponding shortcut key at key or click Next key Typed directly to enter the selected shortcut key
The following links are my implementation of the shortcut keys and Update menu item status of the small program for everyone to participate in the test.
Http://download.csdn.net/my
MFC's UI update mechanism and accelerator key creation