Hide

SftTabs/DLL 6.5 - Tab Control

Display
Print

Special Sample (C)

This sample illustrates a tree control used to switch between different pages (in an invisible wizard-style tab control).

The source code is located at C:\Program Files (x86)\Softelvdm\SftTabs DLL 6.5\Samples\C\Special\Special.c or C:\Program Files\Softelvdm\SftTabs DLL 6.5\Samples\C\Special\Special.c (on 32-bit Windows versions).

/****************************************************************************/
/* SftTabs/DLL 6.5 - Tab Control for C/C++                                  */
/* Copyright (C) 1994, 2017  Softel vdm, Inc. All Rights Reserved.          */
/****************************************************************************/

#include <windows.h>

#include "sfttb.h"                      /* SftTabs/DLL Header File */

// NOTE:  If you receive an error here, you must update the directory path
// for include directories to also point to the SftTree/DLL product 
// include directory.
// If you don't have SftTree/DLL, you cannot recompile this example.
#include "sfttree.h"                    // SftTree


#include "resource.h"                   // application resources

/**********************************************************************/
/*                              Globals                               */
/**********************************************************************/

HINSTANCE g_hInst;                      // App Instance Handle
HBITMAP m_ahBitmap[3];                  // Bitmaps for tree control

/****************************************************************************/
/*                       Center the main dialog                             */
/****************************************************************************/

static void CenterWindow(HWND hwnd)
{
    RECT rc;
    RECT rcOwner;
    int x, y;

    GetWindowRect(hwnd, &rc);
    GetWindowRect(GetDesktopWindow(), &rcOwner);

    // Calculate the starting x,y for the new window so that it would be centered.
    x = rcOwner.left + (((rcOwner.right - rcOwner.left) - (rc.right - rc.left)) / 2);
    y = rcOwner.top + (((rcOwner.bottom - rcOwner.top) - (rc.bottom - rc.top)) / 2);

    SetWindowPos(hwnd, NULL, x, y, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
}

/**********************************************************************/
/*                        Page 1 Dialog Proc                          */
/**********************************************************************/

BOOL CALLBACK Page_DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg) {
    case WM_INITDIALOG:
        // initialize page
        SftTabs_SetPageActive(hwndDlg, (HWND) lParam, NULL);
        return FALSE;                   // we never want the focus on the offered control
    }

    // Any message your dialog procedure doesn't handle, must come here
    if (SftTabs_HandleDialogMessage(hwndDlg, msg, wParam, lParam))
        return TRUE;

    return FALSE;
}

static HWND LocalPageCallback(int pageID, 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 for this page
            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(pageID), hwndOwner, (DLGPROC)Page_DialogProc, 
                    (LPARAM)hwndTab);// pass tab control as data
            // optional, set the main window's title to the window title defined for this page
            SftTabs_CopyWindowTitle(hwnd, hwndOwner);
            return hwnd;
        }
    } else {                            // destroying page
        // We'll always destroy this page (to save resources)
        DestroyWindow(hwndPage);
        return NULL;
    }
}

HWND CALLBACK Page6000_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    return LocalPageCallback(6000, fCreate, hwndOwner, hwndPage, hwndTab);
}
HWND CALLBACK Page6100_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    return LocalPageCallback(6100, fCreate, hwndOwner, hwndPage, hwndTab);
}
HWND CALLBACK Page6200_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    return LocalPageCallback(6200, fCreate, hwndOwner, hwndPage, hwndTab);
}
HWND CALLBACK Page6300_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    return LocalPageCallback(6300, fCreate, hwndOwner, hwndPage, hwndTab);
}
HWND CALLBACK Page6400_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    return LocalPageCallback(6400, fCreate, hwndOwner, hwndPage, hwndTab);
}
HWND CALLBACK Page6500_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    return LocalPageCallback(6500, fCreate, hwndOwner, hwndPage, hwndTab);
}
HWND CALLBACK Page6600_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    return LocalPageCallback(6600, fCreate, hwndOwner, hwndPage, hwndTab);
}
HWND CALLBACK Page6700_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    return LocalPageCallback(6700, fCreate, hwndOwner, hwndPage, hwndTab);
}
HWND CALLBACK Page6800_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    return LocalPageCallback(6800, fCreate, hwndOwner, hwndPage, hwndTab);
}
HWND CALLBACK Page6850_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    return LocalPageCallback(6850, fCreate, hwndOwner, hwndPage, hwndTab);
}
HWND CALLBACK Page6900_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    return LocalPageCallback(6900, fCreate, hwndOwner, hwndPage, hwndTab);
}
HWND CALLBACK Page7000_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
    return LocalPageCallback(7000, fCreate, hwndOwner, hwndPage, hwndTab);
}

