แก้ไข

แชร์ผ่าน


ON_UPDATE_COMMAND_UI Macro

To connect a user-interface object to a command-update handler in a command-target object, open Class View, then right-click on the class to which the handler will be added, and choose Class Wizard. Find the user-interface object's ID in the list on the left, then choose UPDATE_COMMAND_UI in the right pane and click Add Handler. This creates a handler function in the class and adds the appropriate entry in the message map. See Mapping Messages to Functions for more information. You can specify additional messages to handle in the Messages pane.

For example, to update a Clear All command in your program's Edit menu, use the Class Wizard to add a message-map entry in the selected class, a function declaration for a command-update handler called OnUpdateEditClearAll in the class declaration, and an empty function template in the class's implementation file. The function prototype looks like this:

afx_msg void OnUpdateEditClearAll(CCmdUI* pCmdUI);

Like all handlers, the function declaration shows the afx_msg keyword. Like all update handlers, it takes one argument, a pointer to a CCmdUI object.

See also

How to: Update User-Interface Objects