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