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

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

resource handling changes

File size: 13.1 KB
Line 
1/* $Id: windowclass.cpp,v 1.10 2000-05-28 16:43:48 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//******************************************************************************
42ATOM WIN32API RegisterClassA(CONST WNDCLASSA *lpWndClass)
43{
44 WNDCLASSEXA wc;
45 Win32WndClass *wclass;
46
47 dprintf(("RegisterClassA\n"));
48 //CB: size new in ex structure
49 wc.cbSize = sizeof(wc);
50 memcpy(&wc.style, lpWndClass, sizeof(WNDCLASSA));
51 wc.hIconSm = 0;
52
53 wclass = new Win32WndClass(&wc,FALSE);
54 if(wclass == NULL) {
55 dprintf(("RegisterClassA wclass == NULL!"));
56 return(0);
57 }
58 return(wclass->getAtom());
59}
60//******************************************************************************
61//******************************************************************************
62ATOM WIN32API RegisterClassExA(CONST WNDCLASSEXA *lpWndClass)
63{
64 Win32WndClass *wclass;
65
66 dprintf(("RegisterClassExA\n"));
67 wclass = new Win32WndClass((WNDCLASSEXA *)lpWndClass,FALSE);
68 if(wclass == NULL) {
69 dprintf(("RegisterClassExA wclass == NULL!"));
70 return(0);
71 }
72 return(wclass->getAtom());
73}
74//******************************************************************************
75//******************************************************************************
76WORD WIN32API RegisterClassW(CONST WNDCLASSW *lpwc)
77{
78 ATOM rc;
79 WNDCLASSEXA wclass;
80 Win32WndClass *winclass;
81
82 dprintf(("RegisterClassW\n"));
83 //CB: size new in ex structure
84 wclass.cbSize = sizeof(wclass);
85 memcpy(&wclass.style, lpwc, sizeof(WNDCLASSA));
86
87 winclass = new Win32WndClass((WNDCLASSEXA *)&wclass, TRUE);
88 if(winclass == NULL) {
89 dprintf(("RegisterClassW wclass == NULL!"));
90 return(0);
91 }
92 rc = winclass->getAtom();
93
94 return(rc);
95}
96//******************************************************************************
97//******************************************************************************
98ATOM WIN32API RegisterClassExW(CONST WNDCLASSEXW *lpwc)
99{
100 ATOM rc;
101 WNDCLASSEXA wclass;
102 Win32WndClass *winclass;
103
104 dprintf(("RegisterClassExW\n"));
105 memcpy(&wclass, lpwc, sizeof(WNDCLASSEXA));
106
107 winclass = new Win32WndClass((WNDCLASSEXA *)&wclass, TRUE);
108 if(winclass == NULL) {
109 dprintf(("RegisterClassExW wclass == NULL!"));
110 return(0);
111 }
112 rc = winclass->getAtom();
113
114 return(rc);
115}
116//******************************************************************************
117//******************************************************************************
118BOOL WIN32API UnregisterClassA(LPCSTR lpszClassName, HINSTANCE hinst)
119{
120 Win32WndClass::UnregisterClassA(hinst, (LPSTR)lpszClassName);
121
122 //Spintest returns FALSE in dll termination, so pretend it succeeded
123 return(TRUE);
124}
125//******************************************************************************
126//******************************************************************************
127BOOL WIN32API UnregisterClassW(LPCWSTR lpszClassName, HINSTANCE hinst)
128{
129 char *astring = NULL;
130
131 dprintf(("USER32: UnregisterClassW\n"));
132 if(HIWORD(lpszClassName) != 0) {
133 astring = UnicodeToAsciiString((LPWSTR)lpszClassName);
134 }
135 else astring = (char *)lpszClassName;
136
137 Win32WndClass::UnregisterClassA(hinst, (LPSTR)astring);
138 if(HIWORD(astring) != 0)
139 FreeAsciiString((char *)astring);
140
141 //Spintest returns FALSE in dll termination, so pretend it succeeded
142 return(TRUE);
143}
144//******************************************************************************
145//******************************************************************************
146BOOL WIN32API GetClassInfoA(HINSTANCE hInstance, LPCSTR lpszClass, WNDCLASSA *lpwc)
147{
148 WNDCLASSEXA wc;
149 BOOL rc;
150 Win32WndClass *wndclass;
151
152 dprintf(("USER32: GetClassInfoA\n"));
153
154 wndclass = Win32WndClass::FindClass(hInstance, (LPSTR)lpszClass);
155 if(wndclass) {
156 wndclass->getClassInfo(&wc);
157 memcpy(lpwc, &wc.style, sizeof(WNDCLASSA));
158 return(TRUE);
159 }
160 return(FALSE);
161}
162//******************************************************************************
163//******************************************************************************
164BOOL WIN32API GetClassInfoW(HINSTANCE hinst, LPCWSTR lpszClass, WNDCLASSW *lpwc)
165{
166 WNDCLASSEXW wc;
167 BOOL rc;
168 Win32WndClass *wndclass;
169 char *astring = NULL;
170
171 dprintf(("USER32: GetClassInfoW\n"));
172
173 if(HIWORD(lpszClass) != 0) {
174 astring = UnicodeToAsciiString((LPWSTR)lpszClass);
175 }
176 else astring = (char *)lpszClass;
177
178 wndclass = Win32WndClass::FindClass(hinst, astring);
179 if(HIWORD(astring) != 0)
180 FreeAsciiString((char *)astring);
181
182 if(wndclass) {
183 wndclass->getClassInfo(&wc);
184 memcpy(lpwc, &wc.style, sizeof(WNDCLASSW));
185 return(TRUE);
186 }
187 return(FALSE);
188}
189/****************************************************************************
190 * Name : BOOL WIN32API GetClassInfoExA
191 * Purpose : The GetClassInfoEx function retrieves information about a window
192 * class, including the handle of the small icon associated with the
193 * window class. GetClassInfo does not retrieve the handle of the small icon.
194 * Parameters: HINSTANCE hinst handle of application instance
195 * LPCTSTR lpszClass address of class name string
196 * LPWNDCLASSEX lpwcx address of structure for class data
197 * Variables :
198 * Result : If the function finds a matching class and successfully copies
199 * the data, the return value is TRUE;
200 * otherwise, it is FALSE.
201 * To get extended error information, call GetLastError.
202 * Remark : PH: does not obtain handle of the small icon
203 *****************************************************************************/
204BOOL WIN32API GetClassInfoExA(HINSTANCE hInstance,
205 LPCTSTR lpszClass,
206 LPWNDCLASSEXA lpwcx)
207{
208 BOOL rc;
209 Win32WndClass *wndclass;
210
211 if(HIWORD(lpszClass)) {
212 dprintf(("USER32:GetClassInfoExA (%08xh,%s,%08x)",
213 hInstance, lpszClass, lpwcx));
214 }
215 else dprintf(("USER32:GetClassInfoExA (%08xh,%x,%08x)",
216 hInstance, lpszClass, lpwcx));
217
218 wndclass = Win32WndClass::FindClass(hInstance, (LPSTR)lpszClass);
219 if(wndclass) {
220 wndclass->getClassInfo(lpwcx);
221 lpwcx->cbSize = sizeof(WNDCLASSEXA);
222 return(TRUE);
223 }
224 return(FALSE);
225}
226/*****************************************************************************
227 * Name : BOOL WIN32API GetClassInfoExW
228 * Purpose : The GetClassInfoEx function retrieves information about a window
229 * class, including the handle of the small icon associated with the
230 * window class. GetClassInfo does not retrieve the handle of the small icon.
231 * Parameters: HINSTANCE hinst handle of application instance
232 * LPCWSTR lpszClass address of class name string
233 * LPWNDCLASSEX lpwcx address of structure for class data
234 * Variables :
235 * Result : If the function finds a matching class and successfully copies
236 * the data, the return value is TRUE;
237 * otherwise, it is FALSE.
238 * To get extended error information, call GetLastError.
239 * Remark : does not obtain handle of the small icon
240 *
241 *****************************************************************************/
242BOOL WIN32API GetClassInfoExW(HINSTANCE hInstance,
243 LPCWSTR lpszClass,
244 LPWNDCLASSEXW lpwcx)
245{
246 BOOL rc;
247 Win32WndClass *wndclass;
248 char *astring = NULL;
249
250 dprintf(("USER32: GetClassInfoExW\n"));
251
252 if(HIWORD(lpszClass) != 0) {
253 astring = UnicodeToAsciiString((LPWSTR)lpszClass);
254 }
255 else astring = (char *)lpszClass;
256
257 wndclass = Win32WndClass::FindClass(hInstance, astring);
258 if(HIWORD(astring) != 0)
259 FreeAsciiString((char *)astring);
260
261 if(wndclass) {
262 wndclass->getClassInfo(lpwcx);
263 lpwcx->cbSize = sizeof(WNDCLASSEXW);
264 return(TRUE);
265 }
266 return(FALSE);
267}
268//******************************************************************************
269//******************************************************************************
270int WIN32API GetClassNameA(HWND hwnd, LPSTR lpszClassName, int cchClassName)
271{
272 Win32BaseWindow *wnd;
273 int rc;
274
275 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
276 if(!wnd) {
277 dprintf(("GetClassNameA wnd == NULL"));
278 return(0);
279 }
280 *lpszClassName = 0;
281 rc = (wnd->getClass())->getClassName(lpszClassName, cchClassName);
282 dprintf(("USER32: GetClassNameA %x %s (%d)", hwnd, lpszClassName, rc));
283 return rc;
284}
285//******************************************************************************
286//******************************************************************************
287int WIN32API GetClassNameW(HWND hwnd, LPWSTR lpszClassName, int cchClassName)
288{
289 Win32BaseWindow *wnd;
290
291 dprintf(("USER32: GetClassNameW\n"));
292 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
293 if(!wnd) {
294 dprintf(("GetClassNameA wnd == NULL"));
295 return(0);
296 }
297 return (wnd->getClass())->getClassName(lpszClassName, cchClassName);
298}
299//******************************************************************************
300//******************************************************************************
301LONG WIN32API SetClassLongA(HWND hwnd, int nIndex, LONG lNewVal)
302{
303 Win32BaseWindow *wnd;
304
305 dprintf(("USER32: SetClassLongA %x %d %x", hwnd, nIndex, lNewVal));
306 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
307 if(!wnd) {
308 dprintf(("SetClassLongA wnd == NULL"));
309 return(0);
310 }
311 return (wnd->getClass())->setClassLongA(nIndex, lNewVal);
312}
313//******************************************************************************
314//******************************************************************************
315LONG WIN32API SetClassLongW(HWND hwnd, int nIndex, LONG lNewVal)
316{
317 Win32BaseWindow *wnd;
318
319 dprintf(("USER32: SetClassLongW\n"));
320 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
321 if(!wnd) {
322 dprintf(("SetClassLongW wnd == NULL"));
323 return(0);
324 }
325 return (wnd->getClass())->setClassLongW(nIndex, lNewVal);
326}
327//******************************************************************************
328//******************************************************************************
329WORD WIN32API SetClassWord(HWND hwnd, int nIndex, WORD wNewVal)
330{
331 Win32BaseWindow *wnd;
332
333 dprintf(("USER32: SetClassWordA\n"));
334 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
335 if(!wnd) {
336 dprintf(("SetClassWordA wnd == NULL"));
337 return(0);
338 }
339 return (wnd->getClass())->setClassWord(nIndex, wNewVal);
340}
341//******************************************************************************
342//******************************************************************************
343WORD WIN32API GetClassWord(HWND hwnd, int nIndex)
344{
345 Win32BaseWindow *wnd;
346
347 dprintf(("USER32: GetClassWordA\n"));
348 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
349 if(!wnd) {
350 dprintf(("GetClassWordA wnd == NULL"));
351 return(0);
352 }
353 return (wnd->getClass())->getClassWord(nIndex);
354}
355//******************************************************************************
356//******************************************************************************
357LONG WIN32API GetClassLongA(HWND hwnd, int nIndex)
358{
359 Win32BaseWindow *wnd;
360
361 dprintf(("USER32: GetClassLongA %x %d", hwnd, nIndex));
362 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
363 if(!wnd) {
364 dprintf(("GetClassLongA wnd == NULL"));
365 return(0);
366 }
367 return (wnd->getClass())->getClassLongA(nIndex);
368}
369//******************************************************************************
370//******************************************************************************
371LONG WIN32API GetClassLongW(HWND hwnd, int nIndex)
372{
373 Win32BaseWindow *wnd;
374
375 dprintf(("USER32: GetClassLongW\n"));
376 wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
377 if(!wnd) {
378 dprintf(("GetClassLongW wnd == NULL"));
379 return(0);
380 }
381 return (wnd->getClass())->getClassLongW(nIndex);
382}
383//******************************************************************************
384//******************************************************************************
Note: See TracBrowser for help on using the repository browser.