Hide

SftTabs/DLL 6.5 - Tab Control

Display
Print

ClosePossible

The parent window of a tab control calls the SftTabs_ClosePossible function to test if a tabbed dialog or window can be ended.

C

BOOL WINAPI SftTabs_ClosePossible(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 can be ended, otherwise the return value is FALSE.

Comments

The ClosePossible function is called by the parent window of a tab control to test if a tabbed dialog or window can be ended.

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

The SftTabs_ClosePossible function sends WM_QUERYENDSESSION and SftTabs_GetEndPageMessage messages to the currently active tab and its associated page, to determine whether the page can be deactivated.

Example

This C example shows the end of 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.