1 | /* $Id: windowclass.cpp,v 1.14 2001-01-02 18:14:59 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 Window Class Code for OS/2
|
---|
4 | *
|
---|
5 | *
|
---|
6 | * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 | #include <os2win.h>
|
---|
13 | #include <stdio.h>
|
---|
14 | #include <stdlib.h>
|
---|
15 | #include <string.h>
|
---|
16 | #include <stdarg.h>
|
---|
17 | #include <assert.h>
|
---|
18 | #include <misc.h>
|
---|
19 | #include <win32class.h>
|
---|
20 | #include <win32wbase.h>
|
---|
21 | #include <controls.h>
|
---|
22 |
|
---|
23 | #define DBG_LOCALLOG DBG_windowclass
|
---|
24 | #include "dbglocal.h"
|
---|
25 |
|
---|
26 | //******************************************************************************
|
---|
27 | //******************************************************************************
|
---|
28 | void RegisterSystemClasses(ULONG hModule)
|
---|
29 | {
|
---|
30 | dprintf(("RegisterSystemClasses\n"));
|
---|
31 | CONTROLS_Register();
|
---|
32 | }
|
---|
33 | //******************************************************************************
|
---|
34 | //******************************************************************************
|
---|
35 | void UnregisterSystemClasses()
|
---|
36 | {
|
---|
37 | dprintf(("UnregisterSystemClasses\n"));
|
---|
38 | CONTROLS_Unregister();
|
---|
39 | }
|
---|
40 | //******************************************************************************
|
---|
41 | //Note: RegisterClassA does NOT change the last error if successful! (verified in NT 4, SP6)
|
---|
42 | //******************************************************************************
|
---|
43 | ATOM WIN32API RegisterClassA(CONST WNDCLASSA *lpWndClass)
|
---|
44 | {
|
---|
45 | WNDCLASSEXA wc;
|
---|
46 | Win32WndClass *wclass;
|
---|
47 |
|
---|
48 | dprintf(("RegisterClassA\n"));
|
---|
49 | //CB: size new in ex structure
|
---|
50 | wc.cbSize = sizeof(wc);
|
---|
51 | memcpy(&wc.style, lpWndClass, sizeof(WNDCLASSA));
|
---|
52 | wc.hIconSm = 0;
|
---|
53 |
|
---|
54 | if(Win32WndClass::FindClass(wc.hInstance, (LPSTR)wc.lpszClassName)) {
|
---|
55 | if(HIWORD(wc.lpszClassName)) {
|
---|
56 | dprintf(("RegisterClassA %x %s already exists", wc.hInstance, wc.lpszClassName));
|
---|
57 | }
|
---|
58 | else dprintf(("RegisterClassA %x %x already exists", wc.hInstance, wc.lpszClassName));
|
---|
59 | SetLastError(ERROR_CLASS_ALREADY_EXISTS);
|
---|
60 | return 0;
|
---|
61 | }
|
---|
62 |
|
---|
63 | wclass = new Win32WndClass(&wc,FALSE);
|
---|
64 | if(wclass == NULL) {
|
---|
65 | dprintf(("ERROR: RegisterClassA winclass == NULL!"));
|
---|
66 | DebugInt3();
|
---|
67 | return(0);
|
---|
68 | }
|
---|
69 | return(wclass->getAtom());
|
---|
70 | }
|
---|
71 | //******************************************************************************
|
---|
72 | //Note: RegisterClassA does NOT change the last error if successful! (verified in NT 4, SP6)
|
---|
73 | //******************************************************************************
|
---|
74 | ATOM WIN32API RegisterClassExA(CONST WNDCLASSEXA *lpWndClass)
|
---|
75 | {
|
---|
76 | Win32WndClass *wclass;
|
---|
77 |
|
---|
78 | if(Win32WndClass::FindClass(lpWndClass->hInstance, (LPSTR)lpWndClass->lpszClassName)) {
|
---|
79 | if(HIWORD(lpWndClass->lpszClassName)) {
|
---|
80 | dprintf(("RegisterClassExA %x %s already exists", lpWndClass->hInstance, lpWndClass->lpszClassName));
|
---|
81 | }
|
---|
82 | else dprintf(("RegisterClassExA %x %x already exists", lpWndClass->hInstance, lpWndClass->lpszClassName));
|
---|
83 | SetLastError(ERROR_CLASS_ALREADY_EXISTS);
|
---|
84 | return 0;
|
---|
85 | }
|
---|
86 |
|
---|
87 | dprintf(("RegisterClassExA\n"));
|
---|
88 | wclass = new Win32WndClass((WNDCLASSEXA *)lpWndClass,FALSE);
|
---|
89 | if(wclass == NULL) {
|
---|
90 | dprintf(("ERROR: RegisterClassExA winclass == NULL!"));
|
---|
91 | DebugInt3();
|
---|
92 | return(0);
|
---|
93 | }
|
---|
94 | return(wclass->getAtom());
|
---|
95 | }
|
---|
96 | //******************************************************************************
|
---|
97 | //Note: RegisterClassA does NOT change the last error if successful! (verified in NT 4, SP6)
|
---|
98 | //******************************************************************************
|
---|
99 | WORD WIN32API RegisterClassW(CONST WNDCLASSW *lpwc)
|
---|
100 | {
|
---|
101 | ATOM rc;
|
---|
102 | WNDCLASSEXA wc;
|
---|
103 | Win32WndClass *winclass;
|
---|
104 |
|
---|
105 | dprintf(("RegisterClassW\n"));
|
---|
106 | //CB: size new in ex structure
|
---|
107 | wc.cbSize = sizeof(wc);
|
---|
108 | memcpy(&wc.style, lpwc, sizeof(WNDCLASSA));
|
---|
109 | wc.hIconSm = 0;
|
---|
110 |
|
---|
111 | if(Win32WndClass::FindClass(wc.hInstance, (LPWSTR)wc.lpszClassName)) {
|
---|
112 | dprintf(("RegisterClassW %x %x already exists", wc.hInstance, wc.lpszClassName));
|
---|
113 | SetLastError(ERROR_CLASS_ALREADY_EXISTS);
|
---|
114 | return 0;
|
---|
115 | }
|
---|
116 |
|
---|
117 | winclass = new Win32WndClass((WNDCLASSEXA *)&wc, TRUE);
|
---|
118 | if(winclass == NULL) {
|
---|
119 | dprintf(("ERROR: RegisterClassW winclass == NULL!"));
|
---|
120 | DebugInt3();
|
---|
121 | return 0;
|
---|
122 | }
|
---|
123 | rc = winclass->getAtom();
|
---|
124 |
|
---|
125 | return(rc);
|
---|
126 | }
|
---|
127 | //******************************************************************************
|
---|
128 | //Note: RegisterClassA does NOT change the last error if successful! (verified in NT 4, SP6)
|
---|
129 | //******************************************************************************
|
---|
130 | ATOM WIN32API RegisterClassExW(CONST WNDCLASSEXW *lpwc)
|
---|
131 | {
|
---|
132 | ATOM rc;
|
---|
133 | WNDCLASSEXA wc;
|
---|
134 | Win32WndClass *winclass;
|
---|
135 |
|
---|
136 | dprintf(("RegisterClassExW\n"));
|
---|
137 | memcpy(&wc, lpwc, sizeof(WNDCLASSEXA));
|
---|
138 |
|
---|
139 | if(Win32WndClass::FindClass(wc.hInstance, (LPWSTR)wc.lpszClassName)) {
|
---|
140 | dprintf(("RegisterClassW %x %x already exists", wc.hInstance, wc.lpszClassName));
|
---|
141 | SetLastError(ERROR_CLASS_ALREADY_EXISTS);
|
---|
142 | return 0;
|
---|
143 | }
|
---|
144 |
|
---|
145 | winclass = new Win32WndClass((WNDCLASSEXA *)&wc, TRUE);
|
---|
146 | if(winclass == NULL) {
|
---|
147 | dprintf(("ERROR: RegisterClassExW winclass == NULL!"));
|
---|
148 | DebugInt3();
|
---|
149 | return(0);
|
---|
150 | }
|
---|
151 | rc = winclass->getAtom();
|
---|
152 |
|
---|
153 | return(rc);
|
---|
154 | }
|
---|
155 | //******************************************************************************
|
---|
156 | //******************************************************************************
|
---|
157 | BOOL WIN32API UnregisterClassA(LPCSTR lpszClassName, HINSTANCE hinst)
|
---|
158 | {
|
---|
159 | Win32WndClass::UnregisterClassA(hinst, (LPSTR)lpszClassName);
|
---|
160 |
|
---|
161 | //Spintest returns FALSE in dll termination, so pretend it succeeded
|
---|
162 | return(TRUE);
|
---|
163 | }
|
---|
164 | //******************************************************************************
|
---|
165 | //******************************************************************************
|
---|
166 | BOOL WIN32API UnregisterClassW(LPCWSTR lpszClassName, HINSTANCE hinst)
|
---|
167 | {
|
---|
168 | char *astring = NULL;
|
---|
169 |
|
---|
170 | dprintf(("USER32: UnregisterClassW\n"));
|
---|
171 | if(HIWORD(lpszClassName) != 0) {
|
---|
172 | astring = UnicodeToAsciiString((LPWSTR)lpszClassName);
|
---|
173 | }
|
---|
174 | else astring = (char *)lpszClassName;
|
---|
175 |
|
---|
176 | Win32WndClass::UnregisterClassA(hinst, (LPSTR)astring);
|
---|
177 | if(HIWORD(astring) != 0)
|
---|
178 | FreeAsciiString((char *)astring);
|
---|
179 |
|
---|
180 | //Spintest returns FALSE in dll termination, so pretend it succeeded
|
---|
181 | return(TRUE);
|
---|
182 | }
|
---|
183 | //******************************************************************************
|
---|
184 | //******************************************************************************
|
---|
185 | BOOL WIN32API GetClassInfoA(HINSTANCE hInstance, LPCSTR lpszClass, WNDCLASSA *lpwc)
|
---|
186 | {
|
---|
187 | WNDCLASSEXA wc;
|
---|
188 | BOOL rc;
|
---|
189 | Win32WndClass *wndclass;
|
---|
190 |
|
---|
191 | if(HIWORD(lpszClass) != 0) {
|
---|
192 | dprintf(("USER32: GetClassInfoA %x %s %x", hInstance, lpszClass, lpwc));
|
---|
193 | }
|
---|
194 | else dprintf(("USER32: GetClassInfoA %x %x %x", hInstance, lpszClass, lpwc));
|
---|
195 |
|
---|
196 | wndclass = Win32WndClass::FindClass(hInstance, (LPSTR)lpszClass);
|
---|
197 | if(wndclass) {
|
---|
198 | wndclass->getClassInfo(&wc);
|
---|
199 | memcpy(lpwc, &wc.style, sizeof(WNDCLASSA));
|
---|
200 | return(TRUE);
|
---|
201 | }
|
---|
202 | return(FALSE);
|
---|
203 | }
|
---|
204 | //******************************************************************************
|
---|
205 | //******************************************************************************
|
---|
206 | BOOL WIN32API GetClassInfoW(HINSTANCE hinst, LPCWSTR lpszClass, WNDCLASSW *lpwc)
|
---|
207 | {
|
---|
208 | WNDCLASSEXW wc;
|
---|
209 | BOOL rc;
|
---|
210 | Win32WndClass *wndclass;
|
---|
211 | char *astring = NULL;
|
---|
212 |
|
---|
213 | dprintf(("USER32: GetClassInfoW\n"));
|
---|
214 |
|
---|
215 | if(HIWORD(lpszClass) != 0) {
|
---|
216 | astring = UnicodeToAsciiString((LPWSTR)lpszClass);
|
---|
217 | }
|
---|
218 | else astring = (char *)lpszClass;
|
---|
219 |
|
---|
220 | wndclass = Win32WndClass::FindClass(hinst, astring);
|
---|
221 | if(HIWORD(astring) != 0)
|
---|
222 | FreeAsciiString((char *)astring);
|
---|
223 |
|
---|
224 | if(wndclass) {
|
---|
225 | wndclass->getClassInfo(&wc);
|
---|
226 | memcpy(lpwc, &wc.style, sizeof(WNDCLASSW));
|
---|
227 | return(TRUE);
|
---|
228 | }
|
---|
229 | return(FALSE);
|
---|
230 | }
|
---|
231 | /****************************************************************************
|
---|
232 | * Name : BOOL WIN32API GetClassInfoExA
|
---|
233 | * Purpose : The GetClassInfoEx function retrieves information about a window
|
---|
234 | * class, including the handle of the small icon associated with the
|
---|
235 | * window class. GetClassInfo does not retrieve the handle of the small icon.
|
---|
236 | * Parameters: HINSTANCE hinst handle of application instance
|
---|
237 | * LPCTSTR lpszClass address of class name string
|
---|
238 | * LPWNDCLASSEX lpwcx address of structure for class data
|
---|
239 | * Variables :
|
---|
240 | * Result : If the function finds a matching class and successfully copies
|
---|
241 | * the data, the return value is TRUE;
|
---|
242 | * otherwise, it is FALSE.
|
---|
243 | * To get extended error information, call GetLastError.
|
---|
244 | * Remark : PH: does not obtain handle of the small icon
|
---|
245 | *****************************************************************************/
|
---|
246 | BOOL WIN32API GetClassInfoExA(HINSTANCE hInstance,
|
---|
247 | LPCTSTR lpszClass,
|
---|
248 | LPWNDCLASSEXA lpwcx)
|
---|
249 | {
|
---|
250 | BOOL rc;
|
---|
251 | Win32WndClass *wndclass;
|
---|
252 |
|
---|
253 | if(HIWORD(lpszClass)) {
|
---|
254 | dprintf(("USER32:GetClassInfoExA (%08xh,%s,%08x)",
|
---|
255 | hInstance, lpszClass, lpwcx));
|
---|
256 | }
|
---|
257 | else dprintf(("USER32:GetClassInfoExA (%08xh,%x,%08x)",
|
---|
258 | hInstance, lpszClass, lpwcx));
|
---|
259 |
|
---|
260 | wndclass = Win32WndClass::FindClass(hInstance, (LPSTR)lpszClass);
|
---|
261 | if(wndclass) {
|
---|
262 | wndclass->getClassInfo(lpwcx);
|
---|
263 | lpwcx->cbSize = sizeof(WNDCLASSEXA);
|
---|
264 | return(TRUE);
|
---|
265 | }
|
---|
266 | return(FALSE);
|
---|
267 | }
|
---|
268 | /*****************************************************************************
|
---|
269 | * Name : BOOL WIN32API GetClassInfoExW
|
---|
270 | * Purpose : The GetClassInfoEx function retrieves information about a window
|
---|
271 | * class, including the handle of the small icon associated with the
|
---|
272 | * window class. GetClassInfo does not retrieve the handle of the small icon.
|
---|
273 | * Parameters: HINSTANCE hinst handle of application instance
|
---|
274 | * LPCWSTR lpszClass address of class name string
|
---|
275 | * LPWNDCLASSEX lpwcx address of structure for class data
|
---|
276 | * Variables :
|
---|
277 | * Result : If the function finds a matching class and successfully copies
|
---|
278 | * the data, the return value is TRUE;
|
---|
279 | * otherwise, it is FALSE.
|
---|
280 | * To get extended error information, call GetLastError.
|
---|
281 | * Remark : does not obtain handle of the small icon
|
---|
282 | *
|
---|
283 | *****************************************************************************/
|
---|
284 | BOOL WIN32API GetClassInfoExW(HINSTANCE hInstance,
|
---|
285 | LPCWSTR lpszClass,
|
---|
286 | LPWNDCLASSEXW lpwcx)
|
---|
287 | {
|
---|
288 | BOOL rc;
|
---|
289 | Win32WndClass *wndclass;
|
---|
290 | char *astring = NULL;
|
---|
291 |
|
---|
292 | dprintf(("USER32: GetClassInfoExW\n"));
|
---|
293 |
|
---|
294 | if(HIWORD(lpszClass) != 0) {
|
---|
295 | astring = UnicodeToAsciiString((LPWSTR)lpszClass);
|
---|
296 | }
|
---|
297 | else astring = (char *)lpszClass;
|
---|
298 |
|
---|
299 | wndclass = Win32WndClass::FindClass(hInstance, astring);
|
---|
300 | if(HIWORD(astring) != 0)
|
---|
301 | FreeAsciiString((char *)astring);
|
---|
302 |
|
---|
303 | if(wndclass) {
|
---|
304 | wndclass->getClassInfo(lpwcx);
|
---|
305 | lpwcx->cbSize = sizeof(WNDCLASSEXW);
|
---|
306 | return(TRUE);
|
---|
307 | }
|
---|
308 | return(FALSE);
|
---|
309 | }
|
---|
310 | //******************************************************************************
|
---|
311 | //******************************************************************************
|
---|
312 | int WIN32API GetClassNameA(HWND hwnd, LPSTR lpszClassName, int cchClassName)
|
---|
313 | {
|
---|
314 | Win32BaseWindow *wnd;
|
---|
315 | int rc;
|
---|
316 |
|
---|
317 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
318 | if(!wnd) {
|
---|
319 | dprintf(("GetClassNameA wnd == NULL"));
|
---|
320 | return(0);
|
---|
321 | }
|
---|
322 | *lpszClassName = 0;
|
---|
323 | rc = (wnd->getClass())->getClassName(lpszClassName, cchClassName);
|
---|
324 | dprintf(("USER32: GetClassNameA %x %s (%d)", hwnd, lpszClassName, rc));
|
---|
325 | return rc;
|
---|
326 | }
|
---|
327 | //******************************************************************************
|
---|
328 | //******************************************************************************
|
---|
329 | int WIN32API GetClassNameW(HWND hwnd, LPWSTR lpszClassName, int cchClassName)
|
---|
330 | {
|
---|
331 | Win32BaseWindow *wnd;
|
---|
332 |
|
---|
333 | dprintf(("USER32: GetClassNameW\n"));
|
---|
334 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
335 | if(!wnd) {
|
---|
336 | dprintf(("GetClassNameA wnd == NULL"));
|
---|
337 | return(0);
|
---|
338 | }
|
---|
339 | return (wnd->getClass())->getClassName(lpszClassName, cchClassName);
|
---|
340 | }
|
---|
341 | //******************************************************************************
|
---|
342 | //******************************************************************************
|
---|
343 | LONG WIN32API SetClassLongA(HWND hwnd, int nIndex, LONG lNewVal)
|
---|
344 | {
|
---|
345 | Win32BaseWindow *wnd;
|
---|
346 |
|
---|
347 | dprintf(("USER32: SetClassLongA %x %d %x", hwnd, nIndex, lNewVal));
|
---|
348 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
349 | if(!wnd) {
|
---|
350 | dprintf(("SetClassLongA wnd == NULL"));
|
---|
351 | return(0);
|
---|
352 | }
|
---|
353 | return (wnd->getClass())->setClassLongA(nIndex, lNewVal);
|
---|
354 | }
|
---|
355 | //******************************************************************************
|
---|
356 | //******************************************************************************
|
---|
357 | LONG WIN32API SetClassLongW(HWND hwnd, int nIndex, LONG lNewVal)
|
---|
358 | {
|
---|
359 | Win32BaseWindow *wnd;
|
---|
360 |
|
---|
361 | dprintf(("USER32: SetClassLongW\n"));
|
---|
362 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
363 | if(!wnd) {
|
---|
364 | dprintf(("SetClassLongW wnd == NULL"));
|
---|
365 | return(0);
|
---|
366 | }
|
---|
367 | return (wnd->getClass())->setClassLongW(nIndex, lNewVal);
|
---|
368 | }
|
---|
369 | //******************************************************************************
|
---|
370 | //******************************************************************************
|
---|
371 | WORD WIN32API SetClassWord(HWND hwnd, int nIndex, WORD wNewVal)
|
---|
372 | {
|
---|
373 | Win32BaseWindow *wnd;
|
---|
374 |
|
---|
375 | dprintf(("USER32: SetClassWordA\n"));
|
---|
376 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
377 | if(!wnd) {
|
---|
378 | dprintf(("SetClassWordA wnd == NULL"));
|
---|
379 | return(0);
|
---|
380 | }
|
---|
381 | return (wnd->getClass())->setClassWord(nIndex, wNewVal);
|
---|
382 | }
|
---|
383 | //******************************************************************************
|
---|
384 | //******************************************************************************
|
---|
385 | WORD WIN32API GetClassWord(HWND hwnd, int nIndex)
|
---|
386 | {
|
---|
387 | Win32BaseWindow *wnd;
|
---|
388 |
|
---|
389 | dprintf(("USER32: GetClassWordA\n"));
|
---|
390 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
391 | if(!wnd) {
|
---|
392 | dprintf(("GetClassWordA wnd == NULL"));
|
---|
393 | return(0);
|
---|
394 | }
|
---|
395 | return (wnd->getClass())->getClassWord(nIndex);
|
---|
396 | }
|
---|
397 | //******************************************************************************
|
---|
398 | //******************************************************************************
|
---|
399 | LONG WIN32API GetClassLongA(HWND hwnd, int nIndex)
|
---|
400 | {
|
---|
401 | Win32BaseWindow *wnd;
|
---|
402 | LONG ret;
|
---|
403 |
|
---|
404 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
405 | if(!wnd) {
|
---|
406 | dprintf(("GetClassLongA %x %d wnd == NULL", hwnd, nIndex));
|
---|
407 | return(0);
|
---|
408 | }
|
---|
409 | ret = (wnd->getClass())->getClassLongA(nIndex);
|
---|
410 | dprintf(("USER32: GetClassLongA %x %d returned %x", hwnd, nIndex, ret));
|
---|
411 | return ret;
|
---|
412 | }
|
---|
413 | //******************************************************************************
|
---|
414 | //******************************************************************************
|
---|
415 | LONG WIN32API GetClassLongW(HWND hwnd, int nIndex)
|
---|
416 | {
|
---|
417 | Win32BaseWindow *wnd;
|
---|
418 | LONG ret;
|
---|
419 |
|
---|
420 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
421 | if(!wnd) {
|
---|
422 | dprintf(("GetClassLongW %x %d wnd == NULL", hwnd, nIndex));
|
---|
423 | return(0);
|
---|
424 | }
|
---|
425 | ret = (wnd->getClass())->getClassLongW(nIndex);
|
---|
426 | dprintf(("USER32: GetClassLongW %x %d returned %x", hwnd, nIndex, ret));
|
---|
427 | return ret;
|
---|
428 | }
|
---|
429 | //******************************************************************************
|
---|
430 | //******************************************************************************
|
---|