/*- Tab Control Initialization Data --------------------------------------------*/

static const SFTTABS_CONTROL CtlInit = {
    SFTTABSSTYLE_WIZARD,                 /* tab style */
    1,                                   /* number of rows */
    0,                                   /* number of tabs per row (if fFixed) */
    0,                                   /* width of left margin */
    0,                                   /* width of right margin */
    FALSE,                               /* same width for all tabs */
    TRUE,                                /* Client area wanted */
    FALSE,                               /* allow multiline label text */
    TRUE,                                /* use with dialog */
    FALSE,                               /* use specified background color only for text */
    FALSE,                               /* scrollable tabs */
    FALSE,                               /* hide scroll buttons */
    FALSE,                               /* bold font for active tab wanted */
    FALSE,                               /* fill rows completely */
    NULL,                                /* scroll button bitmap */
    NULL,                                /* Dialog data associated with active tab */
    NULL,                                /* Dialog window handle associated with active tab */
    NULL,                                /* Frame, used as client area */
    FALSE,                               /* Tooltips wanted */
    FALSE,                               /* drop text if it doesn't fit */
    FALSE,                               /* conditional scroll buttons */
    BMBUTTONSTYLE_STD,                   /* scroll button style */
    FALSE,                               /* display ... if truncated */
    FALSE,                               /* Flyby highlighting */
    FALSE,                               /* use client area colors in partially obscured frames */
    FALSE,                               /* scroll buttons on left side */
    -1,                                  /* row indentation */
    FALSE,                               /* don't show truncated pattern for clipped tab */
    FALSE,                               /* full size scroll buttons */
    FALSE,                               /* use themes on Windows XP */
    FALSE,                               /* use exact window region */
    FALSE,                               /* always show prefix _ */
    0,0,0,0,                             /* animation values */
    NULL,                                /* disabled button bitmap */
    TRUE,                                /* focus rectangle if the control has i/p focus */
    FALSE,                               /* TRUE if Close button wanted */
    FALSE,                               /* TRUE if Close button disabled */
    FALSE,                               /* TRUE if WM_CLOSE message wanted */
    FALSE,                               /* TRUE if Minimize, Restore, Close buttons are full size */
    SFTTABS_BUTTON_NEAR,                 /* scroll button alignment */
    SFTTABS_BUTTON_NEAR,                 /* Minimize, Restore, Close button alignment */
    FALSE,                               /* TRUE if Minimize button wanted */
    FALSE,                               /* TRUE if Minimize button disabled */
    FALSE,                               /* TRUE if Restore button wanted */
    FALSE,                               /* TRUE if Restore button disabled */
    NULL,                                /* Close, Minimize, Restore button bitmap */
    NULL,                                /* Close, Minimize, Restore disabled button bitmap */
    TEXT(""),                            /* scroll left button tooltip */
    TEXT(""),                            /* scroll button tooltip */
    TEXT(""),                            /* Close button tooltip */
    TEXT(""),                            /* Minimize button tooltip */
    TEXT(""),                            /* Restore button tooltip */
    0,                                   /* custom modifications */
    0,                                   /* forced height/width depending on tab style - 0 to ignore */
    FALSE,                               /* switch tabs on button release (or down if FALSE) */
    FALSE,                               /* Rendering compatible with pre-6.0 */
    FALSE,                               /* don't display clientarea border - select styles only */
    SFTTABS_TABS_LEFT,                   /* alignment of tabs on all rows */
    SFTTABS_LAYOUT_DISTRIBUTE,           /* distribution of tabs on rows */
    0, 0,                                /* minimum and maximum number of rows for autoflow layout (none specified) */
    FALSE,                               /* reorderable tabs */
    FALSE,                               /* drag & drop */
};

