-
Notifications
You must be signed in to change notification settings - Fork 187
Expand file tree
/
Copy pathctl3d.c
More file actions
427 lines (389 loc) · 12.3 KB
/
ctl3d.c
File metadata and controls
427 lines (389 loc) · 12.3 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
/*
* 16-bit CTL3D and CTL3DV2 API stubs.
*
* Copyright (c) 2003 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include <WowNT32.h>
/* Ctl3dSubclassDlg */
#define CTL3D_BUTTONS 0x0001
#define CTL3D_LISTBOXES 0x0002
#define CTL3D_EDITS 0x0004
#define CTL3D_COMBOS 0x0008
#define CTL3D_STATICTEXTS 0x0010
#define CTL3D_STATICFRAMES 0x0020
#define CTL3D_ALL 0xffff
/* resource */
#define CTL3D_3DCHECK 26567
/* Ctl3dSubclassDlgEx */
#define CTL3D_NODLGWINDOW 0x00010000
/* WM_DLGBORDER result */
#define WM_DLGBORDER (WM_USER + 3567)
#define CTL3D_NOBORDER 0
#define CTL3D_BORDER 1
/* WM_DLGSUBCLASS result */
#define WM_DLGSUBCLASS (WM_USER + 3568)
#define CTL3D_NOSUBCLASS 0
#define CTL3D_SUBCLASS 1
#define CTLMSGOFFSET 3569
#define CTL3D_CTLCOLOR (WM_USER + CTLMSGOFFSET)
struct autosubclass
{
HHOOK hook;
DWORD type;
};
static DWORD autosubclass_index = NULL;
static WNDPROC listbox_proc;
static WNDPROC button_proc;
static WNDPROC static_proc;
static WNDPROC combo_proc;
static WNDPROC edit_proc;
static WNDPROC dialog_proc;
LRESULT WINAPI __wine_call_wndproc(HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPARAM lParam, WNDPROC proc);
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID lpvReserved)
{
WNDCLASSA cls;
switch (reason)
{
case DLL_PROCESS_ATTACH:
if (GetClassInfoA(hinstDLL, "LISTBOX", &cls))
listbox_proc = cls.lpfnWndProc;
if (GetClassInfoA(hinstDLL, "BUTTON", &cls))
button_proc = cls.lpfnWndProc;
if (GetClassInfoA(hinstDLL, "STATIC", &cls))
static_proc = cls.lpfnWndProc;
if (GetClassInfoA(hinstDLL, "COMBOBOX", &cls))
combo_proc = cls.lpfnWndProc;
if (GetClassInfoA(hinstDLL, "EDIT", &cls))
edit_proc = cls.lpfnWndProc;
if (GetClassInfoA(hinstDLL, "#32770", &cls))
dialog_proc = cls.lpfnWndProc;
autosubclass_index = TlsAlloc();
break;
case DLL_PROCESS_DETACH:
TlsFree(autosubclass_index);
break;
case DLL_THREAD_DETACH:
{
struct autosubclass *asc = TlsGetValue(autosubclass_index);
if (asc)
{
UnhookWindowsHookEx(asc->hook);
HeapFree(GetProcessHeap(), 0, asc);
}
break;
}
}
return TRUE;
}
static void ctl3d_static(DWORD type, DWORD *style, DWORD *exstyle)
{
switch (*style & 0xf)
{
case SS_BLACKFRAME:
if (type & CTL3D_STATICFRAMES)
{
*style &= ~SS_BLACKFRAME;
*exstyle |= WS_EX_CLIENTEDGE;
}
break;
case SS_GRAYFRAME:
if (type & CTL3D_STATICFRAMES)
{
*style &= ~SS_GRAYFRAME;
*style |= SS_ETCHEDFRAME;
}
break;
case SS_WHITEFRAME:
if (type & CTL3D_STATICFRAMES)
{
*style &= ~SS_WHITEFRAME;
*exstyle |= WS_EX_DLGMODALFRAME;
}
break;
case SS_BLACKRECT:
if (type & CTL3D_STATICTEXTS)
{
*style &= ~SS_BLACKRECT;
*exstyle |= WS_EX_CLIENTEDGE;
}
break;
case SS_GRAYRECT:
if (type & CTL3D_STATICTEXTS)
{
*style &= ~SS_GRAYRECT;
*style |= SS_ETCHEDFRAME;
}
break;
case SS_WHITERECT:
if (type & CTL3D_STATICTEXTS)
{
*style &= ~SS_WHITERECT;
*exstyle |= WS_EX_DLGMODALFRAME;
}
break;
}
}
static LRESULT CALLBACK subclassproc(INT code, WPARAM wp, LPARAM lp)
{
struct autosubclass *asc = TlsGetValue(autosubclass_index);
if (code == HCBT_CREATEWND)
{
CBT_CREATEWNDA *cbt_cw = (CBT_CREATEWNDA *)lp;
char *cls = cbt_cw->lpcs->lpszClass;
if ((DWORD)cls & 0xffff0000)
{
if ((asc->type & CTL3D_EDITS) && (!strcmpi(cls, "EDIT")) || ((asc->type & CTL3D_LISTBOXES) && !strcmpi(cls, "LISTBOX")))
{
DWORD exstyle = cbt_cw->lpcs->dwExStyle | WS_EX_CLIENTEDGE;
SetWindowLongA(wp, GWL_EXSTYLE, exstyle);
}
if (!strcmpi(cls, "STATIC"))
{
DWORD style = cbt_cw->lpcs->style;
DWORD exstyle = cbt_cw->lpcs->dwExStyle;
ctl3d_static(asc->type, &style, &exstyle);
cbt_cw->lpcs->style = style;
cbt_cw->lpcs->dwExStyle = exstyle;
SetWindowLongA(wp, GWL_STYLE, style);
SetWindowLongA(wp, GWL_EXSTYLE, exstyle);
}
}
}
return CallNextHookEx(asc->hook, code, wp, lp);
}
/***********************************************************************
* Ctl3dAutoSubclassEx (CTL3DV2.27)
*/
BOOL16 WINAPI Ctl3dAutoSubclassEx16(HINSTANCE16 hInst, DWORD type)
{
struct autosubclass *asc = TlsGetValue(autosubclass_index);
if (!asc)
{
asc = (struct autosubclass *)HeapAlloc(GetProcessHeap(), 0, sizeof(struct autosubclass));
asc->hook = SetWindowsHookExA(WH_CBT, subclassproc, NULL, GetCurrentThreadId());
TlsSetValue(autosubclass_index, asc);
}
asc->type = type;
return TRUE;
}
/***********************************************************************
* Ctl3dAutoSubclass (CTL3DV2.16)
*/
BOOL16 WINAPI Ctl3dAutoSubclass16(HINSTANCE16 hInst)
{
Ctl3dAutoSubclassEx16(hInst, CTL3D_ALL);
return TRUE;
}
/***********************************************************************
* Ctl3dColorChange (CTL3DV2.6)
*/
BOOL16 WINAPI Ctl3dColorChange16(void)
{
return TRUE;
}
/***********************************************************************
* Ctl3dCtlColor (CTL3DV2.4)
*/
HBRUSH WINAPI Ctl3dCtlColor16(HDC16 hdc, LONG hwnd)
{
return 0;
}
/***********************************************************************
* Ctl3dCtlColorEx (CTL3DV2.18)
*/
HBRUSH WINAPI Ctl3dCtlColorEx16(UINT16 msg, WPARAM16 wParam, LPARAM lParam)
{
return 0;
}
/***********************************************************************
* Ctl3dDlgFramePaint (CTL3DV2.20)
*/
LRESULT WINAPI Ctl3dDlgFramePaint16(HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPARAM lParam)
{
return __wine_call_wndproc(hwnd, msg, wParam, lParam, DefWindowProcA);
}
/***********************************************************************
* Ctl3dEnabled (CTL3DV2.5)
*/
BOOL16 WINAPI Ctl3dEnabled16(void)
{
return FALSE;
}
/***********************************************************************
* Ctl3dGetVer (CTL3DV2.1)
*/
WORD WINAPI Ctl3dGetVer16(void)
{
return MAKEWORD(31,2);
}
/***********************************************************************
* Ctl3dIsAutoSubclass (CTL3DV2.23)
*/
BOOL16 WINAPI Ctl3dIsAutoSubclass16(void)
{
return TlsGetValue(autosubclass_index) ? TRUE : FALSE;
}
/***********************************************************************
* Ctl3dRegister (CTL3DV2.12)
*/
BOOL16 WINAPI Ctl3dRegister16(HINSTANCE16 hInst)
{
return TRUE;
}
/***********************************************************************
* Ctl3dSubclassCtlEx (CTL3DV2.25)
*/
BOOL16 WINAPI Ctl3dSubclassCtlEx16(HWND16 hwnd, INT16 type)
{
HWND hwnd32 = HWND_32(hwnd);
char buf[200] = { 0 };
GetClassNameA(hwnd32, buf, sizeof(buf));
if ((type & CTL3D_EDITS) && (!strcmpi(buf, "EDIT")) || ((type & CTL3D_LISTBOXES) && !strcmpi(buf, "LISTBOX")))
{
SetWindowLongA(hwnd32, GWL_EXSTYLE, GetWindowLongA(hwnd32, GWL_EXSTYLE) | WS_EX_CLIENTEDGE);
SetWindowPos(hwnd32, 0, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DRAWFRAME);
}
else if (!strcmpi(buf, "STATIC"))
{
DWORD style = GetWindowLongA(hwnd32, GWL_STYLE);
DWORD exstyle = GetWindowLongA(hwnd32, GWL_EXSTYLE);
ctl3d_static(type, &style, &exstyle);
SetWindowLongA(hwnd32, GWL_STYLE, style);
SetWindowLongA(hwnd32, GWL_EXSTYLE, exstyle);
}
return TRUE;
}
/***********************************************************************
* Ctl3dSubclassCtl (CTL3DV2.3)
*/
BOOL16 WINAPI Ctl3dSubclassCtl16(HWND16 hwnd)
{
return Ctl3dSubclassCtlEx16(hwnd, CTL3D_ALL);
}
struct ctl3d_enumproc
{
HWND parent;
DWORD types;
};
BOOL CALLBACK ctl3d_enumproc(HWND hwnd, LPARAM lparam)
{
struct ctl3d_enumproc *data = (struct ctl3d_enumproc*)lparam;
if (GetParent(hwnd) != data->parent)
return TRUE;
Ctl3dSubclassCtlEx16(HWND_16(hwnd), data->types);
}
/***********************************************************************
* Ctl3dSubclassDlgEx (CTL3DV2.21)
*/
BOOL16 WINAPI Ctl3dSubclassDlgEx16(HWND16 hwnd, DWORD types)
{
struct ctl3d_enumproc data = { 0 };
data.parent = HWND_32(hwnd);
data.types = types;
EnumChildWindows(data.parent, ctl3d_enumproc, (LPARAM)&data);
return FALSE;
}
/***********************************************************************
* Ctl3dSubclassDlg (CTL3DV2.2)
*/
BOOL16 WINAPI Ctl3dSubclassDlg16(HWND16 hwnd, WORD types)
{
return Ctl3dSubclassDlgEx16(hwnd, types);
}
/***********************************************************************
* Ctl3dUnAutoSubclass (CTL3DV2.24)
*/
BOOL16 WINAPI Ctl3dUnAutoSubclass16(void)
{
struct autosubclass *asc = TlsGetValue(autosubclass_index);
if (asc)
{
UnhookWindowsHookEx(asc->hook);
HeapFree(GetProcessHeap(), 0, asc);
TlsSetValue(autosubclass_index, 0);
}
return FALSE;
}
/***********************************************************************
* Ctl3dUnregister (CTL3DV2.13)
*/
BOOL16 WINAPI Ctl3dUnregister16(HINSTANCE16 hInst)
{
Ctl3dUnAutoSubclass16();
return TRUE;
}
/***********************************************************************
* Ctl3dUnsubclassCtl (CTL3DV2.26)
*/
BOOL16 WINAPI Ctl3dUnsubclassCtl16(HWND16 hwnd)
{
return FALSE;
}
/***********************************************************************
* Ctl3dWinIniChange (CTL3DV2.22)
*/
void WINAPI Ctl3dWinIniChange16(void)
{
}
/***********************************************************************
* ComboWndProc3d (CTL3DV2.10)
*/
LRESULT WINAPI ComboWndProc3d16(HWND16 hwnd, UINT16 msg,WPARAM16 wparam, LPARAM lparam)
{
return __wine_call_wndproc(hwnd, msg, wparam, lparam, combo_proc);
}
/***********************************************************************
* BtnWndProc3d (CTL3DV2.7)
*/
LRESULT WINAPI BtnWndProc3d16(HWND16 hwnd, UINT16 msg, WPARAM16 wparam, LPARAM lparam)
{
return __wine_call_wndproc(hwnd, msg, wparam, lparam, button_proc);
}
/***********************************************************************
* StaticWndProc3d (CTL3DV2.11)
*/
LRESULT WINAPI StaticWndProc3d16(HWND16 hwnd, UINT16 msg, WPARAM16 wparam, LPARAM lparam)
{
return __wine_call_wndproc(hwnd, msg, wparam, lparam, static_proc);
}
/***********************************************************************
* EditWndProc3d (CTL3DV2.8)
*/
LRESULT WINAPI EditWndProc3d16(HWND16 hwnd, UINT16 msg, WPARAM16 wparam, LPARAM lparam)
{
return __wine_call_wndproc(hwnd, msg, wparam, lparam, edit_proc);
}
/***********************************************************************
* ListWndProc3d (CTL3DV2.9)
*/
LRESULT WINAPI ListWndProc3d16(HWND16 hwnd, UINT16 msg, WPARAM16 wparam, LPARAM lparam)
{
return __wine_call_wndproc(hwnd, msg, wparam, lparam, listbox_proc);
}
/***********************************************************************
* Ctl3dDlgProc (CTL3DV2.17)
*/
LRESULT WINAPI Ctl3dDlgProc16(HWND16 hwnd, UINT16 msg, WPARAM16 wparam, LPARAM lparam)
{
return __wine_call_wndproc(hwnd, msg, wparam, lparam, dialog_proc);
}
WORD WINAPI Ctl3dSetStyle16(WORD a1, SEGPTR a2, WORD a3)
{
return 0;
}