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

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

* empty log message *

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