static const SFTTABS_TAB Tab0 = {   /*0Application */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color (when selected) */
    { SFTTABS_GRAPH_NONE, 0 },           /* location */
    TRUE,                                /* enabled/disabled */
    0,                                   /* userdata */
    (SFTTABS_DWORD_PTR) Page6000_Callback,           /* create/destroy callback */
    NULL,                                /* reserved */
    SFTTABS_NOCOLOR,                     /* Flyby foreground color */
    SFTTABS_NOCOLOR,                     /* Client area background color */
    0,0,0,0,                             /* animation values */
    NULL,                                /* tab-specific ImageList handle*/
    FALSE,                               /* hidden tab */
    SFTTABS_NOCOLOR,                     /* gradient fill background color */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill background color, active tab */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill client area color */
    SFTTABS_NOCOLOR, 
    0,0,0,                         /* TabPicture, TabPictureDisabled and TabPictureHot */
    FALSE,                               /* has tab close button */
    0,0,0,0,0,                   /* gap2, TabPicture2, TabPicture2Active, TabPicture2Disabled, TabPicture2Hot */
};
static const SFTTABS_TAB Tab1 = {   /*1Basic Operation */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color (when selected) */
    { SFTTABS_GRAPH_NONE, 0 },           /* location */
    TRUE,                                /* enabled/disabled */
    0,                                   /* userdata */
    (SFTTABS_DWORD_PTR) Page6100_Callback,           /* create/destroy callback */
    NULL,                                /* reserved */
    SFTTABS_NOCOLOR,                     /* Flyby foreground color */
    SFTTABS_NOCOLOR,                     /* Client area background color */
    0,0,0,0,                             /* animation values */
    NULL,                                /* tab-specific ImageList handle*/
    FALSE,                               /* hidden tab */
    SFTTABS_NOCOLOR,                     /* gradient fill background color */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill background color, active tab */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill client area color */
    SFTTABS_NOCOLOR, 
    0,0,0,                         /* TabPicture, TabPictureDisabled and TabPictureHot */
    FALSE,                               /* has tab close button */
    0,0,0,0,0,                   /* gap2, TabPicture2, TabPicture2Active, TabPicture2Disabled, TabPicture2Hot */
};
static const SFTTABS_TAB Tab2 = {   /*1OLE 2 Options */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color (when selected) */
    { SFTTABS_GRAPH_NONE, 0 },           /* location */
    TRUE,                                /* enabled/disabled */
    0,                                   /* userdata */
    (SFTTABS_DWORD_PTR) Page6200_Callback,           /* create/destroy callback */
    NULL,                                /* reserved */
    SFTTABS_NOCOLOR,                     /* Flyby foreground color */
    SFTTABS_NOCOLOR,                     /* Client area background color */
    0,0,0,0,                             /* animation values */
    NULL,                                /* tab-specific ImageList handle*/
    FALSE,                               /* hidden tab */
    SFTTABS_NOCOLOR,                     /* gradient fill background color */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill background color, active tab */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill client area color */
    SFTTABS_NOCOLOR, 
    0,0,0,                         /* TabPicture, TabPictureDisabled and TabPictureHot */
    FALSE,                               /* has tab close button */
    0,0,0,0,0,                   /* gap2, TabPicture2, TabPicture2Active, TabPicture2Disabled, TabPicture2Hot */
};
static const SFTTABS_TAB Tab3 = {   /*1Code Gen Control */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color (when selected) */
    { SFTTABS_GRAPH_NONE, 0 },           /* location */
    TRUE,                                /* enabled/disabled */
    0,                                   /* userdata */
    (SFTTABS_DWORD_PTR) Page6300_Callback,           /* create/destroy callback */
    NULL,                                /* reserved */
    SFTTABS_NOCOLOR,                     /* Flyby foreground color */
    SFTTABS_NOCOLOR,                     /* Client area background color */
    0,0,0,0,                             /* animation values */
    NULL,                                /* tab-specific ImageList handle*/
    FALSE,                               /* hidden tab */
    SFTTABS_NOCOLOR,                     /* gradient fill background color */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill background color, active tab */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill client area color */
    SFTTABS_NOCOLOR, 
    0,0,0,                         /* TabPicture, TabPictureDisabled and TabPictureHot */
    FALSE,                               /* has tab close button */
    0,0,0,0,0,                   /* gap2, TabPicture2, TabPicture2Active, TabPicture2Disabled, TabPicture2Hot */
};
static const SFTTABS_TAB Tab4 = {   /*1Admin Options */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color (when selected) */
    { SFTTABS_GRAPH_NONE, 0 },           /* location */
    TRUE,                                /* enabled/disabled */
    0,                                   /* userdata */
    (SFTTABS_DWORD_PTR) Page6400_Callback,           /* create/destroy callback */
    NULL,                                /* reserved */
    SFTTABS_NOCOLOR,                     /* Flyby foreground color */
    SFTTABS_NOCOLOR,                     /* Client area background color */
    0,0,0,0,                             /* animation values */
    NULL,                                /* tab-specific ImageList handle*/
    FALSE,                               /* hidden tab */
    SFTTABS_NOCOLOR,                     /* gradient fill background color */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill background color, active tab */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill client area color */
    SFTTABS_NOCOLOR, 
    0,0,0,                         /* TabPicture, TabPictureDisabled and TabPictureHot */
    FALSE,                               /* has tab close button */
    0,0,0,0,0,                   /* gap2, TabPicture2, TabPicture2Active, TabPicture2Disabled, TabPicture2Hot */
};
static const SFTTABS_TAB Tab5 = {   /*0Main Window */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color (when selected) */
    { SFTTABS_GRAPH_NONE, 0 },           /* location */
    TRUE,                                /* enabled/disabled */
    0,                                   /* userdata */
    (SFTTABS_DWORD_PTR) Page6500_Callback,           /* create/destroy callback */
    NULL,                                /* reserved */
    SFTTABS_NOCOLOR,                     /* Flyby foreground color */
    SFTTABS_NOCOLOR,                     /* Client area background color */
    0,0,0,0,                             /* animation values */
    NULL,                                /* tab-specific ImageList handle*/
    FALSE,                               /* hidden tab */
    SFTTABS_NOCOLOR,                     /* gradient fill background color */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill background color, active tab */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill client area color */
    SFTTABS_NOCOLOR, 
    0,0,0,                         /* TabPicture, TabPictureDisabled and TabPictureHot */
    FALSE,                               /* has tab close button */
    0,0,0,0,0,                   /* gap2, TabPicture2, TabPicture2Active, TabPicture2Disabled, TabPicture2Hot */
};
static const SFTTABS_TAB Tab6 = {   /*1Basic Options */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color (when selected) */
    { SFTTABS_GRAPH_NONE, 0 },           /* location */
    TRUE,                                /* enabled/disabled */
    0,                                   /* userdata */
    (SFTTABS_DWORD_PTR) Page6600_Callback,           /* create/destroy callback */
    NULL,                                /* reserved */
    SFTTABS_NOCOLOR,                     /* Flyby foreground color */
    SFTTABS_NOCOLOR,                     /* Client area background color */
    0,0,0,0,                             /* animation values */
    NULL,                                /* tab-specific ImageList handle*/
    FALSE,                               /* hidden tab */
    SFTTABS_NOCOLOR,                     /* gradient fill background color */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill background color, active tab */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill client area color */
    SFTTABS_NOCOLOR, 
    0,0,0,                         /* TabPicture, TabPictureDisabled and TabPictureHot */
    FALSE,                               /* has tab close button */
    0,0,0,0,0,                   /* gap2, TabPicture2, TabPicture2Active, TabPicture2Disabled, TabPicture2Hot */
};
static const SFTTABS_TAB Tab7 = {   /*1SDI Client */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color (when selected) */
    { SFTTABS_GRAPH_NONE, 0 },           /* location */
    TRUE,                                /* enabled/disabled */
    0,                                   /* userdata */
    (SFTTABS_DWORD_PTR) Page6700_Callback,           /* create/destroy callback */
    NULL,                                /* reserved */
    SFTTABS_NOCOLOR,                     /* Flyby foreground color */
    SFTTABS_NOCOLOR,                     /* Client area background color */
    0,0,0,0,                             /* animation values */
    NULL,                                /* tab-specific ImageList handle*/
    FALSE,                               /* hidden tab */
    SFTTABS_NOCOLOR,                     /* gradient fill background color */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill background color, active tab */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill client area color */
    SFTTABS_NOCOLOR, 
    0,0,0,                         /* TabPicture, TabPictureDisabled and TabPictureHot */
    FALSE,                               /* has tab close button */
    0,0,0,0,0,                   /* gap2, TabPicture2, TabPicture2Active, TabPicture2Disabled, TabPicture2Hot */
};
static const SFTTABS_TAB Tab8 = {   /*1MDI Client */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color (when selected) */
    { SFTTABS_GRAPH_NONE, 0 },           /* location */
    TRUE,                                /* enabled/disabled */
    0,                                   /* userdata */
    (SFTTABS_DWORD_PTR) Page6800_Callback,           /* create/destroy callback */
    NULL,                                /* reserved */
    SFTTABS_NOCOLOR,                     /* Flyby foreground color */
    SFTTABS_NOCOLOR,                     /* Client area background color */
    0,0,0,0,                             /* animation values */
    NULL,                                /* tab-specific ImageList handle*/
    FALSE,                               /* hidden tab */
    SFTTABS_NOCOLOR,                     /* gradient fill background color */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill background color, active tab */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill client area color */
    SFTTABS_NOCOLOR, 
    0,0,0,                         /* TabPicture, TabPictureDisabled and TabPictureHot */
    FALSE,                               /* has tab close button */
    0,0,0,0,0,                   /* gap2, TabPicture2, TabPicture2Active, TabPicture2Disabled, TabPicture2Hot */
};
static const SFTTABS_TAB Tab9 = {   /*1Dialog Client */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color (when selected) */
    { SFTTABS_GRAPH_NONE, 0 },           /* location */
    TRUE,                                /* enabled/disabled */
    0,                                   /* userdata */
    (SFTTABS_DWORD_PTR) Page6850_Callback,           /* create/destroy callback */
    NULL,                                /* reserved */
    SFTTABS_NOCOLOR,                     /* Flyby foreground color */
    SFTTABS_NOCOLOR,                     /* Client area background color */
    0,0,0,0,                             /* animation values */
    NULL,                                /* tab-specific ImageList handle*/
    FALSE,                               /* hidden tab */
    SFTTABS_NOCOLOR,                     /* gradient fill background color */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill background color, active tab */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill client area color */
    SFTTABS_NOCOLOR, 
    0,0,0,                         /* TabPicture, TabPictureDisabled and TabPictureHot */
    FALSE,                               /* has tab close button */
    0,0,0,0,0,                   /* gap2, TabPicture2, TabPicture2Active, TabPicture2Disabled, TabPicture2Hot */
};
static const SFTTABS_TAB Tab10 = {   /*0MDI Child/View */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color (when selected) */
    { SFTTABS_GRAPH_NONE, 0 },           /* location */
    TRUE,                                /* enabled/disabled */
    0,                                   /* userdata */
    (SFTTABS_DWORD_PTR) Page6900_Callback,           /* create/destroy callback */
    NULL,                                /* reserved */
    SFTTABS_NOCOLOR,                     /* Flyby foreground color */
    SFTTABS_NOCOLOR,                     /* Client area background color */
    0,0,0,0,                             /* animation values */
    NULL,                                /* tab-specific ImageList handle*/
    FALSE,                               /* hidden tab */
    SFTTABS_NOCOLOR,                     /* gradient fill background color */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill background color, active tab */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill client area color */
    SFTTABS_NOCOLOR, 
    0,0,0,                         /* TabPicture, TabPictureDisabled and TabPictureHot */
    FALSE,                               /* has tab close button */
    0,0,0,0,0,                   /* gap2, TabPicture2, TabPicture2Active, TabPicture2Disabled, TabPicture2Hot */
};
static const SFTTABS_TAB Tab11 = {   /*1Basic Options */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color */
    SFTTABS_NOCOLOR, SFTTABS_NOCOLOR,    /* background, foreground color (when selected) */
    { SFTTABS_GRAPH_NONE, 0 },           /* location */
    TRUE,                                /* enabled/disabled */
    0,                                   /* userdata */
    (SFTTABS_DWORD_PTR) Page7000_Callback,           /* create/destroy callback */
    NULL,                                /* reserved */
    SFTTABS_NOCOLOR,                     /* Flyby foreground color */
    SFTTABS_NOCOLOR,                     /* Client area background color */
    0,0,0,0,                             /* animation values */
    NULL,                                /* tab-specific ImageList handle*/
    FALSE,                               /* hidden tab */
    SFTTABS_NOCOLOR,                     /* gradient fill background color */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill background color, active tab */
    SFTTABS_NOCOLOR, 
    SFTTABS_NOCOLOR,                     /* gradient fill client area color */
    SFTTABS_NOCOLOR, 
    0,0,0,                         /* TabPicture, TabPictureDisabled and TabPictureHot */
    FALSE,                               /* has tab close button */
    0,0,0,0,0,                   /* gap2, TabPicture2, TabPicture2Active, TabPicture2Disabled, TabPicture2Hot */
};

