HeaderPane
Main
Hide

SftButton/DLL 3.0 - Button Control

Share Link
Print

MFC and Notifications

Notifications can be handled by a button control's parent window or directly by the button control itself (in a derived class). WM_COMMAND messages are sent by the control to the parent window. The notification codes used are listed in section "Notifications".

Parent Window

If you want to handle Windows notification messages sent by a button control to its parent (usually a class derived from CDialog or CView), add a message-map entry and a message-handler member function to the parent class for each notification.

Message-map entries take the following form for WM_COMMAND and WM_NOTIFY notifications:

ON_Notification( id, memberFxn )

The parent's function prototype is as follows:

/* for WM_COMMAND notifications */
afx_msg void memberFxn( );
/* for WM_NOTIFY notifications */
afx_msg void memberFxn(NMHDR * pNotifyStruct, LRESULT* result);

Notification specifies one of the available notification codes listed in Notifications. id specifies the child window ID of the control sending the notification and memberFxn is the name of the parent member function in your application which handles the notification.

Example

// Event handler prototype added to dialog/window class
afx_msg void OnButtonClicked();

// Event handler(s) added to message map
BEGIN_MESSAGE_MAP(CSampleDialog, CDialog)
    ON_BN_CLICKED(IDC_BUTTON, OnButtonClicked)
END_MESSAGE_MAP()

// Event handler implementation
void CSampleDialog::OnButtonClicked()
{
    // respond to the click
}

Derived Objects

By overriding the OnChildNotify function of an object derived from CSftButton, you can handle messages in the object's class. The parameters are as documented in Notifications. Please see the MFC documentation for additional information regarding the OnChildNotify function. However, the use of message reflection as shown next is the preferred method to handle messages.

MFC defines the ON_CONTROL_REFLECT and ON_NOTIFY_REFLECT macros which allow adding notifications directly to the message map. SftButton/DLL implements all required macros based on ON_CONTROL_REFLECT and ON_NOTIFY_REFLECT. See the MFC documentation for more information on message reflection.

Message-map entries take the following form:

ON_Notification_REFLECT( memberFxn )

Last Updated 04/23/2026 - (email)
© 2026 Softel vdm, Inc.