source: trunk/src/user32/windowclass.cpp@ 4494

Last change on this file since 4494 was 4494, checked in by sandervl, 25 years ago

syscolor fix + added debugint3 system menu option

File size: 15.0 KB
Line 
1/* $Id: windowclass.cpp,v 1.12 2000-10-17 17:11:09 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//******************************************************************************
28void RegisterSystemClasses(ULONG hModule)
29{
30 dprintf(("RegisterSystemClasses\n"));
31 CONTROLS_Register();
32}
33//******************************************************************************
34//******************************************************************************
35void 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//******************************************************************************
43ATOM 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//******************************************************************************
74ATOM 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//******************************************************************************
99WORD 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
110 if(Win32WndClass::FindClass(wc.hInstance, (LPWSTR)wc.lpszClassName)) {
111 dprintf(("RegisterClassW %x %x already exists", wc.hInstance, wc.lpszClassName));
112 SetLastError(ERROR_CLASS_ALREADY_EXISTS);
113 return 0;
114 }
115
116 winclass = new Win32WndClass((WNDCLASSEXA *)&wc, TRUE);
117 if(winclass == NULL) {
118 dprintf(("ERROR: RegisterClassW winclass == NULL!"));
119 DebugInt3();
120 return 0;
121 }
122 rc = winclass->getAtom();
123
124 return(rc);
125}
126//******************************************************************************
127//Note: RegisterClassA does NOT change the last error if successful! (verified in NT 4, SP6)
128//******************************************************************************
129ATOM WIN32API RegisterClassExW(CONST WNDCLASSEXW *lpwc)
130{
131 ATOM rc;
132 WNDCLASSEXA wc;
133 Win32WndClass *winclass;
134
135 dprintf(("RegisterClassExW\n"));
136 memcpy(&wc, lpwc, sizeof(WNDCLASSEXA));
137
138 if(Win32WndClass::FindClass(wc.hInstance, (LPWSTR)wc.lpszClassName)) {
139 dprintf(("RegisterClassW %x %x already exists", wc.hInstance, wc.lpszClassName));
140 SetLastError(ERROR_CLASS_ALREADY_EXISTS);
141 return 0;
142 }
143
144 winclass = new Win32WndClass((WNDCLASSEXA *)&wc, TRUE);
145 if(winclass == NULL) {
146 dprintf(("ERROR: RegisterClassExW winclass == NULL!"));
147 DebugInt3();
148 return(0);
149 }
150 rc = winclass->getAtom();
151
152 return(rc);
153}
154//******************************************************************************
155//******************************************************************************
156BOOL WIN32API UnregisterClassA(LPCSTR lpszClassName, HINSTANCE hinst)
157{
158 Win32WndClass::UnregisterClassA(hinst, (LPSTR)lpszClassName);
159
160 //Spintest returns FALSE in dll termination, so pretend it succeeded
161 return(TRUE);
162}
163//******************************************************************************
164//******************************************************************************
165BOOL WIN32API UnregisterClassW(LPCWSTR lpszClassName, HINSTANCE hinst)
166{
167 char *astring = NULL;
168
169 dprintf(("USER32: UnregisterClassW\n"));
170 if(HIWORD(lpszClassName) != 0) {
171 astring = UnicodeToAsciiString((LPWSTR)lpszClassName);
172 }
173 else astring = (char *)lpszClassName;
174
175 Win32WndClass::UnregisterClassA(hinst, (LPSTR)astring);
176 if(HIWORD(astring) != 0)
177 FreeAsciiString((char *)astring);
178
179 //Spintest returns FALSE in dll termination, so pretend it succeeded
180 return(TRUE);
181}
182//******************************************************************************
183//******************************************************************************
184BOOL WIN32API GetClassInfoA(HINSTANCE hInstance, LPCSTR lpszClass, WNDCLASSA *lpwc)
185{
186 WNDCLASSEXA wc;
187 BOOL rc;
188 Win32WndClass *wndclass;
189
190 if(HIWORD(lpszClass) != 0) {
191 dprintf(("USER32: GetClassInfoA %x %s %x", hInstance, lpszClass, lpwc));
192 }
193 else dprintf(("USER32: GetClassInfoA %x %x %x", hInstance, lpszClass, lpwc));
194
195 wndclass = Win32WndClass::FindClass(hInstance, (LPSTR)lpszClass);
196 if(wndclass) {
197 wndclass->getClassInfo(&wc);
198 memcpy(lpwc, &wc.style, sizeof(WNDCLASSA));
199 return(TRUE);
200 }
201 return(FALSE);
202}
203//******************************************************************************
204//******************************************************************************
205BOOL WIN32API GetClassInfoW(HINSTANCE hinst, LPCWSTR lpszClass, WNDCLASSW *lpwc)
206{
207 WNDCLASSEXW wc;
208 BOOL rc;
209 Win32WndClass *wndclass;
210 char *astring = NULL;
211
212 dprintf(("USER32: GetClassInfoW\n"));
213
214 if(HIWORD(lpszClass) != 0) {
215 astring = UnicodeToAsciiString((LPWSTR)lpszClass);
216 }
217 else astring = (char *)lpszClass;
218
219 wndclass = Win32WndClass::FindClass(hinst, astring);
220 if(HIWORD(astring) != 0)
221 FreeAsciiString((char *)astring);
222
223 if(wndclass) {
224 wndclass->getClassInfo(&wc);
225 memcpy(lpwc, &wc.style, sizeof(WNDCLASSW));
226 return(TRUE);
227 }
228 return(FALSE);
229}
230/****************************************************************************
231 * Name : BOOL WIN32API GetClassInfoExA
232 * Purpose : The GetClassInfoEx function retrieves information about a window
233 * class, including the handle of the small icon associated with the
234 * window class. GetClassInfo does not retrieve the handle of the small icon.
235 * Parameters: HINSTANCE hinst handle of application instance
236 * LPCTSTR lpszClass address of class name string
237 * LPWNDCLASSEX lpwcx address of structure for class data
238 * Variables :
239 * Result : If the function finds a matching class and successfully copies
240 * the data, the return value is TRUE;
241 * otherwise, it is FALSE.
242 * To get extended error information, call GetLastError.
243 * Remark : PH: does not obtain handle of the small icon
244 *****************************************************************************/
245BOOL WIN32API GetClassInfoExA(HINSTANCE hInstance,
246 LPCTSTR lpszClass,
247 LPWNDCLASSEXA lpwcx)
248{
249 BOOL rc;
250 Win32WndClass *wndclass;
251
252 if(HIWORD(lpszClass)) {
253 dprintf(("USER32:GetClassInfoExA (%08xh,%s,%08x)",
254 hInstance, lpszClass, lpwcx));
255 }
256 else dprintf(("USER32:GetClassInfoExA (%08xh,%x,%08x)",
257 hInstance, lpszClass, lpwcx));
258
259 wndclass = Win32WndClass::FindClass(hInstance, (LPSTR)lpszClass);
260 if(wndclass) {
261 wndclass->getClassInfo(lpwcx);
262 lpwcx->cbSize = sizeof(WNDCLASSEXA);
263 return(TRUE);
264 }
265 return(FALSE);
266}
267/*****************************************************************************
268 * Name : BOOL WIN32API GetClassInfoExW
269 * Purpose : The GetClassInfoEx function retrieves information about a window
270 * class, including the handle of the small icon associated with the
271 * window class. GetClassInfo does not retrieve the handle of the small icon.
272 * Parameters: HINSTANCE hinst handle of application instance
273 * LPCWSTR lpszClass address of class name string
274 * LPWNDCLASSEX lpwcx address of structure for class data
275 * Variables :
276 * Result : If the function finds a matching class and successfully copies
277 * the data, the return value is TRUE;
278 * otherwise, it is FALSE.
279 * To get extended error information, call GetLastError.
280 * Remark : does not obtain handle of the small icon
281 *
282 *****************************************************************************/
283BOOL WIN32API GetClassInfoExW(HINSTANCE hInstance,
284 LPCWSTR lpszClass,
285 LPWNDCLASSEXW lpwcx)
286{
287 BOOL rc;
288 Win32WndClass *wndclass;
289 char *astring = NULL;
290
291 dprintf(("USER32: GetClassInfoExW\n"));
292
293 if(HIWORD(lpszClass) != 0) {
294 astring = UnicodeToAsciiString((LPWSTR)lpszClass);
295 }
296 else astring = (char *)lpszClass;
297
298 wndclass = Win32WndClass::FindClass(hInstance, astring);
299 if(HIWORD(astring) != 0)
300 FreeAsciiString((char *)astring);
301
302 if(wndclass) {
303 wndclass->getClassInfo(lpwcx);
304 lpwcx->cbSize = sizeof(WNDCLASSEXW);
305 return(TRUE);
306 }
307 return(FALSE);
308}
309//******************************************************************************
310//******************************************************************************
311int WIN32API GetClassNameA(HWND hwnd, LPSTR lpszClassName, int cchClassName)
312{
313 Win32BaseWindow *wnd;
314 int rc;
315
316 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
317 if(!wnd) {
318 dprintf(("GetClassNameA wnd == NULL"));
319 return(0);
320 }
321 *lpszClassName = 0;
322 rc = (wnd->getClass())->getClassName(lpszClassName, cchClassName);
323 dprintf(("USER32: GetClassNameA %x %s (%d)", hwnd, lpszClassName, rc));
324 return rc;
325}
326//******************************************************************************
327//******************************************************************************
328int WIN32API GetClassNameW(HWND hwnd, LPWSTR lpszClassName, int cchClassName)
329{
330 Win32BaseWindow *wnd;
331
332 dprintf(("USER32: GetClassNameW\n"));
333 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
334 if(!wnd) {
335 dprintf(("GetClassNameA wnd == NULL"));
336 return(0);
337 }
338 return (wnd->getClass())->getClassName(lpszClassName, cchClassName);
339}
340//******************************************************************************
341//******************************************************************************
342LONG WIN32API SetClassLongA(HWND hwnd, int nIndex, LONG lNewVal)
343{
344 Win32BaseWindow *wnd;
345
346 dprintf(("USER32: SetClassLongA %x %d %x", hwnd, nIndex, lNewVal));
347 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
348 if(!wnd) {
349 dprintf(("SetClassLongA wnd == NULL"));
350 return(0);
351 }
352 return (wnd->getClass())->setClassLongA(nIndex, lNewVal);
353}
354//******************************************************************************
355//******************************************************************************
356LONG WIN32API SetClassLongW(HWND hwnd, int nIndex, LONG lNewVal)
357{
358 Win32BaseWindow *wnd;
359
360 dprintf(("USER32: SetClassLongW\n"));
361 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
362 if(!wnd) {
363 dprintf(("SetClassLongW wnd == NULL"));
364 return(0);
365 }
366 return (wnd->getClass())->setClassLongW(nIndex, lNewVal);
367}
368//******************************************************************************
369//******************************************************************************
370WORD WIN32API SetClassWord(HWND hwnd, int nIndex, WORD wNewVal)
371{
372 Win32BaseWindow *wnd;
373
374 dprintf(("USER32: SetClassWordA\n"));
375 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
376 if(!wnd) {
377 dprintf(("SetClassWordA wnd == NULL"));
378 return(0);
379 }
380 return (wnd->getClass())->setClassWord(nIndex, wNewVal);
381}
382//******************************************************************************
383//******************************************************************************
384WORD WIN32API GetClassWord(HWND hwnd, int nIndex)
385{
386 Win32BaseWindow *wnd;
387
388 dprintf(("USER32: GetClassWordA\n"));
389 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
390 if(!wnd) {
391 dprintf(("GetClassWordA wnd == NULL"));
392 return(0);
393 }
394 return (wnd->getClass())->getClassWord(nIndex);
395}
396//******************************************************************************
397//******************************************************************************
398LONG WIN32API GetClassLongA(HWND hwnd, int nIndex)
399{
400 Win32BaseWindow *wnd;
401
402 dprintf(("USER32: GetClassLongA %x %d", hwnd, nIndex));
403 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
404 if(!wnd) {
405 dprintf(("GetClassLongA wnd == NULL"));
406 return(0);
407 }
408 return (wnd->getClass())->getClassLongA(nIndex);
409}
410//******************************************************************************
411//******************************************************************************
412LONG WIN32API GetClassLongW(HWND hwnd, int nIndex)
413{
414 Win32BaseWindow *wnd;
415
416 dprintf(("USER32: GetClassLongW\n"));
417 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
418 if(!wnd) {
419 dprintf(("GetClassLongW wnd == NULL"));
420 return(0);
421 }
422 return (wnd->getClass())->getClassLongW(nIndex);
423}
424//******************************************************************************
425//******************************************************************************
Note: See TracBrowser for help on using the repository browser.