HeaderPane
Main
Hide

SftMask/DLL 7.0 - Masked Edit Control

Share Link
Print

MFC and Notifications

Notifications can be handled by a masked edit control's parent window or directly by the masked edit control itself (in a derived class). Simple notifications are sent as WM_COMMAND messages, extended notifications as WM_NOTIFY messages with NM_SFTMASK_* structures. The notification codes used are listed in section "Notifications".

Parent Window

If you want to handle Windows notification messages sent by a masked edit 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:

/* for WM_COMMAND notifications */
ON_CONTROL( notificationCode, id, memberFxn )

/* for WM_NOTIFY notifications */
ON_NOTIFY( notificationCode, 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);

notificationCode specifies one of the available notification codes listed in Notifications (such as SFTMASKN_CHANGE or NM_SFTMASK_VALIDATIONERROR_CODE). 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 prototypes added to dialog/window class
afx_msg void OnMaskChanged();
afx_msg void OnMaskValidationError(NMHDR* pNMHDR, LRESULT* pResult);

// Event handler(s) added to message map
BEGIN_MESSAGE_MAP(CSampleDialog, CDialog)
    ON_CONTROL(SFTMASKN_CHANGE, IDC_MASK, OnMaskChanged)
    ON_NOTIFY(NM_SFTMASK_VALIDATIONERROR_CODE, IDC_MASK, OnMaskValidationError)
END_MESSAGE_MAP()

// Event handler implementation
void CSampleDialog::OnMaskChanged()
{
    // respond to the change
}

void CSampleDialog::OnMaskValidationError(NMHDR* pNMHDR, LRESULT* pResult)
{
    NM_SFTMASK_VALIDATIONERROR* pErr = (NM_SFTMASK_VALIDATIONERROR*) pNMHDR;
    // respond to the validation error
    *pResult = 0;
}

Derived Objects

By overriding the OnChildNotify function of an object derived from CSftMask, 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. MFC also defines the ON_CONTROL_REFLECT and ON_NOTIFY_REFLECT macros which allow adding notifications directly to the message map of the derived class. See the MFC documentation for more information on message reflection.

See Also Notifications | Using C++/MFC


Last Updated 08/30/2026 - (email)
© 2026 Softel vdm, Inc.