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

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

Implemented SetWindowPlacement + bugfixes

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