/**********************************************************************/
/*                          Frame Dialog Proc                         */
/**********************************************************************/


BOOL CALLBACK MainDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg) {

    case WM_INITDIALOG: {
        int i, index;
        HWND hwndTab, hwndTree;
        SFTTABS_TAB Tab;
        SFTTABS_CONTROL Ctl;
    
        // Center this dialog
        CenterWindow(hwndDlg);
        
        hwndTab = GetDlgItem(hwndDlg, IDC_TAB);
                                             /* get the window handle */

        /* Initialization is faster if we set redraw off */
        SendMessage(hwndTab, WM_SETREDRAW, (WPARAM)FALSE, 0);

        /* We are using new features */
        SftTabs_SetVersion(hwndTab, SFTTABS_6_5);

        index = SftTabs_AddTab(hwndTab, TEXT("0Application"));
        SftTabs_SetTabInfo(hwndTab, index, &Tab0);

        index = SftTabs_AddTab(hwndTab, TEXT("1Basic Operation"));
        SftTabs_SetTabInfo(hwndTab, index, &Tab1);

        index = SftTabs_AddTab(hwndTab, TEXT("1OLE 2 Options"));
        SftTabs_SetTabInfo(hwndTab, index, &Tab2);

        index = SftTabs_AddTab(hwndTab, TEXT("1Code Gen Control"));
        SftTabs_SetTabInfo(hwndTab, index, &Tab3);

        index = SftTabs_AddTab(hwndTab, TEXT("1Admin Options"));
        SftTabs_SetTabInfo(hwndTab, index, &Tab4);

        index = SftTabs_AddTab(hwndTab, TEXT("0Main Window"));
        SftTabs_SetTabInfo(hwndTab, index, &Tab5);

        index = SftTabs_AddTab(hwndTab, TEXT("1Basic Options"));
        SftTabs_SetTabInfo(hwndTab, index, &Tab6);

        index = SftTabs_AddTab(hwndTab, TEXT("1SDI Client"));
        SftTabs_SetTabInfo(hwndTab, index, &Tab7);

        index = SftTabs_AddTab(hwndTab, TEXT("1MDI Client"));
        SftTabs_SetTabInfo(hwndTab, index, &Tab8);

        index = SftTabs_AddTab(hwndTab, TEXT("1Dialog Client"));
        SftTabs_SetTabInfo(hwndTab, index, &Tab9);

        index = SftTabs_AddTab(hwndTab, TEXT("0MDI Child/View"));
        SftTabs_SetTabInfo(hwndTab, index, &Tab10);

        index = SftTabs_AddTab(hwndTab, TEXT("1Basic Options"));
        SftTabs_SetTabInfo(hwndTab, index, &Tab11);

        SftTabs_SetControlInfo(hwndTab, &CtlInit);

        SftTabs_SetCurrentTab(hwndTab, 0);

        // Make sure to turn redraw back on
        SendMessage(hwndTab, WM_SETREDRAW, (WPARAM)TRUE, 0);
        InvalidateRect(hwndTab, NULL, TRUE);

        // Activate current page. If your tab control doesn't have a client
        // area, make sure to define a frame window.
        SftTabs_ActivatePage(hwndDlg, hwndTab, NULL, TRUE);

        // Mark the window as a main, tabbed dialog (so accel. keys work) by registering it.
        // Register the dialog AFTER activating the current page
        SftTabs_RegisterDialog(hwndDlg);


        // load all bitmaps for the tree control
        m_ahBitmap[0] = LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BITMAP1));
        m_ahBitmap[1] = LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BITMAP2));
        m_ahBitmap[2] = LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BITMAP3));

        /*- Initialize Tree Control using Tab Control Contents -------------------------*/
        hwndTree = GetDlgItem(hwndDlg, IDC_TREE);     
        SftTree_SetItemBitmapAlign(hwndTree, TRUE);/* Align item bitmaps */
        SftTree_SetShowTruncated(hwndTree, TRUE);/* Show ... if truncated */
        SftTree_SetNoFocusStyle(hwndTree, SFTTREE_NOFOCUS_FRAME);/* No focus, show frame */
        SftTree_SetSelectionStyle(hwndTree, SFTTREE_SELECTION_CELL1);/* Select first cell only */
        SftTree_SetFlyby(hwndTree, TRUE);    /* Flyby highlighting */
        SftTree_SetScrollTips(hwndTree, TRUE);/* Show Scrolltips */
        SftTree_SetOpenEnded(hwndTree, TRUE);/* Last column width */
        SftTree_SetShowHeaderButtons(hwndTree, TRUE);/* Show column header as buttons */
        /* Define columns */
        {
            SFTTREE_COLUMN_EX aCol[1] = {
              { 0, 0,                        /* Reserved */
                100,                         /* Width (in pixels) */
                ES_LEFT | SFTTREE_TOOLTIP,   /* Cell alignment */
                ES_LEFT | SFTTREE_HEADER_UP, /* Title style */
                TEXT("Topics"),              /* Column header title */
                NULL, NULL,                  /* Reserved field and bitmap handle */
                SFTTREE_BMP_RIGHT,           /* Bitmap alignment */
                0, 0, 0,                     /* Reserved fields */
                SFTTREE_NOCOLOR,             /* Cell background color */
                SFTTREE_NOCOLOR,             /* Cell foreground color */
                SFTTREE_NOCOLOR,             /* Selected cell background color */
                SFTTREE_NOCOLOR,             /* Selected cell foreground color */
                0,                           /* Real column position (set by SetColumns call) */
                0,                           /* Display column number (display position) */
                0,
                0,                           /* minimum column width */
              }                              /* Column flag */
            };
            SftTree_SetColumnsEx(hwndTree, 1, aCol);/* Set column attributes */
        }
        SftTree_SetCharSearchMode(hwndTree, SFTTREE_CHARSEARCH_ALLCHARS, -1);/* Consider all characters typed */
        /* Change the default colors */
        {
            SFTTREE_COLORS Colors;
            SftTree_GetCtlColors(hwndTree, &Colors);/* Get current color settings */
            Colors.colorTreeLines = COLOR_BTNSHADOW | 0x80000000L;/* Tree line color */
            Colors.colorTreeLinesGrayed = COLOR_BTNSHADOW | 0x80000000L;/* Tree line color (disabled control) */
            SftTree_SetCtlColors(hwndTree, &Colors);/* Set new colors */
        }
        // Set default item bitmaps
        SftTree_SetBitmaps(hwndTree, m_ahBitmap);

        // Get tab control's information
        SftTabs_GetControlInfo(hwndTab, &Ctl);
        // copy all labels into tree control
        for (i = 0 ; i < Ctl.nTabs ; ++i) {
            SftTabs_GetTabInfo(hwndTab, i, &Tab);
            // add the tab label as a tree branch
            index = SftTree_AddString(hwndTree, Tab.lpszText+1);
            // the first character determined the level
            SftTree_SetItemLevel(hwndTree, index, *Tab.lpszText != '0' ? 1 : 0);
        }
        // now collapse all items
        SftTree_Collapse(hwndTree, -1, 0);

        // Set selection in tree control
        SftTree_SetCaretIndex(hwndTree, SftTabs_GetCurrentTab(hwndTab));
        SftTree_SetCurSel(hwndTree, SftTabs_GetCurrentTab(hwndTab));

        // all tab labels have been copied to the tree control
        return TRUE;                    // we want the i/p focus on the
                                        // main dialog's tree control
     }

    case WM_DESTROY: {
        // delete bitmaps
        DeleteObject(m_ahBitmap[0]);
        DeleteObject(m_ahBitmap[1]);
        DeleteObject(m_ahBitmap[2]);

        /* Unregister, or the window properties used won't be removed */
        SftTabs_UnregisterDialog(hwndDlg);

        /* destroy all pages */
        SftTabs_Destroy(hwndDlg, GetDlgItem(hwndDlg, IDC_TAB));
        break;
     }

    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(hwndDlg, 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(hwndDlg, hwndCtl, NULL, FALSE);
                    break;
                }
                break;
                
            case IDC_TREE:              // Tree Control
                switch (code) {
                case SFTTREEN_CARETCHANGE: {// new selection
                    int index;
                    HWND hwndTree = hwndCtl;
                    HWND hwndTab = GetDlgItem(hwndDlg, IDC_TAB);
                    // get current selection (from tree control)
                    index = SftTree_GetCaretIndex(hwndTree); 
                    // Set corresponsing tab
                    SftTabs_SetCurrentTab(hwndTab, index);
                    break;
                 }
                case SFTTREEN_LBUTTONDOWN_ITEM:
                case SFTTREEN_LBUTTONDBLCLK_ITEM:
                case SFTTREEN_LBUTTONDBLCLK_TEXT: {// expand or collapse
                    int index;
                    HWND hwndTree = hwndCtl;
                    BOOL fExpand, fControl;
                    // get current position
                    index = SftTree_GetCaretIndex(hwndTree);// get caret location
                    // check if item is expanded
                    fExpand = SftTree_GetItemExpand(hwndTree, index);
                    // if the CONTROL key is pressed, expand all dependent levels
                    fControl = (BOOL)(GetKeyState(VK_CONTROL)&0x8000);
    
                    // do the opposite
                    SftTree_SetItemExpand(hwndTree, index, !fExpand, fControl);
                    break;
                 }
                }            
                break;

            case IDOK:
            case IDCANCEL:
                if (code == BN_CLICKED)
                    SendMessage(hwndDlg, 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(hwndDlg, GetDlgItem(hwndDlg, IDC_TAB)))
                    EndDialog(hwndDlg, TRUE);
                break;
            case IDCANCEL:
                EndDialog(hwndDlg, FALSE);
                break;
                // The above assumes that this is a modal dialog. If it is a modeless
                // don't use EndDialog, use DestroyWindow instead.
            }
        }
        return TRUE;
     }
    }

    // Call SftTabs/DLL to let it handle some messages (mostly for keyboard accel. keys)
    if (SftTabs_HandleDialogMessage(hwndDlg, msg, wParam, lParam))
        return TRUE;

    return FALSE;
}

/**********************************************************************/
/*                              WinMain                               */
/**********************************************************************/

int PASCAL WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpszCmdLine, int cmdShow)
{
    // Initialize 
    g_hInst = hinst;

    SftTabs_RegisterApp(hinst);
    SftTree_RegisterApp2(hinst);
  
    // Initialize, run, and terminate the application
    DialogBox(g_hInst, MAKEINTRESOURCE(IDD_MAINDIALOG), NULL, (DLGPROC)MainDialogProc);

    SftTabs_UnregisterApp(hinst);
    SftTree_UnregisterApp2(hinst);

    return 0;
}

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