/****************************************************************************/
/* SftTabs/DLL 6.0 - Tab Control for C/C++ */
/* SftTabs/DLL 6.0 - Itanium Edition */
/* SftTabs/DLL 6.0 - x64 Edition */
/* SftTabs/DLL 6.0 - Windows Mobile Edition */
/* Copyright (C) 1994, 2009 Softel vdm, Inc. All Rights Reserved. */
/****************************************************************************/
#include <windows.h>
#include "sfttb.h" /* SftTabs/DLL Header File */
#include "resource.h" // application resources
/**********************************************************************/
/* Globals */
/**********************************************************************/
HINSTANCE g_hInst; // App Instance Handle
int m_lastItem = 0; // counter for spinning globe
HBITMAP m_hSampleBitmap; /* A sample bitmap */
HBITMAP m_hBackgroundBitmap; /* background bitmap */
HICON m_hSampleIcon; /* A sample icon */
/**********************************************************************/
/* Page 1 Dialog Proc */
/**********************************************************************/
BOOL CALLBACK Page1_DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult;
switch (msg) {
case WM_INITDIALOG:
SetWindowText(GetDlgItem(hwndDlg, IDC_P1_EDIT1), TEXT("Click another tab"));
SendMessage(GetDlgItem(hwndDlg, IDC_P1_CHECK1), BM_SETCHECK, 1, 0);
// initialize page
SftTabs_SetPageActive(hwndDlg, (HWND) lParam, NULL);
return !SftTabs_IsRegisteredDialog(GetParent(hwndDlg));
}
if (SftTabs_HandleDialogMessage(hwndDlg, msg, wParam, lParam))
return TRUE;
if (SftTabs_TransparentControls(hwndDlg, NULL, &msg, &wParam, &lParam, &lResult, 0, 0))
return (BOOL) lResult;
return FALSE;
}
HWND CALLBACK Page1_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 for this page
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_PAGE1), hwndOwner, (DLGPROC)Page1_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
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;
}
}
}
/**********************************************************************/
/* Page 2 Dialog Proc */
/**********************************************************************/
void CALLBACK Page2_DrawBackground(HDC hDC, HWND hwndDlg, HWND hwndTab, SFTTABS_DWORD_PTR UserData)
{
RECT rect;
GetClientRect(hwndDlg, &rect);
SftTabs_PaintTiledBitmap(hDC, m_hBackgroundBitmap, 0, 0, &rect);
}
BOOL CALLBACK Page2_DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult;
#if !defined(DEPRECATED) // NEW METHOD
// we're phasing out the use of WM_QUERYENDSESSION
// while still fully supported, SftTabs_GetEndPageMessage should be used to
// test for the "end-page" message.
// WM_QUERYENDSESSION is not supported for SftTabs/DLL Windows Mobile Edition
if (msg == SftTabs_GetEndPageMessage()) {
BOOL fEnd = (BOOL) SendMessage(GetDlgItem(hwndDlg, IDC_P2_CHECK1), BM_GETCHECK, 0, 0) != 0;
if (!fEnd) {
MessageBox(hwndDlg, TEXT("Please check the checkbox on the dialog to be able to switch to another tab."),
TEXT("Sample"), MB_APPLMODAL|MB_ICONSTOP|MB_OK);
SetWindowLong(hwndDlg, DWLP_MSGRESULT, TRUE); // cancel page switching
// this is a dialog proc, so we can't simply return True/False
// we have to use SetWindowLong instead. In a regular window proc
// we could simply return True/False
}
return TRUE; // message handled
}
#endif
switch (msg) {
case WM_INITDIALOG:
m_hBackgroundBitmap = LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BACKGROUND));
// initialize page
SftTabs_SetPageActive(hwndDlg, (HWND) lParam, NULL);
return !SftTabs_IsRegisteredDialog(GetParent(hwndDlg));
#if defined(DEPRECATED)
// we're phasing out the use of WM_QUERYENDSESSION
// while still supported, SftTabs_GetEndPageMessage should be used to
// test for the "end-page" message.
// WM_QUERYENDSESSION is not supported for SftTabs/DLL Windows Mobile Edition
case WM_QUERYENDSESSION: {
BOOL fEnd = (BOOL) SendMessage(GetDlgItem(hwndDlg, IDC_P2_CHECK1), BM_GETCHECK, 0, 0) != 0;
if (!fEnd)
MessageBox(hwndDlg, TEXT("Please check the checkbox on the dialog to be able to switch to another tab."),
TEXT("Sample"), MB_APPLMODAL|MB_ICONSTOP|MB_OK);
return !fEnd;
}
#endif
case WM_DESTROY:
DeleteObject(m_hBackgroundBitmap);
break;
}
if (SftTabs_HandleDialogMessage(hwndDlg, msg, wParam, lParam))
return TRUE;
if (SftTabs_TransparentControls(hwndDlg, Page2_DrawBackground, &msg, &wParam, &lParam, &lResult, SFTTABS_DRAWBG_OVERRIDETHEME, 0))
return (BOOL) lResult;
return FALSE;
}
HWND CALLBACK Page2_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 for this page
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_PAGE2), hwndOwner, (DLGPROC)Page2_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
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;
}
}
}
/**********************************************************************/
/* Page 3 Dialog Proc */
/**********************************************************************/
BOOL CALLBACK Page3_DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult;
switch (msg) {
case WM_INITDIALOG:
SetWindowText(GetDlgItem(hwndDlg, IDC_P3_EDIT1), TEXT("Type Here"));
// initialize page
SftTabs_SetPageActive(hwndDlg, (HWND) lParam, NULL);
return !SftTabs_IsRegisteredDialog(GetParent(hwndDlg));
}
if (SftTabs_HandleDialogMessage(hwndDlg, msg, wParam, lParam))
return TRUE;
if (SftTabs_TransparentControls(hwndDlg, NULL, &msg, &wParam, &lParam, &lResult, 0, 0))
return (BOOL) lResult;
return FALSE;
}
HWND CALLBACK Page3_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 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(IDD_PAGE3), hwndOwner, (DLGPROC)Page3_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;
}
}
/**********************************************************************/
/* Page 4 Dialog Proc */
/**********************************************************************/
BOOL CALLBACK Page4_DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult;
switch (msg) {
case WM_INITDIALOG:
// optional, set the main window's title to the window title defined for this page
SftTabs_SetPageActive(hwndDlg, (HWND)lParam, NULL);
return !SftTabs_IsRegisteredDialog(GetParent(hwndDlg));
case WM_COMMAND: {
HWND hwndCtl = (HWND) lParam;
int id = LOWORD(wParam);
int code = HIWORD(wParam);
if (hwndCtl) {
switch (id) {
case IDC_P4_NEXT: {
HWND hwndTab = SftTabs_GetTabControlFromPage(hwndDlg);
int iTab = SftTabs_GetCurrentTab(hwndTab);
SftTabs_SetCurrentTab(hwndTab, iTab+1);
break;
}
case IDC_P4_PREVIOUS: {
HWND hwndTab = SftTabs_GetTabControlFromPage(hwndDlg);
int iTab = SftTabs_GetCurrentTab(hwndTab);
SftTabs_SetCurrentTab(hwndTab, iTab-1);
break;
}
case IDC_P4_OK:
case IDC_P4_CANCEL:
// just send it to this window as a command
if (code == BN_CLICKED)
SendMessage(hwndDlg, WM_COMMAND, id, 0);
break;
}
} else {
switch (id) {
case IDC_P4_OK:
// Send IDOK to the parent window to close it
// The active page (this one) will be called
// with a WM_QUERYENDSESSION/SftTabs_GetEndPageMessage
// message first.
SendMessage(GetParent(hwndDlg), WM_COMMAND, IDOK, 0);
break;
case IDC_P4_CANCEL:
// Send IDCANCEL to the page's parent window
SendMessage(GetParent(hwndDlg), WM_COMMAND, IDCANCEL, 0);
break;
}
}
break;
}
}
if (SftTabs_HandleDialogMessage(hwndDlg, msg, wParam, lParam))
return TRUE;
if (SftTabs_TransparentControls(hwndDlg, NULL, &msg, &wParam, &lParam, &lResult, 0, 0))
return (BOOL) lResult;
return FALSE;
}
HWND CALLBACK Page4_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 for this page
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_PAGE4), hwndOwner, (DLGPROC)Page4_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
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;
}
}
}
/**********************************************************************/
/* Page 5 Dialog Proc */
/**********************************************************************/
HWND CALLBACK Page5_Callback(BOOL fCreate, HWND hwndOwner, HWND hwndPage, HWND hwndTab)
{
MessageBox(hwndOwner, TEXT("This page is empty (and not implemented). During development, pages can be left blank, ")
TEXT("which allows you to design the overall look of a tabbed dialog without implementing all pages."),
TEXT("Fifth Page"), MB_OK|MB_APPLMODAL|MB_ICONINFORMATION );
return NULL;
}
/**********************************************************************/
/* Page 6 Dialog Proc */
/**********************************************************************/
BOOL CALLBACK Page6Page_DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult;
switch (msg) {
case WM_INITDIALOG: {
HWND hwndTab = (HWND) lParam;// get the associated tab control
TCHAR szBuffer[256];
TCHAR szBuffer2[512];
SftTabs_GetTabLabel(hwndTab, SftTabs_GetCurrentTab(hwndTab), szBuffer);
wsprintf(szBuffer2, TEXT("This page's tab label reads \"%s\""), (LPCTSTR) szBuffer);
SetWindowText(GetDlgItem(hwndDlg, IDC_PAGE6_PAGE_EDIT1), szBuffer2);
// initialize page
SftTabs_SetPageActive(hwndDlg, (HWND) lParam, NULL);
// dialogs in nested tabs must return FALSE
return FALSE;
}
case WM_COMMAND: {
HWND hwndCtl = (HWND) lParam;
int id = LOWORD(wParam);
int code = HIWORD(wParam);
if (hwndCtl) {
switch (id) {
case IDC_PAGE6_PAGE_BUTTON1:
switch (code) {
case BN_CLICKED: // test button
MessageBox(NULL, TEXT("The test button has been clicked."),
TEXT("Just Testing"), MB_OK|MB_TASKMODAL|MB_ICONINFORMATION );
break;
}
break;
}
}
break;
}
}
if (SftTabs_HandleDialogMessage(hwndDlg, msg, wParam, lParam))
return TRUE;
if (SftTabs_TransparentControls(hwndDlg, NULL, &msg, &wParam, &lParam, &lResult, 0, 0))
return (BOOL) lResult;
return FALSE;
}
HWND CALLBACK Page6Page_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.
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_PAGE6_PAGEX), hwndOwner, (DLGPROC)Page6Page_DialogProc,
(LPARAM)hwndTab);// pass tab control as data
return hwnd;
}
} else { // destroying page
// We'll always destroy this page (to save resources)
DestroyWindow(hwndPage);
return NULL;
}
}
/*- Tab1 Control Initialization Data -------------------------------------------*/
static const SFTTABS_CONTROL Page6_Tab1_CtlInit = {
SFTTABSSTYLE_MODERN_I, /* tab style */
2, /* number of rows */
0, /* number of tabs per row (if fFixed) */
5, /* width of left margin */
26, /* width of right margin */
TRUE, /* 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 */
TRUE, /* Tooltips wanted */
FALSE, /* drop text if it doesn't fit */
FALSE, /* conditional scroll buttons */
BMBUTTONSTYLE_STD, /* scroll button style */
FALSE, /* display ... if truncated */
TRUE, /* 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 */
TRUE, /* use themes on Windows XP */
TRUE, /* 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 */
};
static const SFTTABS_TAB Page6_Tab1_Tab0 = { /*&1 */
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) Page6Page_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,
};
static const SFTTABS_TAB Page6_Tab1_Tab1 = { /*&2 */
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) Page6Page_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,
};
static const SFTTABS_TAB Page6_Tab1_Tab2 = { /*&3 */
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) Page6Page_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,
};
static const SFTTABS_TAB Page6_Tab1_Tab3 = { /*&4 */
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) Page6Page_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,
};
static const SFTTABS_TAB Page6_Tab1_Tab4 = { /*&5 */
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) Page6Page_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,
};
static const SFTTABS_TAB Page6_Tab1_Tab5 = { /*&6 */
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) Page6Page_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,
};
/*- Tab2 Control Initialization Data -------------------------------------------*/
static const SFTTABS_CONTROL Page6_Tab2_CtlInit = {
SFTTABSSTYLE_MODERN_I, /* tab style */
1, /* number of rows */
4, /* number of tabs per row (if fFixed) */
0, /* width of left margin */
0, /* width of right margin */
TRUE, /* 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 */
TRUE, /* scrollable tabs */
FALSE, /* hide scroll buttons */
TRUE, /* 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 */
TRUE, /* Tooltips wanted */
FALSE, /* drop text if it doesn't fit */
FALSE, /* conditional scroll buttons */
BMBUTTONSTYLE_THEME_SCROLL, /* scroll button style */
FALSE, /* display ... if truncated */
TRUE, /* 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 */
TRUE, /* full size scroll buttons */
TRUE, /* use themes on Windows XP */
TRUE, /* 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 */
};
static const SFTTABS_TAB Page6_Tab2_Tab0 = { /* &A */
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) Page6Page_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,
};
static const SFTTABS_TAB Page6_Tab2_Tab1 = { /* &B */
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) Page6Page_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,
};
static const SFTTABS_TAB Page6_Tab2_Tab2 = { /* &C */
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) Page6Page_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,
};
static const SFTTABS_TAB Page6_Tab2_Tab3 = { /* &D */
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) Page6Page_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,
};
static const SFTTABS_TAB Page6_Tab2_Tab4 = { /* &E */
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) Page6Page_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,
};
static const SFTTABS_TAB Page6_Tab2_Tab5 = { /* &F */
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) Page6Page_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,
};
BOOL CALLBACK Page6_DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult;
switch (msg) {
case WM_INITDIALOG: {
HWND hwndTab;
int index;
// Initialize Tab Control # 1 of this page
hwndTab = GetDlgItem(hwndDlg, IDC_P6_TAB1);
/* 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_0);
index = SftTabs_AddTab(hwndTab, TEXT("&1"));
SftTabs_SetToolTip(hwndTab, index, TEXT("ToolTip for the first tab"));
SftTabs_SetTabInfo(hwndTab, index, &Page6_Tab1_Tab0);
index = SftTabs_AddTab(hwndTab, TEXT("&2"));
SftTabs_SetToolTip(hwndTab, index, TEXT("ToolTip for the second tab"));
SftTabs_SetTabInfo(hwndTab, index, &Page6_Tab1_Tab1);
index = SftTabs_AddTab(hwndTab, TEXT("&3"));
SftTabs_SetToolTip(hwndTab, index, TEXT("ToolTip for the third tab"));
SftTabs_SetTabInfo(hwndTab, index, &Page6_Tab1_Tab2);
index = SftTabs_AddTab(hwndTab, TEXT("&4"));
SftTabs_SetToolTip(hwndTab, index, TEXT("ToolTip for the fourth tab"));
SftTabs_SetTabInfo(hwndTab, index, &Page6_Tab1_Tab3);
index = SftTabs_AddTab(hwndTab, TEXT("&5"));
SftTabs_SetToolTip(hwndTab, index, TEXT("ToolTip for the fifth tab"));
SftTabs_SetTabInfo(hwndTab, index, &Page6_Tab1_Tab4);
index = SftTabs_AddTab(hwndTab, TEXT("&6"));
SftTabs_SetToolTip(hwndTab, index, TEXT("ToolTip for the sixth tab"));
SftTabs_SetTabInfo(hwndTab, index, &Page6_Tab1_Tab5);
SftTabs_SetControlInfo(hwndTab, &Page6_Tab1_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
SftTabs_ActivatePage(hwndDlg, hwndTab, NULL, TRUE);
// Set default transition effect
{
SFTTABS_CONTROL Ctl;
SftTabs_GetControlInfo(hwndTab, &Ctl);
Ctl.defaultAnimationStyleShow = SFTTABS_EXPAND_CENTER;
Ctl.defaultAnimationTimeShow = 200;
SftTabs_SetControlInfo(hwndTab, &Ctl);
}
// Initialize Tab Control # 2 of this page
hwndTab = GetDlgItem(hwndDlg, IDC_P6_TAB2);
/* 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_0);
index = SftTabs_AddTab(hwndTab, TEXT("&A"));
SftTabs_SetToolTip(hwndTab, index, TEXT("ToolTip for tab number 1"));
SftTabs_SetTabInfo(hwndTab, index, &Page6_Tab2_Tab0);
index = SftTabs_AddTab(hwndTab, TEXT("&B"));
SftTabs_SetToolTip(hwndTab, index, TEXT("ToolTip for tab number 2"));
SftTabs_SetTabInfo(hwndTab, index, &Page6_Tab2_Tab1);
index = SftTabs_AddTab(hwndTab, TEXT("&C"));
SftTabs_SetToolTip(hwndTab, index, TEXT("ToolTip for tab number 3"));
SftTabs_SetTabInfo(hwndTab, index, &Page6_Tab2_Tab2);
index = SftTabs_AddTab(hwndTab, TEXT("&D"));
SftTabs_SetToolTip(hwndTab, index, TEXT("ToolTip for tab number 4"));
SftTabs_SetTabInfo(hwndTab, index, &Page6_Tab2_Tab3);
index = SftTabs_AddTab(hwndTab, TEXT("&E"));
SftTabs_SetToolTip(hwndTab, index, TEXT("ToolTip for tab number 5"));
SftTabs_SetTabInfo(hwndTab, index, &Page6_Tab2_Tab4);
index = SftTabs_AddTab(hwndTab, TEXT("&F"));
SftTabs_SetToolTip(hwndTab, index, TEXT("ToolTip for tab number 6"));
SftTabs_SetTabInfo(hwndTab, index, &Page6_Tab2_Tab5);
SftTabs_SetControlInfo(hwndTab, &Page6_Tab2_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 for tab2
SftTabs_ActivatePage(hwndDlg, hwndTab, NULL, TRUE);
// Now complete this page's activation
SftTabs_SetPageActive(hwndDlg, (HWND) lParam, NULL);
// 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);
// Set default transition effect
{
SFTTABS_CONTROL Ctl;
SftTabs_GetControlInfo(hwndTab, &Ctl);
Ctl.defaultAnimationStyleShow = SFTTABS_EXPAND_CENTER;
Ctl.defaultAnimationTimeShow = 200;
SftTabs_SetControlInfo(hwndTab, &Ctl);
}
return FALSE; // input focus already set
}
case WM_DESTROY: {
// Unregister, or the window properties used won't be removed
SftTabs_UnregisterDialog(hwndDlg);
// destroy all pages
SftTabs_Destroy(hwndDlg, GetDlgItem(hwndDlg, IDC_P6_TAB1));
SftTabs_Destroy(hwndDlg, GetDlgItem(hwndDlg, IDC_P6_TAB2));
break;
}
case WM_COMMAND: {
HWND hwndCtl = (HWND) lParam;
int id = LOWORD(wParam);
int code = HIWORD(wParam);
if (hwndCtl) {
switch (id) {
case IDC_P6_TAB1:
case IDC_P6_TAB2:
switch (code) {
case SFTTABSN_SWITCHING:// we're about to switch away from
// the current page
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;
}
}
break;
}
}
if (SftTabs_HandleDialogMessage(hwndDlg, msg, wParam, lParam))
return TRUE;
if (SftTabs_TransparentControls(hwndDlg, NULL, &msg, &wParam, &lParam, &lResult, 0, 0))
return (BOOL) lResult;
return FALSE;
}
HWND CALLBACK Page6_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 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(IDD_PAGE6), hwndOwner, (DLGPROC)Page6_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;
}
}
/****************************************************************************/
/* 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);
}
/**********************************************************************/
/* Frame Dialog Proc */
/**********************************************************************/
/*- Tab Control Initialization Data --------------------------------------------*/
static const SFTTABS_CONTROL CtlInit = {
SFTTABSSTYLE_MODERN_I, /* tab style */
2, /* 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 */
TRUE, /* bold font for active tab wanted */
TRUE, /* 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 */
TRUE, /* Tooltips wanted */
FALSE, /* drop text if it doesn't fit */
FALSE, /* conditional scroll buttons */
BMBUTTONSTYLE_STD, /* scroll button style */
FALSE, /* display ... if truncated */
TRUE, /* 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 */
TRUE, /* use themes on Windows XP */
TRUE, /* 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 */
};
static const SFTTABS_TAB Tab0 = { /*The First One */
SFTTABS_NOCOLOR, RGB(0,0,255), /* background, foreground color */
SFTTABS_NOCOLOR, RGB(0,0,255), /* background, foreground color (when selected) */
{ SFTTABS_GRAPH_LEFT, 0 }, /* location */
TRUE, /* enabled/disabled */
0, /* userdata */
(SFTTABS_DWORD_PTR) Page1_Callback, /* user supplied tab 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,
};
static const SFTTABS_TAB Tab1 = { /*&Second */
SFTTABS_NOCOLOR, RGB(255,0,0), /* background, foreground color */
SFTTABS_NOCOLOR, RGB(255,0,0), /* background, foreground color (when selected) */
{ SFTTABS_GRAPH_RIGHT, 0 }, /* location */
TRUE, /* enabled/disabled */
0, /* userdata */
(SFTTABS_DWORD_PTR) Page2_Callback, /* user supplied tab 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,
};
static const SFTTABS_TAB Tab2 = { /*&Third */
SFTTABS_NOCOLOR, RGB(128,128,0), /* background, foreground color */
SFTTABS_NOCOLOR, RGB(128,128,0), /* background, foreground color (when selected) */
{ SFTTABS_GRAPH_NONE, 0 }, /* location */
TRUE, /* enabled/disabled */
0, /* userdata */
(SFTTABS_DWORD_PTR) Page3_Callback, /* user supplied tab 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,
};
static const SFTTABS_TAB Tab3 = { /*F&ourth */
SFTTABS_NOCOLOR, RGB(0,255,255), /* background, foreground color */
SFTTABS_NOCOLOR, RGB(0,255,255), /* background, foreground color (when selected) */
{ SFTTABS_GRAPH_NONE, 0 }, /* location */
TRUE, /* enabled/disabled */
0, /* userdata */
(SFTTABS_DWORD_PTR) Page4_Callback, /* user supplied tab 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,
};
static const SFTTABS_TAB Tab4 = { /*F&ifth */
SFTTABS_NOCOLOR, RGB(0,0,128), /* background, foreground color */
SFTTABS_NOCOLOR, RGB(0,0,128), /* background, foreground color (when selected) */
{ SFTTABS_GRAPH_NONE, 0 }, /* location */
TRUE, /* enabled/disabled */
0, /* userdata */
(SFTTABS_DWORD_PTR) Page5_Callback, /* user supplied tab 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,
};
static const SFTTABS_TAB Tab5 = { /*Si&xth */
SFTTABS_NOCOLOR, RGB(128,0,0), /* background, foreground color */
SFTTABS_NOCOLOR, RGB(128,0,0), /* background, foreground color (when selected) */
{ SFTTABS_GRAPH_NONE, 0 }, /* location */
TRUE, /* enabled/disabled */
0, /* userdata */
(SFTTABS_DWORD_PTR) Page6_Callback, /* user supplied tab callback */
NULL, /* reserved */
SFTTABS_NOCOLOR, /* Flyby foreground color */
COLOR_INFOBK|0x80000000, /* 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,
};
BOOL CALLBACK MainDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG: {
int index;
HWND hwndTab;
SFTTABS_TAB Tab;
// Center this dialog
CenterWindow(hwndDlg);
hwndTab = GetDlgItem(hwndDlg, IDC_TAB);
/* get the window handle */
/* load the bitmaps/icons */
m_hSampleBitmap = LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BITMAP));
m_hSampleIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON));
/* 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_0);
index = SftTabs_AddTab(hwndTab, TEXT("The First One"));
SftTabs_SetToolTip(hwndTab, index, TEXT("Demonstrates tabbing into and out of the tab page"));
Tab = Tab0;
Sft_SetPictureBitmap(&Tab.TabPicture, m_hSampleBitmap);
//Old Style (pre-6.0): Tab.graph.type = SFTTABS_GRAPH_BITMAP;
//Old Style (pre-6.0): Tab.graph.item.hBitmap = m_hSampleBitmap;
SftTabs_SetTabInfo(hwndTab, index, &Tab);
index = SftTabs_AddTab(hwndTab, TEXT("&Second"));
SftTabs_SetToolTip(hwndTab, index, TEXT("Demonstrates how an application can prevent tab switching"));
Tab = Tab1;
Sft_SetPictureIcon(&Tab.TabPicture, m_hSampleIcon);
//Old Style (pre-6.0): Tab.graph.type = SFTTABS_GRAPH_ICON;
//Old Style (pre-6.0): Tab.graph.item.hIcon = m_hSampleIcon;
SftTabs_SetTabInfo(hwndTab, index, &Tab);
index = SftTabs_AddTab(hwndTab, TEXT("&Third"));
SftTabs_SetToolTip(hwndTab, index, TEXT("This page is reset everytime you switch to it"));
SftTabs_SetTabInfo(hwndTab, index, &Tab2);
index = SftTabs_AddTab(hwndTab, TEXT("F&ourth"));
SftTabs_SetToolTip(hwndTab, index, TEXT("A page with private OK, Cancel, Next and Previous page buttons"));
SftTabs_SetTabInfo(hwndTab, index, &Tab3);
index = SftTabs_AddTab(hwndTab, TEXT("F&ifth"));
SftTabs_SetToolTip(hwndTab, index, TEXT("A page that has not yet been implemented"));
SftTabs_SetTabInfo(hwndTab, index, &Tab4);
index = SftTabs_AddTab(hwndTab, TEXT("Si&xth"));
SftTabs_SetToolTip(hwndTab, index, TEXT("A page with nested tab controls and pages"));
SftTabs_SetTabInfo(hwndTab, index, &Tab5);
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
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);
// Update Tab2 to use transition effects
{
SFTTABS_TAB Tab;
SftTabs_GetTabInfo(hwndTab, 2, &Tab);
Tab.animationStyleShow = SFTTABS_SLIDE_FROM_LEFT;
Tab.animationTimeShow = 400;
SftTabs_SetTabInfo(hwndTab, 2, &Tab);
}
// Update Tab5 to use transition effects
{
SFTTABS_TAB Tab;
SftTabs_GetTabInfo(hwndTab, 5, &Tab);
Tab.animationStyleShow = SFTTABS_EXPAND_CENTER;
Tab.animationTimeShow = 400;
SftTabs_SetTabInfo(hwndTab, 5, &Tab);
}
{
// Animate the entire window
// Animation works on windows 98, 2000 or better only
HMODULE hUser32 = GetModuleHandle(TEXT("USER32.DLL"));
if (hUser32) {
typedef BOOL (WINAPI* LPFNANIMATEWINDOW)(HWND, DWORD, DWORD);
LPFNANIMATEWINDOW lpfnAnimateWindow;
lpfnAnimateWindow = (LPFNANIMATEWINDOW)GetProcAddress(hUser32, "AnimateWindow");
if (lpfnAnimateWindow)
lpfnAnimateWindow(hwndDlg, 300, AW_HOR_POSITIVE);
}
}
return FALSE; // WM_INITDIALOG, input focus already set
}
case WM_DESTROY:
/* delete the bitmaps/icons */
DeleteObject(m_hSampleBitmap);
// 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: {
// Parameter packing differs between 16-bit and 32-bit Windows
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 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.
}
break;
}
}
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); /* Register with SftTabs/DLL */
// Initialize, run, and terminate the application
DialogBox(g_hInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)MainDialogProc);
SftTabs_UnregisterApp(hinst); /* Unregister from SftTabs/DLL */
return 0;
}