source: trunk/src/user32/new/windowclass.cpp@ 314

Last change on this file since 314 was 314, checked in by sandervl, 26 years ago

Misc window class changes/bugfixes

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