Compartilhar via


Handlers for Commands and Control Notifications

There are no default handlers for commands or control-notification messages. Therefore, you are bound only by convention in naming your handlers for these categories of messages. When you map the command or control notification to a handler, the Properties windows proposes a name based on the command ID or control-notification code. You can accept the proposed name, change it, or replace it.

Convention suggests that you name handlers in both categories for the user-interface object they represent. Thus a handler for the Cut command on the Edit menu might be named

afx_msg void OnEditCut();

Because the Cut command is so commonly implemented in applications, the framework predefines the command ID for the Cut command as ID_EDIT_CUT. For a list of all predefined command IDs, see the file AFXRES.H. For more information, see Standard Commands.

In addition, convention suggests a handler for the BN_CLICKED notification message from a button labeled "My Button" might be named

afx_msg void OnBnClickedMybutton();

You might assign this command an ID of IDC_MY_BUTTON because it is equivalent to an application-specific user-interface object.

Both categories of messages take no arguments and return no value.

See Also

Concepts

Declaring Message Handler Functions