Hide

SftTabs/DLL 6.5 - Tab Control

Display
Print

DeactivatePage

The parent window of a tab control calls the SftTabs_DeactivatePage function to signal that the current page is no longer the active page.

C

BOOL WINAPI SftTabs_DeactivatePage(HWND hwndParent, HWND hwndCtl);

Parameters

hwndParent

The window handle of the tab control's parent window.

hwndCtl

The window handle of the tab control.

Returns

The return value is TRUE if the current page was deactivated, otherwise the return value is FALSE.

Comments

The DeactivatePage function is called by the parent window of a tab control to signal that the current page is no longer the active page.

SftTabs_DeactivatePage is only used in the C implementation of tabbed dialogs and tabbed windows.

The SftTabs_DeactivatePage function sends a WM_QUERYENDSESSION and SftTabs_GetEndPageMessage messages to the currently active tab and its associated dialog or window procedure to determine if the page can be deactivated. It also causes the tab callback routine SFTTABS_TABCALLBACK responsible for the current tab to be called to destroy the page.

Example

This C example shows a typical tabbed dialog WM_COMMAND message handler:

case WM_COMMAND: {
    HWND hwndCtl = (HWND) lParam;
    int id = LOWORD(wParam);
    int code = HIWORD(wParam);
    if (hwndCtl) {
        switch (id) {
            case IDC_TAB:
                switch (code) {
                    case SFTTABSN_SWITCHING:// we're about to switch away from
                        // the current page. If you need to know what the new
                        // page will be use SftTabs_GetNextTab(hwndCtl).
                        if (!SftTabs_DeactivatePage(hwndParent, hwndCtl))
                            // couldn't deactivate current page, so don't switch
                            SendMessage(hwndCtl, WM_CANCELMODE, 0, 0);
                        break;
                    case SFTTABSN_SWITCHED:// we switched to a new page
                        SftTabs_ActivatePage(hwndParent, hwndCtl, NULL, FALSE);
                        break;
                }
                break;
            case IDOK:
            case IDCANCEL:
                if (code == BN_CLICKED)
                    SendMessage(hwndParent, WM_COMMAND, id, 0);
                break;
        }
    } else {
        switch (id) {
            case IDOK:
                // The currently active page will be called with a
                // WM_QUERYENDSESSION/SftTabs_GetEndPageMessage message to determine
                // whether it can be closed
                if (SftTabs_ClosePossible(hwndParent, GetDlgItem(hwndParent, IDC_TAB)))
                    EndDialog(hwndParent, TRUE);
                break;
            case IDCANCEL:
                EndDialog(hwndParent, FALSE);
                break;
                // The above assumes that this is a modal dialog. If it is a modeless
                // don't use EndDialog, use DestroyWindow instead.
        }
    }
    break;
}

See Also C/C++ API | C++ Classes | Notifications


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