source: trunk/src/user32/window.cpp@ 1513

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

EB's unicode changes + seticon + mdi fixes

File size: 51.3 KB
Line 
1/* $Id: window.cpp,v 1.27 1999-10-30 09:19:47 sandervl Exp $ */
2/*
3 * Win32 window apis for OS/2
4 *
5 * Copyright 1999 Sander van Leeuwen
6 * Copyright 1999 Daniela Engert (dani@ngrt.de)
7 *
8 * Parts based on Wine Windows code (windows\win.c)
9 *
10 * Copyright 1993, 1994 Alexandre Julliard
11 *
12 * Project Odin Software License can be found in LICENSE.TXT
13 *
14 *
15 * TODO: Decide what to do about commands for OS/2 windows (non-Win32 apps)
16 *
17 */
18
19#include <os2win.h>
20#include <misc.h>
21#include <string.h>
22#include <stdio.h>
23#include <win32wbase.h>
24#include <win32wmdiclient.h>
25#include <win32wdesktop.h>
26#include "win32dlg.h"
27#include <oslibwin.h>
28#include <oslibgdi.h>
29#include "user32.h"
30#include "winicon.h"
31#include <win\winpos.h>
32
33//******************************************************************************
34//******************************************************************************
35HWND WIN32API CreateWindowExA(DWORD exStyle, LPCSTR className,
36 LPCSTR windowName, DWORD style, INT x,
37 INT y, INT width, INT height,
38 HWND parent, HMENU menu,
39 HINSTANCE instance, LPVOID data )
40{
41 Win32BaseWindow *window;
42 ATOM classAtom;
43 CREATESTRUCTA cs;
44 char tmpClass[20];
45
46 if(exStyle & WS_EX_MDICHILD)
47 return CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
48
49#if 1
50 /* Find the class atom */
51 if (!(classAtom = GlobalFindAtomA(className)))
52 {
53 if (!HIWORD(className))
54 dprintf(("CreateWindowEx32A: bad class name %04x\n",LOWORD(className)));
55 else
56 dprintf(("CreateWindowEx32A: bad class name '%s'\n", className));
57
58 SetLastError(ERROR_INVALID_PARAMETER);
59 return 0;
60 }
61
62 if (!HIWORD(className))
63 {
64 sprintf(tmpClass,"#%d", (int) className);
65 className = tmpClass;
66 }
67#else
68 /* Find the class atom */
69 if (!HIWORD(className) || !(classAtom = GlobalFindAtomA(className)))
70 {
71 if (!HIWORD(className))
72 {
73 sprintf(tmpClass,"#%d", (int) className);
74 classAtom = GlobalFindAtomA(tmpClass);
75 className = tmpClass;
76 }
77 if (!classAtom)
78 {
79 if (!HIWORD(className)) {
80 dprintf(("CreateWindowEx32A: bad class name %04x\n", LOWORD(className)));
81 }
82 else dprintf(("CreateWindowEx32A: bad class name '%s'\n", className ));
83
84 SetLastError(ERROR_INVALID_PARAMETER);
85 return 0;
86 }
87 }
88#endif
89 /* Create the window */
90 cs.lpCreateParams = data;
91 cs.hInstance = instance;
92 cs.hMenu = menu;
93 cs.hwndParent = parent;
94 cs.x = x;
95 cs.y = y;
96 cs.cx = width;
97 cs.cy = height;
98 cs.style = style;
99 cs.lpszName = windowName;
100 cs.lpszClass = className;
101 cs.dwExStyle = exStyle;
102 if(HIWORD(className)) {
103 dprintf(("CreateWindowExA: class %s parent %x (%d,%d) (%d,%d), %x %x", className, parent, x, y, width, height, style, exStyle));
104 }
105 else dprintf(("CreateWindowExA: class %d parent %x (%d,%d) (%d,%d), %x %x", className, parent, x, y, width, height, style, exStyle));
106
107 if(!strcmpi(className, MDICLIENTCLASSNAMEA)) {
108 window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, FALSE);
109 }
110 else
111 if(!strcmpi((char *) className, DIALOG_CLASS_NAMEA))
112 {
113 DLG_TEMPLATE dlgTemplate = {0};
114 dlgTemplate.style = cs.style;
115 dlgTemplate.exStyle = cs.dwExStyle;
116 dlgTemplate.x = cs.x;
117 dlgTemplate.y = cs.y;
118 dlgTemplate.cx = cs.cx;
119 dlgTemplate.cy = cs.cy;
120 dlgTemplate.className = cs.lpszClass;
121 dlgTemplate.caption = cs.lpszName;
122 window = (Win32BaseWindow *) new Win32Dialog(cs.hInstance,
123 (LPCSTR) &dlgTemplate,
124 cs.hwndParent,
125 NULL,
126 (LPARAM) data,
127 FALSE);
128 }
129 else {
130 window = new Win32BaseWindow( &cs, classAtom, FALSE );
131 }
132 if(window == NULL)
133 {
134 dprintf(("Win32BaseWindow creation failed!!"));
135 return 0;
136 }
137 if(GetLastError() != 0)
138 {
139 dprintf(("Win32BaseWindow error found!!"));
140 delete window;
141 return 0;
142 }
143 return window->getWindowHandle();
144}
145//******************************************************************************
146//******************************************************************************
147HWND WIN32API CreateWindowExW(DWORD exStyle, LPCWSTR className,
148 LPCWSTR windowName, DWORD style, INT x,
149 INT y, INT width, INT height,
150 HWND parent, HMENU menu,
151 HINSTANCE instance, LPVOID data )
152{
153 Win32BaseWindow *window;
154 ATOM classAtom;
155 CREATESTRUCTA cs;
156 char tmpClassA[20];
157 WCHAR tmpClassW[20];
158
159 if(exStyle & WS_EX_MDICHILD)
160 return CreateMDIWindowW(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
161
162 /* Find the class atom */
163 if (!HIWORD(className) || !(classAtom = GlobalFindAtomW(className)))
164 {
165 if (!HIWORD(className))
166 {
167 sprintf(tmpClassA,"#%d", (int) className);
168 AsciiToUnicode(tmpClassA, tmpClassW);
169 classAtom = GlobalFindAtomW(tmpClassW);
170 className = (LPCWSTR)tmpClassW;
171 }
172 if (!classAtom)
173 {
174 if (!HIWORD(className)) {
175 dprintf(("CreateWindowEx32W: bad class name %04x\n", LOWORD(className)));
176 }
177 else dprintf(("CreateWindowEx32W: bad class name "));
178
179 SetLastError(ERROR_INVALID_PARAMETER);
180 return 0;
181 }
182 }
183
184 /* Create the window */
185 cs.lpCreateParams = data;
186 cs.hInstance = instance;
187 cs.hMenu = menu;
188 cs.hwndParent = parent;
189 cs.x = x;
190 cs.y = y;
191 cs.cx = width;
192 cs.cy = height;
193 cs.style = style;
194 cs.lpszName = (LPSTR)windowName;
195 cs.lpszClass = (LPSTR)className;
196 cs.dwExStyle = exStyle;
197
198 if(!lstrcmpiW(className, (LPWSTR)MDICLIENTCLASSNAMEW)) {
199 window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, TRUE);
200 }
201 else
202 if(!lstrcmpiW(className, (LPWSTR)DIALOG_CLASS_NAMEW))
203 {
204 DLG_TEMPLATE dlgTemplate = {0};
205 dlgTemplate.style = cs.style;
206 dlgTemplate.exStyle = cs.dwExStyle;
207 dlgTemplate.x = cs.x;
208 dlgTemplate.y = cs.y;
209 dlgTemplate.cx = cs.cx;
210 dlgTemplate.cy = cs.cy;
211 dlgTemplate.className = cs.lpszClass;
212 dlgTemplate.caption = cs.lpszName;
213 window = (Win32BaseWindow *) new Win32Dialog(cs.hInstance,
214 (LPCSTR) &dlgTemplate,
215 cs.hwndParent,
216 NULL,
217 (LPARAM) data,
218 TRUE);
219 }
220 else {
221 window = new Win32BaseWindow( &cs, classAtom, TRUE );
222 }
223 if(window == NULL)
224 {
225 dprintf(("Win32BaseWindow creation failed!!"));
226 return 0;
227 }
228 if(GetLastError() != 0)
229 {
230 dprintf(("Win32BaseWindow error found!!"));
231 delete window;
232 return 0;
233 }
234 return window->getWindowHandle();
235}
236//******************************************************************************
237//******************************************************************************
238HWND WIN32API CreateMDIWindowA(LPCSTR lpszClassName, LPCSTR lpszWindowName,
239 DWORD dwStyle, int x, int y, int nWidth,
240 int nHeight, HWND hwndParent,
241 HINSTANCE hInstance, LPARAM lParam )
242{
243 HWND hwnd;
244 MDICREATESTRUCTA cs;
245 Win32BaseWindow *window;
246
247 window = Win32BaseWindow::GetWindowFromHandle(hwndParent);
248 if(!window) {
249 dprintf(("CreateMDIWindowA, window %x not found", hwndParent));
250 return 0;
251 }
252
253 dprintf(("USER32: CreateMDIWindowA\n"));
254 cs.szClass = lpszClassName;
255 cs.szTitle = lpszWindowName;
256 cs.hOwner = hInstance;
257 cs.x = x;
258 cs.y = y;
259 cs.cx = nHeight;
260 cs.cy = nWidth;
261 cs.style = dwStyle;
262 cs.lParam = lParam;
263
264 return window->SendMessageA(WM_MDICREATE, 0, (LPARAM)&cs);
265}
266//******************************************************************************
267//******************************************************************************
268HWND WIN32API CreateMDIWindowW(LPCWSTR lpszClassName, LPCWSTR lpszWindowName,
269 DWORD dwStyle, int x, int y, int nWidth,
270 int nHeight, HWND hwndParent,
271 HINSTANCE hInstance, LPARAM lParam )
272{
273 HWND hwnd;
274 MDICREATESTRUCTW cs;
275 Win32BaseWindow *window;
276
277 window = Win32BaseWindow::GetWindowFromHandle(hwndParent);
278 if(!window) {
279 dprintf(("CreateMDIWindowW, window %x not found", hwndParent));
280 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
281 return 0;
282 }
283
284 dprintf(("USER32: CreateMDIWindowW\n"));
285 cs.szClass = lpszClassName;
286 cs.szTitle = lpszWindowName;
287 cs.hOwner = hInstance;
288 cs.x = x;
289 cs.y = y;
290 cs.cx = nHeight;
291 cs.cy = nWidth;
292 cs.style = dwStyle;
293 cs.lParam = lParam;
294
295 return window->SendMessageW(WM_MDICREATE, 0, (LPARAM)&cs);
296}
297//******************************************************************************
298//******************************************************************************
299BOOL WIN32API DestroyWindow(HWND hwnd)
300{
301 Win32BaseWindow *window;
302
303 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
304 if(!window) {
305 dprintf(("DestroyWindow, window %x not found", hwnd));
306 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
307 return 0;
308 }
309 dprintf(("DestroyWindow %x", hwnd));
310 return window->DestroyWindow();
311}
312//******************************************************************************
313//******************************************************************************
314HWND WIN32API SetActiveWindow( HWND hwnd)
315{
316 Win32BaseWindow *window;
317
318 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
319 if(!window) {
320 dprintf(("SetActiveWindow, window %x not found", hwnd));
321 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
322 return 0;
323 }
324 dprintf(("SetActiveWindow %x", hwnd));
325 return window->SetActiveWindow();
326}
327//******************************************************************************
328//******************************************************************************
329HWND WIN32API GetParent( HWND hwnd)
330{
331 Win32BaseWindow *window;
332
333 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
334 if(!window) {
335 dprintf(("GetParent, window %x not found", hwnd));
336 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
337 return 0;
338 }
339// dprintf(("GetParent %x", hwnd));
340 return window->GetParent();
341}
342//******************************************************************************
343//******************************************************************************
344HWND WIN32API SetParent( HWND hwndChild, HWND hwndNewParent)
345{
346 Win32BaseWindow *window;
347
348 window = Win32BaseWindow::GetWindowFromHandle(hwndChild);
349 if(!window) {
350 dprintf(("SetParent, window %x not found", hwndChild));
351 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
352 return 0;
353 }
354 dprintf(("SetParent %x %x", hwndChild, hwndNewParent));
355 return window->SetParent(hwndNewParent);
356}
357//******************************************************************************
358//******************************************************************************
359BOOL WIN32API IsChild( HWND hwndParent, HWND hwnd)
360{
361 Win32BaseWindow *window;
362
363 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
364 if(!window) {
365 dprintf(("IsChild, window %x not found", hwnd));
366 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
367 return 0;
368 }
369 dprintf(("IsChild %x %x", hwndParent, hwnd));
370 return window->IsChild(hwndParent);
371}
372//******************************************************************************
373//******************************************************************************
374HWND WIN32API GetTopWindow( HWND hwnd)
375{
376 Win32BaseWindow *window;
377
378 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
379 if(!window) {
380 dprintf(("GetTopWindow, window %x not found", hwnd));
381 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
382 return 0;
383 }
384 return window->GetTopWindow();
385}
386//******************************************************************************
387//******************************************************************************
388BOOL WIN32API IsIconic( HWND hwnd)
389{
390 Win32BaseWindow *window;
391
392 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
393 if(!window) {
394 dprintf(("IsIconic, window %x not found", hwnd));
395 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
396 return 0;
397 }
398 dprintf(("IsIconic %x", hwnd));
399 return window->IsIconic();
400}
401//******************************************************************************
402//******************************************************************************
403HWND WIN32API GetWindow(HWND hwnd, UINT uCmd)
404{
405 Win32BaseWindow *window;
406 HWND rc;
407
408 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
409 if(!window) {
410 dprintf(("GetWindow, window %x not found", hwnd));
411 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
412 return 0;
413 }
414 rc = window->GetWindow(uCmd);
415 return rc;
416}
417//******************************************************************************
418//******************************************************************************
419BOOL WIN32API EnableWindow( HWND hwnd, BOOL fEnable)
420{
421 Win32BaseWindow *window;
422
423 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
424 if(!window) {
425 dprintf(("EnableWindow, window %x not found", hwnd));
426 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
427 return 0;
428 }
429 dprintf(("EnableWindow %x %d", hwnd, fEnable));
430 return window->EnableWindow(fEnable);
431}
432//******************************************************************************
433//******************************************************************************
434BOOL WIN32API BringWindowToTop(HWND hwnd)
435{
436 return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
437}
438//******************************************************************************
439//******************************************************************************
440HWND WIN32API GetActiveWindow()
441{
442 return Win32BaseWindow::GetActiveWindow();
443}
444//******************************************************************************
445//******************************************************************************
446BOOL WIN32API ShowWindow(HWND hwnd, int nCmdShow)
447{
448 Win32BaseWindow *window;
449
450 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
451 if(!window) {
452 dprintf(("ShowWindow, window %x not found", hwnd));
453 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
454 return 0;
455 }
456 dprintf(("ShowWindow %x", hwnd));
457 return window->ShowWindow(nCmdShow);
458}
459//******************************************************************************
460//******************************************************************************
461BOOL WIN32API SetWindowPos(HWND hwnd, HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
462{
463 Win32BaseWindow *window;
464
465 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
466 if(!window) {
467 dprintf(("SetWindowPos, window %x not found", hwnd));
468 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
469 return 0;
470 }
471 dprintf(("SetWindowPos %x %x x=%d y=%d cx=%d cy=%d %x", hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
472 return window->SetWindowPos(hwndInsertAfter, x, y, cx, cy, fuFlags);
473}
474//******************************************************************************
475//******************************************************************************
476BOOL WIN32API SetWindowPlacement(HWND hwnd, const WINDOWPLACEMENT *winpos)
477{
478 Win32BaseWindow *window;
479
480 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
481 if(!window) {
482 dprintf(("SetWindowPlacement, window %x not found", hwnd));
483 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
484 return 0;
485 }
486 return window->SetWindowPlacement((WINDOWPLACEMENT *)winpos);
487}
488//******************************************************************************
489//******************************************************************************
490BOOL WIN32API GetWindowPlacement(HWND hwnd, LPWINDOWPLACEMENT arg2)
491{
492 dprintf(("USER32: GetWindowPlacement\n"));
493 return O32_GetWindowPlacement(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd), arg2);
494}
495//******************************************************************************
496//******************************************************************************
497BOOL WIN32API IsWindow( HWND hwnd)
498{
499 Win32BaseWindow *window;
500
501 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
502 if(!window) {
503 dprintf(("IsWindow, window %x not found", hwnd));
504 return FALSE;
505 }
506 dprintf(("IsWindow %x", hwnd));
507 return window->IsWindow();
508}
509//******************************************************************************
510//******************************************************************************
511BOOL WIN32API IsWindowEnabled( HWND hwnd)
512{
513 Win32BaseWindow *window;
514
515 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
516 if(!window) {
517 dprintf(("IsWindowEnabled, window %x not found", hwnd));
518 return 0;
519 }
520 dprintf(("IsWindowEnabled %x", hwnd));
521 return window->IsWindowEnabled();
522}
523//******************************************************************************
524//******************************************************************************
525BOOL WIN32API IsWindowVisible( HWND hwnd)
526{
527 Win32BaseWindow *window;
528 BOOL rc;
529
530 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
531 if(!window) {
532 dprintf(("IsWindowVisible, window %x not found", hwnd));
533 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
534 return 0;
535 }
536 rc = window->IsWindowVisible();
537 dprintf(("IsWindowVisible %x returned %d", hwnd, rc));
538 return rc;
539}
540//******************************************************************************
541//******************************************************************************
542HWND WIN32API SetFocus (HWND hwnd)
543{
544 HWND lastFocus, lastFocus_W, hwnd_O;
545 BOOL activate;
546
547 hwnd_O = Win32BaseWindow::Win32ToOS2Handle (hwnd);
548 lastFocus = OSLibWinQueryFocus (OSLIB_HWND_DESKTOP);
549 activate = ((hwnd_O == lastFocus) || OSLibWinIsChild (lastFocus, hwnd_O));
550 lastFocus_W = Win32BaseWindow::OS2ToWin32Handle (lastFocus);
551
552 dprintf(("SetFocus %x (%x) -> %x (%x)\n", lastFocus_W, lastFocus, hwnd, hwnd_O));
553
554 return (OSLibWinSetFocus (OSLIB_HWND_DESKTOP, hwnd_O, activate)) ? lastFocus_W : 0;
555}
556//******************************************************************************
557//******************************************************************************
558HWND WIN32API GetFocus(void)
559{
560 HWND hwnd;
561
562 hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP);
563 dprintf(("USER32: GetFocus %x\n", hwnd));
564 hwnd = Win32BaseWindow::OS2ToWin32Handle(hwnd);
565 return hwnd;
566}
567//******************************************************************************
568//******************************************************************************
569/***********************************************************************
570 * GetInternalWindowPos (USER32.245)
571 */
572UINT WIN32API GetInternalWindowPos(HWND hwnd,
573 LPRECT rectWnd,
574 LPPOINT ptIcon )
575{
576 WINDOWPLACEMENT wndpl;
577
578 dprintf(("USER32: GetInternalWindowPos(%08xh,%08xh,%08xh)\n",
579 hwnd,
580 rectWnd,
581 ptIcon));
582
583 if (GetWindowPlacement( hwnd, &wndpl ))
584 {
585 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
586 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
587 return wndpl.showCmd;
588 }
589 return 0;
590}
591//******************************************************************************
592//******************************************************************************
593BOOL WIN32API IsZoomed(HWND hwnd)
594{
595 dprintf(("USER32: IsZoomed\n"));
596 return O32_IsZoomed(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd));
597}
598//******************************************************************************
599//******************************************************************************
600BOOL WIN32API LockWindowUpdate(HWND hwnd)
601{
602 dprintf(("USER32: LockWindowUpdate\n"));
603 return O32_LockWindowUpdate(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd));
604}
605//******************************************************************************
606//******************************************************************************
607BOOL WIN32API GetWindowRect( HWND hwnd, PRECT pRect)
608{
609 Win32BaseWindow *window;
610 BOOL rc;
611
612 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
613 if(!window) {
614 dprintf(("GetWindowRect, window %x not found", hwnd));
615 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
616 return 0;
617 }
618 rc = window->GetWindowRect(pRect);
619 dprintf(("GetWindowRect %x (%d,%d) (%d,%d)", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
620 return rc;
621}
622//******************************************************************************
623//******************************************************************************
624int WIN32API GetWindowTextLengthA( HWND hwnd)
625{
626 Win32BaseWindow *window;
627
628 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
629 if(!window) {
630 dprintf(("GetWindowTextLength, window %x not found", hwnd));
631 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
632 return 0;
633 }
634 dprintf(("GetWindowTextLength %x", hwnd));
635 return window->GetWindowTextLength();
636}
637//******************************************************************************
638//******************************************************************************
639int WIN32API GetWindowTextA( HWND hwnd, LPSTR lpsz, int cch)
640{
641 Win32BaseWindow *window;
642 int rc;
643
644 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
645 if(!window) {
646 dprintf(("GetWindowTextA, window %x not found", hwnd));
647 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
648 return 0;
649 }
650 rc = window->GetWindowTextA(lpsz, cch);
651 dprintf(("GetWindowTextA %x %s", hwnd, lpsz));
652 return rc;
653}
654//******************************************************************************
655//******************************************************************************
656int WIN32API GetWindowTextLengthW( HWND hwnd)
657{
658 dprintf(("USER32: GetWindowTextLengthW\n"));
659 return GetWindowTextLengthA(hwnd);
660}
661//******************************************************************************
662//******************************************************************************
663int WIN32API GetWindowTextW(HWND hwnd, LPWSTR lpsz, int cch)
664{
665 Win32BaseWindow *window;
666
667 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
668 if(!window) {
669 dprintf(("GetWindowTextW, window %x not found", hwnd));
670 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
671 return 0;
672 }
673 dprintf(("GetWindowTextW %x", hwnd));
674 return window->GetWindowTextW(lpsz, cch);
675}
676//******************************************************************************
677//******************************************************************************
678BOOL WIN32API SetWindowTextA(HWND hwnd, LPCSTR lpsz)
679{
680 Win32BaseWindow *window;
681
682 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
683 if(!window) {
684 dprintf(("SetWindowTextA, window %x not found", hwnd));
685 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
686 return 0;
687 }
688 dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
689 return window->SetWindowTextA((LPSTR)lpsz);
690}
691//******************************************************************************
692//******************************************************************************
693BOOL WIN32API SetWindowTextW( HWND hwnd, LPCWSTR lpsz)
694{
695 Win32BaseWindow *window;
696
697 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
698 if(!window) {
699 dprintf(("SetWindowTextA, window %x not found", hwnd));
700 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
701 return 0;
702 }
703 dprintf(("SetWindowTextW %x", hwnd));
704 return window->SetWindowTextW((LPWSTR)lpsz);
705}
706/*******************************************************************
707 * InternalGetWindowText (USER32.326)
708 */
709int WIN32API InternalGetWindowText(HWND hwnd,
710 LPWSTR lpString,
711 INT nMaxCount )
712{
713 dprintf(("USER32: InternalGetWindowText(%08xh,%08xh,%08xh) not properly implemented.\n",
714 hwnd,
715 lpString,
716 nMaxCount));
717
718 return GetWindowTextW(hwnd,lpString,nMaxCount);
719}
720//******************************************************************************
721//TODO: Correct?
722//******************************************************************************
723BOOL WIN32API SetForegroundWindow(HWND hwnd)
724{
725 dprintf((" SetForegroundWindow %x", hwnd));
726
727 return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER );
728}
729//******************************************************************************
730//******************************************************************************
731BOOL WIN32API GetClientRect( HWND hwnd, PRECT pRect)
732{
733 BOOL rc;
734 HWND hwndWin32 = hwnd;
735
736 Win32BaseWindow *window;
737
738 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
739 if(!window) {
740 dprintf(("GetClientRect, window %x not found", hwnd));
741 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
742 return 0;
743 }
744 *pRect = *window->getClientRect();
745 OffsetRect(pRect, -pRect->left, -pRect->top);
746 dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom));
747 return TRUE;
748}
749//******************************************************************************
750//******************************************************************************
751BOOL WIN32API AdjustWindowRect(PRECT rect, DWORD style, BOOL menu)
752{
753 return AdjustWindowRectEx(rect, style, menu, 0);
754}
755//******************************************************************************
756//******************************************************************************
757BOOL WIN32API AdjustWindowRectEx( PRECT rect, DWORD style, BOOL menu, DWORD exStyle)
758{
759 dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d)\n", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
760
761 /* Correct the window style */
762 if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
763 style |= WS_CAPTION;
764
765 style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD | WS_VSCROLL | WS_HSCROLL);
766 exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE |
767 WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
768 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
769
770 Win32BaseWindow::NC_AdjustRectOuter( rect, style, menu, exStyle );
771 Win32BaseWindow::NC_AdjustRectInner( rect, style, exStyle );
772
773 dprintf(("AdjustWindowRectEx returned (%d,%d)(%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom));
774 return TRUE;
775}
776//******************************************************************************
777/* Coordinate Space and Transformation Functions */
778//******************************************************************************
779int WIN32API MapWindowPoints(HWND hwndFrom, HWND hwndTo, LPPOINT lpPoints,
780 UINT cPoints)
781{
782 Win32BaseWindow *wndfrom, *wndto;
783 int retval = 0;
784 OSLIBPOINT point;
785
786 if(lpPoints == NULL || cPoints == 0) {
787 SetLastError(ERROR_INVALID_PARAMETER);
788 return 0;
789 }
790 if(hwndFrom)
791 {
792 wndfrom = Win32BaseWindow::GetWindowFromHandle(hwndFrom);
793 if(!wndfrom) {
794 dprintf(("MapWindowPoints, window %x not found", hwndFrom));
795 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
796 return 0;
797 }
798 }
799 else wndfrom = windowDesktop;
800
801 if(hwndTo)
802 {
803 wndto = Win32BaseWindow::GetWindowFromHandle(hwndTo);
804 if(!wndto) {
805 dprintf(("MapWindowPoints, window %x not found", hwndTo));
806 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
807 return 0;
808 }
809 }
810 else wndto = windowDesktop;
811
812 if(wndto == wndfrom)
813 return 0; //nothing to do
814
815 dprintf(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
816 point.x = lpPoints->x;
817 point.y = wndfrom->getWindowHeight() - lpPoints->y;
818
819 OSLibWinMapWindowPoints(wndfrom->getOS2WindowHandle(), wndto->getOS2WindowHandle(), &point, 1);
820 point.y = wndto->getWindowHeight() - point.y;
821
822 short int xinc = point.x - lpPoints->x;
823 short int yinc = point.y - lpPoints->y;
824
825 for(int i=0;i<cPoints;i++)
826 {
827 lpPoints[i].x += xinc;
828 lpPoints[i].y += yinc;
829 }
830 retval = ((LONG)yinc << 16) | xinc;
831 return retval;
832}
833//******************************************************************************
834//******************************************************************************
835BOOL WIN32API ScreenToClient (HWND hwnd, LPPOINT pt)
836{
837 Win32BaseWindow *wnd;
838 PRECT rcl;
839
840 dprintf(("ScreenToClient %x (%d,%d)\n", hwnd, pt->x, pt->y));
841
842 if (!hwnd) return (TRUE);
843 wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
844 if (!wnd) return (TRUE);
845
846 rcl = wnd->getClientRect();
847 pt->y = ScreenHeight - pt->y;
848 OSLibWinMapWindowPoints (OSLIB_HWND_DESKTOP, wnd->getOS2WindowHandle(), (OSLIBPOINT *)pt, 1);
849 pt->y = (rcl->bottom - rcl->top) - pt->y;
850 dprintf(("ScreenToClient %x returned (%d,%d)\n", hwnd, pt->x, pt->y));
851 return (TRUE);
852}
853//******************************************************************************
854//******************************************************************************
855HWND WIN32API GetDesktopWindow(void)
856{
857 dprintf(("USER32: GetDesktopWindow\n"));
858 return windowDesktop->getWindowHandle();
859}
860//******************************************************************************
861//******************************************************************************
862HWND WIN32API FindWindowA(LPCSTR lpszClass, LPCSTR lpszWindow)
863{
864 if(!lpszClass) {
865 SetLastError(ERROR_INVALID_PARAMETER);
866 return 0;
867 }
868 if(HIWORD(lpszClass)) {
869 dprintf(("USER32: FindWindow %s %s\n", lpszClass, lpszWindow));
870 }
871 else dprintf(("USER32: FindWindow %x %s\n", lpszClass, lpszWindow));
872
873 return Win32BaseWindow::FindWindowEx(OSLIB_HWND_DESKTOP, 0, (LPSTR)lpszClass, (LPSTR)lpszWindow);
874}
875//******************************************************************************
876//******************************************************************************
877HWND WIN32API FindWindowW( LPCWSTR lpClassName, LPCWSTR lpWindowName)
878{
879 char *astring1 = UnicodeToAsciiString((LPWSTR)lpClassName);
880 char *astring2 = UnicodeToAsciiString((LPWSTR)lpWindowName);
881 HWND rc;
882
883 rc = FindWindowA(astring1, astring2);
884 FreeAsciiString(astring1);
885 FreeAsciiString(astring2);
886 return rc;
887}
888//******************************************************************************
889//******************************************************************************
890HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow)
891{
892 if(!lpszClass) {
893 SetLastError(ERROR_INVALID_PARAMETER);
894 return 0;
895 }
896 if(HIWORD(lpszClass)) {
897 dprintf(("USER32: FindWindowExA (%x,%x) %s %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
898 }
899 else dprintf(("USER32: FindWindowExA (%x,%x)%x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
900
901 return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
902}
903/*****************************************************************************
904 * Name : HWND WIN32API FindWindowExW
905 * Purpose : The FindWindowEx function retrieves the handle of a window whose
906 * class name and window name match the specified strings. The
907 * function searches child windows, beginning with the one following
908 * the given child window.
909 * Parameters: HWND hwndParent handle of parent window
910 * HWND hwndChildAfter handle of a child window
911 * LPCTSTR lpszClass address of class name
912 * LPCTSTR lpszWindow address of window name
913 * Variables :
914 * Result : If the function succeeds, the return value is the handle of the
915 * window that has the specified class and window names.
916 * If the function fails, the return value is NULL. To get extended
917 * error information, call GetLastError.
918 * Remark :
919 * Status : UNTESTED STUB
920 *
921 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
922 *****************************************************************************/
923
924HWND WIN32API FindWindowExW(HWND hwndParent,
925 HWND hwndChildAfter,
926 LPCWSTR lpszClass,
927 LPCWSTR lpszWindow)
928{
929 if(!lpszClass) {
930 SetLastError(ERROR_INVALID_PARAMETER);
931 return 0;
932 }
933 dprintf(("USER32: FindWindowExW (%x,%x) %x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
934
935 return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
936}
937//******************************************************************************
938//******************************************************************************
939BOOL WIN32API FlashWindow(HWND hwnd, BOOL fFlash)
940{
941 dprintf(("FlashWindow %x %d\n", hwnd, fFlash));
942 return OSLibWinFlashWindow(Win32BaseWindow::Win32ToOS2Handle(hwnd), fFlash);
943}
944//******************************************************************************
945//******************************************************************************
946BOOL WIN32API MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
947 BOOL repaint )
948{
949 int flags = SWP_NOZORDER | SWP_NOACTIVATE;
950
951 if (!repaint) flags |= SWP_NOREDRAW;
952 dprintf(("MoveWindow: %04x %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ));
953
954 return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
955}
956//******************************************************************************
957//******************************************************************************
958BOOL WIN32API ClientToScreen (HWND hwnd, PPOINT pt)
959{
960 Win32BaseWindow *wnd;
961 PRECT rcl;
962
963 dprintf(("ClientToScreen (%d,%d)\n", pt->x, pt->y));
964 if (!hwnd) {
965 SetLastError(ERROR_INVALID_PARAMETER);
966 return (FALSE);
967 }
968 wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
969 if (!wnd) {
970 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
971 return (FALSE);
972 }
973
974 rcl = wnd->getClientRect();
975 pt->y = (rcl->bottom - rcl->top) - pt->y;
976 OSLibWinMapWindowPoints (wnd->getOS2WindowHandle(), OSLIB_HWND_DESKTOP, (OSLIBPOINT *)pt, 1);
977 pt->y = ScreenHeight - pt->y;
978 dprintf(("ClientToScreen returned (%d,%d)\n", pt->x, pt->y));
979 return (TRUE);
980}
981//******************************************************************************
982//******************************************************************************
983HDWP WIN32API BeginDeferWindowPos(int count)
984{
985 HDWP handle;
986 DWP *pDWP;
987
988 dprintf(("USER32: BeginDeferWindowPos\n"));
989 if (count <= 0)
990 {
991 SetLastError(ERROR_INVALID_PARAMETER);
992 return 0;
993 }
994 handle = (HDWP)HeapAlloc(GetProcessHeap(), 0, sizeof(DWP) + (count-1)*sizeof(WINDOWPOS) );
995 if (!handle)
996 return 0;
997
998 pDWP = (DWP *) handle;
999 pDWP->actualCount = 0;
1000 pDWP->suggestedCount = count;
1001 pDWP->valid = TRUE;
1002 pDWP->wMagic = DWP_MAGIC;
1003 pDWP->hwndParent = 0;
1004 return handle;
1005}
1006/***********************************************************************
1007 * DeferWindowPos (USER32.128)
1008 */
1009HDWP WIN32API DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
1010 INT x, INT y, INT cx, INT cy,
1011 UINT flags )
1012{
1013 DWP *pDWP;
1014 int i;
1015 HDWP newhdwp = hdwp,retvalue;
1016 Win32BaseWindow *window;
1017
1018 pDWP = (DWP *)hdwp;
1019 if (!pDWP) {
1020 SetLastError(ERROR_INVALID_PARAMETER);
1021 return 0;
1022 }
1023
1024 if (hwnd == GetDesktopWindow())
1025 return 0;
1026
1027 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1028 if(!window) {
1029 dprintf(("DeferWindowPos, window %x not found", hwnd));
1030 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1031 HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
1032 return 0;
1033 }
1034
1035
1036/* Numega Bounds Checker Demo dislikes the following code.
1037 In fact, I've not been able to find any "same parent" requirement in any docu
1038 [AM 980509]
1039 */
1040#if 0
1041 /* All the windows of a DeferWindowPos() must have the same parent */
1042 parent = pWnd->parent->hwndSelf;
1043 if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
1044 else if (parent != pDWP->hwndParent)
1045 {
1046 USER_HEAP_FREE( hdwp );
1047 retvalue = 0;
1048 goto END;
1049 }
1050#endif
1051
1052 for (i = 0; i < pDWP->actualCount; i++)
1053 {
1054 if (pDWP->winPos[i].hwnd == hwnd)
1055 {
1056 /* Merge with the other changes */
1057 if (!(flags & SWP_NOZORDER))
1058 {
1059 pDWP->winPos[i].hwndInsertAfter = hwndAfter;
1060 }
1061 if (!(flags & SWP_NOMOVE))
1062 {
1063 pDWP->winPos[i].x = x;
1064 pDWP->winPos[i].y = y;
1065 }
1066 if (!(flags & SWP_NOSIZE))
1067 {
1068 pDWP->winPos[i].cx = cx;
1069 pDWP->winPos[i].cy = cy;
1070 }
1071 pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
1072 SWP_NOZORDER | SWP_NOREDRAW |
1073 SWP_NOACTIVATE | SWP_NOCOPYBITS|
1074 SWP_NOOWNERZORDER);
1075 pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
1076 SWP_FRAMECHANGED);
1077 retvalue = hdwp;
1078 goto END;
1079 }
1080 }
1081 if (pDWP->actualCount >= pDWP->suggestedCount)
1082 {
1083 newhdwp = (HDWP)HeapReAlloc(GetProcessHeap(), 0, (LPVOID)hdwp,
1084 sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS));
1085 if (!newhdwp)
1086 {
1087 retvalue = 0;
1088 goto END;
1089 }
1090 pDWP = (DWP *) newhdwp;
1091 pDWP->suggestedCount++;
1092 }
1093 pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
1094 pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
1095 pDWP->winPos[pDWP->actualCount].x = x;
1096 pDWP->winPos[pDWP->actualCount].y = y;
1097 pDWP->winPos[pDWP->actualCount].cx = cx;
1098 pDWP->winPos[pDWP->actualCount].cy = cy;
1099 pDWP->winPos[pDWP->actualCount].flags = flags;
1100 pDWP->actualCount++;
1101 retvalue = newhdwp;
1102END:
1103 return retvalue;
1104}
1105//******************************************************************************
1106//******************************************************************************
1107BOOL WIN32API EndDeferWindowPos( HDWP hdwp)
1108{
1109 DWP *pDWP;
1110 WINDOWPOS *winpos;
1111 BOOL res = TRUE;
1112 int i;
1113
1114 pDWP = (DWP *) hdwp;
1115 if (!pDWP) {
1116 dprintf(("**EndDeferWindowPos invalid parameter\n"));
1117 SetLastError(ERROR_INVALID_PARAMETER);
1118 return FALSE;
1119 }
1120 dprintf(("**EndDeferWindowPos for %d windows", pDWP->actualCount));
1121 for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
1122 {
1123 dprintf(("**EndDeferWindowPos %x (%d,%d) (%d,%d) %x", winpos->hwnd, winpos->x, winpos->y, winpos->x, winpos->cy, winpos->flags));
1124 if (!(res = SetWindowPos(winpos->hwnd, winpos->hwndInsertAfter,
1125 winpos->x, winpos->y, winpos->cx,
1126 winpos->cy, winpos->flags )))
1127 break;
1128 }
1129 dprintf(("**EndDeferWindowPos DONE"));
1130 HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
1131 return res;
1132}
1133//******************************************************************************
1134//******************************************************************************
1135HWND WIN32API ChildWindowFromPoint( HWND hwnd, POINT pt)
1136{
1137 dprintf(("USER32: ChildWindowFromPoint\n"));
1138// return O32_ChildWindowFromPoint(arg1, arg2);
1139 return ChildWindowFromPointEx(hwnd, pt, 0);
1140}
1141//******************************************************************************
1142//******************************************************************************
1143/*****************************************************************************
1144 * Name : HWND WIN32API ChildWindowFromPointEx
1145 * Purpose : The GetWindowRect function retrieves the dimensions of the
1146 * bounding rectangle of the specified window. The dimensions are
1147 * given in screen coordinates that are relative to the upper-left
1148 * corner of the screen.
1149 * Parameters:
1150 * Variables :
1151 * Result : If the function succeeds, the return value is the window handle.
1152 * If the function fails, the return value is zero
1153 * Remark :
1154 * Status : FULLY IMPLEMENTED AND TESTED
1155 *
1156 * Author : Rene Pronk [Sun, 1999/08/08 23:30]
1157 *****************************************************************************/
1158
1159HWND WIN32API ChildWindowFromPointEx (HWND hwndParent, POINT pt, UINT uFlags)
1160{
1161 RECT rect;
1162 HWND hWnd;
1163 POINT absolutePt;
1164
1165 dprintf(("ChildWindowFromPointEx(%08xh,%08xh,%08xh).\n",
1166 hwndParent, pt, uFlags));
1167
1168 if (GetWindowRect (hwndParent, &rect) == 0) {
1169 // oops, invalid handle
1170 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1171 return NULL;
1172 }
1173
1174 // absolutePt has its top in the upper-left corner of the screen
1175 absolutePt = pt;
1176 ClientToScreen (hwndParent, &absolutePt);
1177
1178 // make rect the size of the parent window
1179 GetWindowRect (hwndParent, &rect);
1180 rect.right = rect.right - rect.left;
1181 rect.bottom = rect.bottom - rect.top;
1182 rect.left = 0;
1183 rect.top = 0;
1184
1185 if (PtInRect (&rect, pt) == 0) {
1186 // point is outside window
1187 return NULL;
1188 }
1189
1190 // get first child
1191 hWnd = GetWindow (hwndParent, GW_CHILD);
1192
1193 while (hWnd != NULL) {
1194
1195 // do I need to skip this window?
1196 if (((uFlags & CWP_SKIPINVISIBLE) &&
1197 (IsWindowVisible (hWnd) == FALSE)) ||
1198 ((uFlags & CWP_SKIPDISABLED) &&
1199 (IsWindowEnabled (hWnd) == FALSE)) ||
1200 ((uFlags & CWP_SKIPTRANSPARENT) &&
1201 (GetWindowLongA (hWnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
1202
1203 {
1204 hWnd = GetWindow (hWnd, GW_HWNDNEXT);
1205 continue;
1206 }
1207
1208 // is the point in this window's rect?
1209 GetWindowRect (hWnd, &rect);
1210 if (PtInRect (&rect, absolutePt) == FALSE) {
1211 hWnd = GetWindow (hWnd, GW_HWNDNEXT);
1212 continue;
1213 }
1214
1215 dprintf(("ChildWindowFromPointEx returned %x", hWnd));
1216 // found it!
1217 return hWnd;
1218 }
1219
1220 // the point is in the parentwindow but the parentwindow has no child
1221 // at this coordinate
1222 dprintf(("ChildWindowFromPointEx returned parent %x", hwndParent));
1223 return hwndParent;
1224}
1225//******************************************************************************
1226//******************************************************************************
1227BOOL WIN32API CloseWindow(HWND hwnd)
1228{
1229 Win32BaseWindow *window;
1230
1231 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1232 if(!window) {
1233 dprintf(("CloseWindow, window %x not found", hwnd));
1234 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1235 return 0;
1236 }
1237 dprintf(("CloseWindow %x\n", hwnd));
1238 return window->CloseWindow();
1239}
1240//******************************************************************************
1241//TODO: Does this return handles of hidden or disabled windows?
1242//******************************************************************************
1243HWND WIN32API WindowFromPoint( POINT point)
1244{
1245 HWND hwnd;
1246
1247 dprintf(("WindowFromPoint (%d,%d)\n", point.x, point.y));
1248 hwnd = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&point);
1249 if(hwnd) {
1250 return Win32BaseWindow::OS2ToWin32Handle(hwnd);
1251 }
1252 return 0;
1253}
1254//******************************************************************************
1255//******************************************************************************
1256BOOL WIN32API IsWindowUnicode(HWND hwnd)
1257{
1258 Win32BaseWindow *window;
1259
1260 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1261 if(!window) {
1262 dprintf(("IsWindowUnicode, window %x not found", hwnd));
1263 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1264 return 0;
1265 }
1266 return window->IsUnicode();
1267}
1268/*****************************************************************************
1269 * Name : WORD WIN32API CascadeWindows
1270 * Purpose : The CascadeWindows function cascades the specified windows or
1271 * the child windows of the specified parent window.
1272 * Parameters: HWND hwndParent handle of parent window
1273 * UINT wHow types of windows not to arrange
1274 * CONST RECT * lpRect rectangle to arrange windows in
1275 * UINT cKids number of windows to arrange
1276 * const HWND FAR * lpKids array of window handles
1277 * Variables :
1278 * Result : If the function succeeds, the return value is the number of windows arranged.
1279 * If the function fails, the return value is zero.
1280 * Remark :
1281 * Status : UNTESTED STUB
1282 *
1283 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
1284 *****************************************************************************/
1285
1286WORD WIN32API CascadeWindows(HWND hwndParent,
1287 UINT wHow,
1288 CONST LPRECT lpRect,
1289 UINT cKids,
1290 const HWND *lpKids)
1291{
1292 dprintf(("USER32:CascadeWindows(%08xh,%u,%08xh,%u,%08x) not implemented.\n",
1293 hwndParent,
1294 wHow,
1295 lpRect,
1296 cKids,
1297 lpKids));
1298
1299 return (0);
1300}
1301/*****************************************************************************
1302 * Name : BOOL WIN32API SwitchToThisWindow
1303 * Purpose : Unknown
1304 * Parameters: Unknown
1305 * Variables :
1306 * Result :
1307 * Remark :
1308 * Status : UNTESTED UNKNOWN STUB
1309 *
1310 * Author : Patrick Haller [Wed, 1998/06/16 11:55]
1311 *****************************************************************************/
1312
1313BOOL WIN32API SwitchToThisWindow(HWND hwnd,
1314 BOOL x2)
1315{
1316 dprintf(("USER32: SwitchToThisWindow(%08xh,%08xh) not implemented.\n",
1317 hwnd,
1318 x2));
1319
1320 return (FALSE); /* default */
1321}
1322//******************************************************************************
1323//******************************************************************************
1324BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
1325{
1326 Win32BaseWindow *window;
1327 BOOL rc;
1328 ULONG henum;
1329 HWND hwndNext;
1330 ULONG tid;
1331 ULONG pid, curpid;
1332
1333 dprintf(("EnumThreadWindows\n"));
1334
1335 curpid = GetCurrentProcessId();
1336
1337 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
1338 while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
1339 {
1340 OSLibWinQueryWindowProcess(hwndNext, &pid, &tid);
1341 if(!(curpid == pid && dwThreadId == tid))
1342 continue;
1343
1344 window = Win32BaseWindow::GetWindowFromOS2Handle(hwndNext);
1345 if(window == NULL) {
1346 window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndNext);
1347 if(!window) {
1348 //OS/2 window or non-frame window, so skip it
1349 continue;
1350 }
1351 }
1352 if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE)
1353 break;
1354 }
1355 OSLibWinEndEnumWindows (henum);
1356 return TRUE;
1357}
1358//******************************************************************************
1359//******************************************************************************
1360BOOL WIN32API EnumChildWindows(HWND hwnd, WNDENUMPROC lpfn, LPARAM lParam)
1361{
1362 Win32BaseWindow *window;
1363 BOOL rc = TRUE;
1364 ULONG henum;
1365 HWND hwndNext;
1366
1367 if(lpfn == NULL) {
1368 dprintf(("EnumChildWindows invalid parameter %x %x\n", hwnd, lParam));
1369 SetLastError(ERROR_INVALID_PARAMETER);
1370 return FALSE;
1371 }
1372 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1373 if(!window) {
1374 dprintf(("EnumChildWindows, window %x not found", hwnd));
1375 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1376 return FALSE;
1377 }
1378 return window->EnumChildWindows(lpfn, lParam);
1379}
1380//******************************************************************************
1381//******************************************************************************
1382BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
1383{
1384 Win32BaseWindow *window;
1385 BOOL rc;
1386 ULONG henum;
1387 HWND hwndNext, hwndParent = OSLIB_HWND_DESKTOP;
1388
1389 dprintf(("EnumThreadWindows\n"));
1390
1391 do {
1392 henum = OSLibWinBeginEnumWindows(hwndParent);
1393 while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
1394 {
1395 window = Win32BaseWindow::GetWindowFromOS2Handle(hwndNext);
1396 if(window == NULL) {
1397 window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndNext);
1398 if(!window) {
1399 //OS/2 window or non-frame window, so skip it
1400 continue;
1401 }
1402 }
1403 if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE) {
1404 goto Abort;
1405 }
1406 }
1407 if(hwndParent == OSLIB_HWND_OBJECT)
1408 break;
1409 hwndParent = OSLIB_HWND_OBJECT;
1410 OSLibWinEndEnumWindows(henum);
1411 }
1412 while(TRUE);
1413
1414Abort:
1415 OSLibWinEndEnumWindows(henum);
1416 return TRUE;
1417}
1418//******************************************************************************
1419//******************************************************************************
1420UINT WIN32API ArrangeIconicWindows( HWND arg1)
1421{
1422#ifdef DEBUG
1423 WriteLog("USER32: ArrangeIconicWindows\n");
1424#endif
1425 return O32_ArrangeIconicWindows(arg1);
1426}
1427//******************************************************************************
1428//restores iconized window to previous size/position
1429//******************************************************************************
1430BOOL WIN32API OpenIcon(HWND hwnd)
1431{
1432#ifdef DEBUG
1433 WriteLog("USER32: OpenIcon\n");
1434#endif
1435 if(!IsIconic(hwnd))
1436 return FALSE;
1437 ShowWindow(hwnd, SW_SHOWNORMAL);
1438 return TRUE;
1439}
1440//******************************************************************************
1441//******************************************************************************
1442BOOL WIN32API ShowOwnedPopups( HWND arg1, BOOL arg2)
1443{
1444 dprintf(("USER32: ShowOwnedPopups\n"));
1445 return O32_ShowOwnedPopups(arg1, arg2);
1446}
1447//******************************************************************************
1448//******************************************************************************
1449
Note: See TracBrowser for help on using the repository browser.