-
Notifications
You must be signed in to change notification settings - Fork 67
/
TBDDLG.CPP
93 lines (84 loc) · 1.97 KB
/
TBDDLG.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// TBDDLG.CPP
// ..., 2008
//
#include <slib.h>
#pragma hdrstop
#include <tv.h>
TabbedDialog * TabbedDialog::topTabbedDialog = 0; // @global
TabbedDialog::TabbedDialog(char * aName,TabbedDialogPage *aPage,int aNum)
{
num = aNum;
name = newStr(aName);
pages = new TabbedDialogPage[aNum];
memcpy(pages,aPage,sizeof(TabbedDialogPage)*num);
for(int i = 0; i < num; i++) {
pages[i].dialog = 0;
pages[i].hWnd = 0;
}
prevTabbedDialog =topTabbedDialog;
topTabbedDialog = this;
}
TabbedDialog::~TabbedDialog()
{
delete pages;
delete name;
topTabbedDialog=prevTabbedDialog;
}
ushort TabbedDialog::execute(void)
{
PROPSHEETPAGE psp;
HPROPSHEETPAGE *handles=new HPROPSHEETPAGE[num];
for(int i = 0; i < num; i++) {
psp.dwSize = sizeof(psp);
psp.dwFlags = PSP_USETITLE;
psp.hInstance = TProgram::GetInst();
psp.pszTemplate = MAKEINTRESOURCE(pages[i].id);
psp.hIcon = 0;
psp.pszTitle = pages[i].tabName;
OemToChar(psp.pszTitle,(char *)psp.pszTitle);
psp.pfnDlgProc = (DLGPROC)PropertySheetDialogProc;
psp.lParam = (long)i;
psp.pfnCallback = 0;
psp.pcRefParent = 0;
handles[i] = CreatePropertySheetPage(&psp);
}
PROPSHEETHEADER psh;
psh.dwSize = sizeof(psh);
psh.dwFlags = PSH_NOAPPLYNOW;
psh.hwndParent = APPL->H_MainWnd;
psh.hInstance = TProgram::GetInst();
psh.hIcon = 0;
psh.pszCaption = name;
OemToChar(psh.pszCaption, (char *)psh.pszCaption);
psh.nPages = num;
psh.nStartPage = 0;
psh.phpage = handles;
psh.pfnCallback = 0;
PropertySheet(&psh);
delete handles;
return lastCommand;
}
HWND TabbedDialog::setupPage(int page, TDialog * pDlg)
{
pages[page].dialog = pDlg;
lastCommand = 0;
return pages[page].hWnd;
}
void TabbedDialog::clearPage(int page)
{
pages[page].dialog = 0;
}
int TabbedDialog::findPageByHandle(HWND h)
{
int i = 0;
while(i < num && pages[i].hWnd != h)
++i;
return (i == num) ? -1 : i;
}
int TabbedDialog::findPageByID(long id)
{
int i = 0;
while(i < num && pages[i].id != id)
++i;
return (i == num) ? -1 : i;
}