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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/*
Miranda Database Tool
Copyright 2000-2011 Miranda ICQ/IM project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "dbchecker.h"
static HFONT hBoldFont = NULL;
static HENHMETAFILE hEmfHeaderLogo = NULL;
static BOOL CALLBACK MyControlsEnumChildren(HWND hwnd, LPARAM)
{
DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
DWORD exstyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
char szClass[64];
int makeBold = 0;
GetClassNameA(hwnd, szClass, sizeof(szClass));
if (!strcmp(szClass, "Static")) {
if (((style & SS_TYPEMASK) == SS_LEFT || (style & SS_TYPEMASK) == SS_CENTER || (style & SS_TYPEMASK) == SS_RIGHT) && exstyle & WS_EX_CLIENTEDGE)
makeBold = 1;
}
else if (!strcmp(szClass, "Button")) {
if (exstyle&WS_EX_CLIENTEDGE)
makeBold = 1;
}
if (makeBold) {
if (hBoldFont == NULL) {
LOGFONT lf;
hBoldFont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
GetObject(hBoldFont, sizeof(lf), &lf);
lf.lfWeight = FW_BOLD;
hBoldFont = CreateFontIndirect(&lf);
}
SendMessage(hwnd, WM_SETFONT, (WPARAM)hBoldFont, 0);
SetWindowLongPtr(hwnd, GWL_EXSTYLE, exstyle&~WS_EX_CLIENTEDGE);
SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
}
return TRUE;
}
int DoMyControlProcessing(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam, INT_PTR *bReturn)
{
switch (message) {
case WM_INITDIALOG:
EnumChildWindows(hdlg, MyControlsEnumChildren, 0);
if (hEmfHeaderLogo == NULL) {
HRSRC hRsrc = FindResourceA(hInst, MAKEINTRESOURCEA(IDE_HDRLOGO), "EMF");
HGLOBAL hGlob = LoadResource(hInst, hRsrc);
hEmfHeaderLogo = SetEnhMetaFileBits(SizeofResource(hInst, hRsrc), (PBYTE)LockResource(hGlob));
}
SendDlgItemMessage(hdlg, IDC_HDRLOGO, STM_SETIMAGE, IMAGE_ENHMETAFILE, (LPARAM)hEmfHeaderLogo);
break;
case WM_CTLCOLORSTATIC:
if ((GetWindowLongPtr((HWND)lParam, GWL_STYLE) & 0xFFFF) == 0) {
char szText[256];
GetWindowTextA((HWND)lParam, szText, SIZEOF(szText));
if (!strcmp(szText, "whiterect")) {
SetTextColor((HDC)wParam, RGB(255, 255, 255));
SetBkColor((HDC)wParam, RGB(255, 255, 255));
SetBkMode((HDC)wParam, OPAQUE);
*bReturn = (INT_PTR)GetStockObject(WHITE_BRUSH);
return TRUE;
}
else {
SetBkMode((HDC)wParam, TRANSPARENT);
*bReturn = (INT_PTR)GetStockObject(NULL_BRUSH);
return TRUE;
}
}
break;
}
return FALSE;
}
INT_PTR CALLBACK WizardDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND hdlgPage;
switch (message) {
case WM_INITDIALOG:
SendMessage(hdlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_DBTOOL)));
hdlgPage = NULL;
if (bShortMode)
SendMessage(hdlg, WZM_GOTOPAGE, IDD_SELECTDB, (LPARAM)SelectDbDlgProc);
else
SendMessage(hdlg, WZM_GOTOPAGE, IDD_WELCOME, (LPARAM)WelcomeDlgProc);
TranslateDialogDefault(hdlg);
return TRUE;
case WZM_GOTOPAGE:
if (hdlgPage != NULL) DestroyWindow(hdlgPage);
EnableWindow(GetDlgItem(hdlg, IDC_BACK), TRUE);
EnableWindow(GetDlgItem(hdlg, IDOK), TRUE);
EnableWindow(GetDlgItem(hdlg, IDCANCEL), TRUE);
SetDlgItemText(hdlg, IDCANCEL, TranslateT("Cancel"));
hdlgPage = CreateDialog(hInst, MAKEINTRESOURCE(wParam), hdlg, (DLGPROC)lParam);
TranslateDialogDefault(hdlgPage);
SetWindowPos(hdlgPage, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
ShowWindow(hdlgPage, SW_SHOW);
break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_BACK:
case IDOK:
SendMessage(hdlgPage, WZN_PAGECHANGING, wParam, 0);
SendMessage(hdlgPage, message, wParam, lParam);
break;
case IDCANCEL:
wizardResult = 0;
SendMessage(hdlgPage, WZN_CANCELCLICKED, 0, 0);
EndDialog(hdlg, wizardResult);
break;
}
break;
case WM_DESTROY:
if (opts.dbChecker) {
opts.dbChecker->Destroy();
opts.dbChecker = NULL;
}
if (opts.hOutFile)
CloseHandle(opts.hOutFile);
DestroyWindow(hdlgPage);
if (hBoldFont != NULL) {
DeleteObject(hBoldFont);
hBoldFont = NULL;
}
if (hEmfHeaderLogo != NULL) {
DeleteEnhMetaFile(hEmfHeaderLogo);
hEmfHeaderLogo = NULL;
}
break;
}
return FALSE;
}
|