Hide

SftTabs/DLL 6.5 - Tab Control

Display
Print

GetNextTab

Retrieves the index of the next tab about to become active.

C

int SftTabs_GetNextTab(HWND hwndCtl);

C++

int CSftTabs::GetNextTab() const;

Parameters

hwndCtl

The window handle of the tab control.

Returns

The return value is the index of the next tab about to become active.

Comments

The GetNextTab function retrieves the index of the next tab about to become active.

GetNextTab returns the index of the tab about to become active while processing a SFTTABSN_SWITCHING notification. The application can prevent the new tab from becoming active by sending a WM_CANCELMODE message to the tab control.

GetNextTab can also be used in a CSftTabsPage::AllowSwitch or CSftTabsWindowPage::AllowSwitch function, because these are called by the C++ class implementations while a SFTTABSN_SWITCHING notification is being processed.

GetNextTab can only be used while processing a SFTTABSN_SWITCHING notification.

Example

This example prevents the user from switching to tab 0:

C

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_GetNextTab(hwndCtl) == 0) {
                            SendMessage(hwndCtl, WM_CANCELMODE, 0, 0);
                            break;
                        }
                        if (!SftTabs_DeactivatePage(hwndParent, hwndCtl)) {
                            // couldn't deactivate current page, so don't switch
                            SendMessage(hwndCtl, WM_CANCELMODE, 0, 0);
                            break;
                        }
                        break;
                    case SFTTABSN_SWITCHED:// we switched to a new page
                        SftTabs_ActivatePage(hwndParent, hwndCtl, NULL, FALSE);
                        break;
                }
                break;
        }
    }
    break;
}

C++

BOOL CPage2::AllowSwitch()
{
    if (m_pTabCtl->GetNextTab() == 0))
        return FALSE;
    return TRUE; // Allow switching away from this page
}

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


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