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