Hide

SftTabs/DLL 6.5 - Tab Control

Display
Print

SFTTABS_TABCALLBACK Type Definition

Defines the callback function associated with a tab. This callback routine is called by SftTabs/DLL to create and destroy the page associated with a tab.

typedef HWND (CALLBACK* SFTTABS_TABCALLBACK)(BOOL fCreate,
    HWND hwndOwner, HWND hwndPage, HWND hwndTab);

Parameters

fCreate

TRUE if creating a new page. If hwndPage is NULL, the page is created for the first time, otherwise the page already exists. When creating a new page, the application should create a modeless dialog or a window. fCreate is FALSE when destroying a page or switching away from a page.

hwndOwner

The window handle of the tab control's parent window. This window should be the owner of any pages created by this callback function. If fCreate is FALSE, hwndOwner can be NULL. In this case, the page hwndPage should be destroyed unconditionally. If hwndOwner is not NULL, the window may be left intact, the tab control is merely switching away from the current page. By returning the page's window handle, the callback can indicate that the window wasn't destroyed. Returning NULL indicates that the page was destroyed.

hwndPage

The window handle of the page to create or destroy. hwndPage may be NULL when the page is created for the first time.

hwndTab

The window handle of the tab control.

Returns

The return value is the new page's window handle if fCreate is TRUE. If fCreate is FALSE, hwndOwner is not NULL and the callback hasn't destroyed the page, the return value is the window handle of the page. Otherwise NULL should be returned.

Comments

SFTTABS_TABCALLBACK defines the type of the callback function associated with a tab. This callback routine is called by SftTabs/DLL to create and destroy the page associated with a tab.

Callback functions associated with a tab are only used in the C implementation of tabbed dialogs and tabbed windows. They are not used for MFC/C++. For more information on tabbed dialogs and windows, see Implementing Tabbed Dialogs and Implementing Tabbed Windows.

Example

This example supports a page which is kept when switching away from the active tab:

C

HWND CALLBACK Page_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    if (fCreate) { // creating a new page
        if (hwndPage) {
            // already created, we could do some initialization here.
            // this will be called every time the page becomes active.
            // The WM_SHOWWINDOW message is also sent to the page and could
            // be used to determine activation/deactivation of the page.
            // optional, set the main window's title to the window title defined ...
            SftTabs_CopyWindowTitle(hwndPage, hwndOwner);
            return NULL; // return NULL, ignored
        } else {
            // Create the page.
            // You can create and initialize any type of window here, not just dialogs.
            // Use CreateWindow to create other windows. Don't specify WS_VISIBLE, but
            // make sure you use WS_TABSTOP.
            // When creating a non-dialog window, make sure to call SftTabs_SetPageActive
            // after the page has been created.
            HWND hwnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_your_dialog_ID),
                hwndOwner, (DLGPROC)Page_yourDialogProc,
                (LPARAM)(UINT)hwndTab); // pass tab control as data
            // optional, set the main window's title to the window title defined ...
            SftTabs_CopyWindowTitle(hwnd, hwndOwner);
            return hwnd;
        }
    } else {                    // destroying page
        if (hwndOwner)          // - because we're switching away
            return hwndPage;    // keep the window handle, don't destroy it
        else {                  // - because we're closing the main dialog
            DestroyWindow(hwndPage);
            return NULL;
        }
    }
}

This example supports a page which is destroyed every time when switching away from the active tab:

C

HWND CALLBACK Page_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    if (fCreate) { // creating a new page
        if (hwndPage) {
            // already created, we could do some initialization here.
            // this will be called every time the page becomes active
            // The WM_CREATE/WM_INITDIALOG/WM_DESTROY messages are also sent to
            // the page and could be used to determine activation/deactivation.
            // of the page.
            // optional, set the main window's title to the window title defined ...
            SftTabs_CopyWindowTitle(hwndPage, hwndOwner);
            return NULL;
        } else {
            // Create the page.
            // You can create and initialize any type of window here, not just dialogs.
            // Use CreateWindow to create other windows. Don't specify WS_VISIBLE, but
            // make sure you use WS_TABSTOP.
            // When creating a non-dialog window, make sure to call SftTabs_SetPageActive
            // after the page has been created.
            HWND hwnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_your_dialog_ID),
                hwndOwner, (DLGPROC)Page_yourDialogProc,
                (LPARAM)(UINT)hwndTab);// pass tab control as data
            // optional, set the main window's title to the window title defined ...
            SftTabs_CopyWindowTitle(hwnd, hwndOwner);
            return hwnd;
        }
    } else { // destroying page
        // We'll always destroy this page (to save resources)
        DestroyWindow(hwndPage);
        return NULL;
    }
}

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


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