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

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

Very preliminary code for Open32 replacement

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