Hide

SftTabs/DLL 6.5 - Tab Control

Display
Print

MFC and Notifications

Notifications can be handled by a tab control's parent window or directly by the tab 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 tab 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 - not currently used */
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 OnTabSwitching();

// Event handler(s) added to message map
BEGIN_MESSAGE_MAP(CSampleView, CView)
    ON_SFTTABSN_SWITCHING(IDC_TAB, OnTabSwitching)
END_MESSAGE_MAP()

// Event handler implementation
void CSampleView::OnTabSwitching()
{
    if (!SwitchingOK())
        m_Tab.SendMessage(WM_CANCELMODE);// cancel switching
}

Derived Objects

By overriding the OnChildNotify function of an object derived from CSftTabs, 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. SftTabs/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 )

The function prototype is as follows:

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

Notification specifies one of the available notification codes listed in Notifications. memberFxn is the name of the member function in your object's class which handles the notification.

Example

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

// Event handler(s) added to message map
BEGIN_MESSAGE_MAP(CSampleView, CView)
    ON_SFTTABSN_SWITCHING(IDC_TAB, OnTabSwitching)
END_MESSAGE_MAP()

// Event handler implementation
void CSampleView::OnTabSwitching()
{
    if (!SwitchingOK())
        m_Tab.SendMessage(WM_CANCELMODE);// cancel switching
}

Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.