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