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

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

Dialog fixes + ported Wine apis

File size: 50.0 KB
Line 
1/* $Id: window.cpp,v 1.17 1999-10-17 15:46:10 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 arg1, const WINDOWPLACEMENT * arg2)
474{
475 dprintf(("USER32: SetWindowPlacement\n"));
476 return O32_SetWindowPlacement(arg1, arg2);
477}
478//******************************************************************************
479//******************************************************************************
480BOOL WIN32API GetWindowPlacement( HWND arg1, LPWINDOWPLACEMENT arg2)
481{
482#ifdef DEBUG
483 WriteLog("USER32: GetWindowPlacement\n");
484#endif
485 return O32_GetWindowPlacement(arg1, arg2);
486}
487//******************************************************************************
488//******************************************************************************
489BOOL WIN32API IsWindow( HWND hwnd)
490{
491 Win32BaseWindow *window;
492
493 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
494 if(!window) {
495 dprintf(("IsWindow, window %x not found", hwnd));
496 return FALSE;
497 }
498 dprintf(("IsWindow %x", hwnd));
499 return window->IsWindow();
500}
501//******************************************************************************
502//******************************************************************************
503BOOL WIN32API IsWindowEnabled( HWND hwnd)
504{
505 Win32BaseWindow *window;
506
507 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
508 if(!window) {
509 dprintf(("IsWindowEnabled, window %x not found", hwnd));
510 return 0;
511 }
512 dprintf(("IsWindowEnabled %x", hwnd));
513 return window->IsWindowEnabled();
514}
515//******************************************************************************
516//******************************************************************************
517BOOL WIN32API IsWindowVisible( HWND hwnd)
518{
519 Win32BaseWindow *window;
520
521 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
522 if(!window) {
523 dprintf(("IsWindowVisible, window %x not found", hwnd));
524 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
525 return 0;
526 }
527 dprintf(("IsWindowVisible %x", hwnd));
528 return window->IsWindowVisible();
529}
530//******************************************************************************
531//******************************************************************************
532HWND WIN32API SetFocus (HWND hwnd)
533{
534 HWND lastFocus, lastFocus_W, hwnd_O;
535 BOOL activate;
536
537 hwnd_O = Win32BaseWindow::Win32ToOS2Handle (hwnd);
538 lastFocus = OSLibWinQueryFocus (OSLIB_HWND_DESKTOP);
539 activate = ((hwnd_O == lastFocus) || OSLibWinIsChild (lastFocus, hwnd_O));
540 lastFocus_W = Win32BaseWindow::OS2ToWin32Handle (lastFocus);
541
542 dprintf(("SetFocus %x (%x) -> %x (%x)\n", lastFocus_W, lastFocus, hwnd, hwnd_O));
543
544 return (OSLibWinSetFocus (OSLIB_HWND_DESKTOP, hwnd_O, activate)) ? lastFocus_W : 0;
545}
546//******************************************************************************
547//******************************************************************************
548HWND WIN32API GetFocus(void)
549{
550 HWND hwnd;
551
552 hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP);
553 dprintf(("USER32: GetFocus %x\n", hwnd));
554 hwnd = Win32BaseWindow::OS2ToWin32Handle(hwnd);
555 return hwnd;
556}
557//******************************************************************************
558//******************************************************************************
559/***********************************************************************
560 * GetInternalWindowPos (USER32.245)
561 */
562UINT WIN32API GetInternalWindowPos(HWND hwnd,
563 LPRECT rectWnd,
564 LPPOINT ptIcon )
565{
566 WINDOWPLACEMENT wndpl;
567
568 dprintf(("USER32: GetInternalWindowPos(%08xh,%08xh,%08xh)\n",
569 hwnd,
570 rectWnd,
571 ptIcon));
572
573 if (GetWindowPlacement( hwnd, &wndpl ))
574 {
575 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
576 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
577 return wndpl.showCmd;
578 }
579 return 0;
580}
581//******************************************************************************
582//******************************************************************************
583BOOL WIN32API IsZoomed( HWND arg1)
584{
585#ifdef DEBUG
586 WriteLog("USER32: IsZoomed\n");
587#endif
588 return O32_IsZoomed(arg1);
589}
590//******************************************************************************
591//******************************************************************************
592BOOL WIN32API LockWindowUpdate( HWND arg1)
593{
594#ifdef DEBUG
595 WriteLog("USER32: LockWindowUpdate\n");
596#endif
597 return O32_LockWindowUpdate(arg1);
598}
599//******************************************************************************
600//******************************************************************************
601
602#if 0
603BOOL WIN32API RedrawWindow( HWND arg1, const RECT * arg2, HRGN arg3, UINT arg4)
604{
605 BOOL rc;
606
607 rc = O32_RedrawWindow(arg1, arg2, arg3, arg4);
608#ifdef DEBUG
609 WriteLog("USER32: RedrawWindow %X , %X, %X, %X returned %d\n", arg1, arg2, arg3, arg4, rc);
610#endif
611 InvalidateRect(arg1, arg2, TRUE);
612 UpdateWindow(arg1);
613 SendMessageA(arg1, WM_PAINT, 0, 0);
614 return(rc);
615}
616#endif
617//******************************************************************************
618//******************************************************************************
619BOOL WIN32API GetWindowRect( HWND hwnd, PRECT pRect)
620{
621 Win32BaseWindow *window;
622 BOOL rc;
623
624 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
625 if(!window) {
626 dprintf(("GetWindowRect, window %x not found", hwnd));
627 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
628 return 0;
629 }
630 rc = window->GetWindowRect(pRect);
631 dprintf(("GetWindowRect %x (%d,%d) (%d,%d)", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
632 return rc;
633}
634//******************************************************************************
635//******************************************************************************
636int WIN32API GetWindowTextLengthA( HWND hwnd)
637{
638 Win32BaseWindow *window;
639
640 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
641 if(!window) {
642 dprintf(("GetWindowTextLength, window %x not found", hwnd));
643 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
644 return 0;
645 }
646 dprintf(("GetWindowTextLength %x", hwnd));
647 return window->GetWindowTextLength();
648}
649//******************************************************************************
650//******************************************************************************
651int WIN32API GetWindowTextA( HWND hwnd, LPSTR lpsz, int cch)
652{
653 Win32BaseWindow *window;
654 int rc;
655
656 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
657 if(!window) {
658 dprintf(("GetWindowTextA, window %x not found", hwnd));
659 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
660 return 0;
661 }
662 rc = window->GetWindowTextA(lpsz, cch);
663 dprintf(("GetWindowTextA %x %s", hwnd, lpsz));
664 return rc;
665}
666//******************************************************************************
667//******************************************************************************
668int WIN32API GetWindowTextLengthW( HWND hwnd)
669{
670 dprintf(("USER32: GetWindowTextLengthW\n"));
671 return GetWindowTextLengthA(hwnd);
672}
673//******************************************************************************
674//******************************************************************************
675int WIN32API GetWindowTextW(HWND hwnd, LPWSTR lpsz, int cch)
676{
677 Win32BaseWindow *window;
678
679 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
680 if(!window) {
681 dprintf(("GetWindowTextW, window %x not found", hwnd));
682 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
683 return 0;
684 }
685 dprintf(("GetWindowTextW %x", hwnd));
686 return window->GetWindowTextW(lpsz, cch);
687}
688//******************************************************************************
689//******************************************************************************
690BOOL WIN32API SetWindowTextA(HWND hwnd, LPCSTR lpsz)
691{
692 Win32BaseWindow *window;
693
694 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
695 if(!window) {
696 dprintf(("SetWindowTextA, window %x not found", hwnd));
697 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
698 return 0;
699 }
700 dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
701 return window->SetWindowTextA((LPSTR)lpsz);
702}
703//******************************************************************************
704//******************************************************************************
705BOOL WIN32API SetWindowTextW( HWND hwnd, LPCWSTR lpsz)
706{
707 Win32BaseWindow *window;
708
709 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
710 if(!window) {
711 dprintf(("SetWindowTextA, window %x not found", hwnd));
712 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
713 return 0;
714 }
715 dprintf(("SetWindowTextW %x", hwnd));
716 return window->SetWindowTextW((LPWSTR)lpsz);
717}
718/*******************************************************************
719 * InternalGetWindowText (USER32.326)
720 */
721int WIN32API InternalGetWindowText(HWND hwnd,
722 LPWSTR lpString,
723 INT nMaxCount )
724{
725 dprintf(("USER32: InternalGetWindowText(%08xh,%08xh,%08xh) not properly implemented.\n",
726 hwnd,
727 lpString,
728 nMaxCount));
729
730 return GetWindowTextW(hwnd,lpString,nMaxCount);
731}
732//******************************************************************************
733//TODO: Correct?
734//******************************************************************************
735BOOL WIN32API SetForegroundWindow(HWND hwnd)
736{
737 dprintf((" SetForegroundWindow %x", hwnd));
738
739 return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER );
740}
741//******************************************************************************
742//******************************************************************************
743BOOL WIN32API GetClientRect( HWND hwnd, PRECT pRect)
744{
745 BOOL rc;
746 HWND hwndWin32 = hwnd;
747
748#if 1
749 Win32BaseWindow *window;
750
751 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
752 if(!window) {
753 dprintf(("GetClientRect, window %x not found", hwnd));
754 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
755 return 0;
756 }
757 *pRect = *window->getClientRect();
758 OffsetRect(pRect, -pRect->left, -pRect->top);
759 dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom));
760 return TRUE;
761#else
762 hwnd = Win32BaseWindow::Win32ToOS2Handle(hwnd);
763 rc = OSLibWinQueryWindowRect(hwnd, pRect);
764 dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom));
765 return rc;
766#endif
767}
768//******************************************************************************
769//******************************************************************************
770BOOL WIN32API AdjustWindowRect(PRECT rect, DWORD style, BOOL menu)
771{
772 return AdjustWindowRectEx(rect, style, menu, 0);
773}
774//******************************************************************************
775//******************************************************************************
776BOOL WIN32API AdjustWindowRectEx( PRECT rect, DWORD style, BOOL menu, DWORD exStyle)
777{
778 dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d)\n", style, exStyle, menu, rect->right, rect->top, rect->left, rect->bottom));
779
780#if 0
781 O32_AdjustWindowRectEx(rect, style, menu, exStyle);
782#else
783 /* Correct the window style */
784 if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
785 style |= WS_CAPTION;
786
787 style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD | WS_VSCROLL | WS_HSCROLL);
788 exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE |
789 WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
790 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
791
792 Win32BaseWindow::NC_AdjustRectOuter( rect, style, menu, exStyle );
793 Win32BaseWindow::NC_AdjustRectInner( rect, style, exStyle );
794#endif
795
796 dprintf(("AdjustWindowRectEx returned (%d,%d)(%d,%d)\n", rect->right, rect->top, rect->left, rect->bottom));
797 return TRUE;
798}
799//******************************************************************************
800//******************************************************************************
801HWND WIN32API GetDesktopWindow(void)
802{
803 dprintf(("USER32: GetDesktopWindow\n"));
804 return windowDesktop->getWindowHandle();
805}
806//******************************************************************************
807//******************************************************************************
808HWND WIN32API FindWindowA(LPCSTR lpszClass, LPCSTR lpszWindow)
809{
810 if(!lpszClass) {
811 SetLastError(ERROR_INVALID_PARAMETER);
812 return 0;
813 }
814 if(HIWORD(lpszClass)) {
815 dprintf(("USER32: FindWindow %s %s\n", lpszClass, lpszWindow));
816 }
817 else dprintf(("USER32: FindWindow %x %s\n", lpszClass, lpszWindow));
818
819 return Win32BaseWindow::FindWindowEx(OSLIB_HWND_DESKTOP, 0, (LPSTR)lpszClass, (LPSTR)lpszWindow);
820}
821//******************************************************************************
822//******************************************************************************
823HWND WIN32API FindWindowW( LPCWSTR lpClassName, LPCWSTR lpWindowName)
824{
825 char *astring1 = UnicodeToAsciiString((LPWSTR)lpClassName);
826 char *astring2 = UnicodeToAsciiString((LPWSTR)lpWindowName);
827 HWND rc;
828
829 rc = FindWindowA(astring1, astring2);
830 FreeAsciiString(astring1);
831 FreeAsciiString(astring2);
832 return rc;
833}
834//******************************************************************************
835//******************************************************************************
836HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow)
837{
838 if(!lpszClass) {
839 SetLastError(ERROR_INVALID_PARAMETER);
840 return 0;
841 }
842 if(HIWORD(lpszClass)) {
843 dprintf(("USER32: FindWindowExA (%x,%x) %s %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
844 }
845 else dprintf(("USER32: FindWindowExA (%x,%x)%x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
846
847 return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
848}
849/*****************************************************************************
850 * Name : HWND WIN32API FindWindowExW
851 * Purpose : The FindWindowEx function retrieves the handle of a window whose
852 * class name and window name match the specified strings. The
853 * function searches child windows, beginning with the one following
854 * the given child window.
855 * Parameters: HWND hwndParent handle of parent window
856 * HWND hwndChildAfter handle of a child window
857 * LPCTSTR lpszClass address of class name
858 * LPCTSTR lpszWindow address of window name
859 * Variables :
860 * Result : If the function succeeds, the return value is the handle of the
861 * window that has the specified class and window names.
862 * If the function fails, the return value is NULL. To get extended
863 * error information, call GetLastError.
864 * Remark :
865 * Status : UNTESTED STUB
866 *
867 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
868 *****************************************************************************/
869
870HWND WIN32API FindWindowExW(HWND hwndParent,
871 HWND hwndChildAfter,
872 LPCWSTR lpszClass,
873 LPCWSTR lpszWindow)
874{
875 if(!lpszClass) {
876 SetLastError(ERROR_INVALID_PARAMETER);
877 return 0;
878 }
879 dprintf(("USER32: FindWindowExW (%x,%x) %x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
880
881 return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
882}
883//******************************************************************************
884//******************************************************************************
885BOOL WIN32API FlashWindow(HWND hwnd, BOOL fFlash)
886{
887 dprintf(("FlashWindow %x %d\n", hwnd, fFlash));
888 return OSLibWinFlashWindow(Win32BaseWindow::Win32ToOS2Handle(hwnd), fFlash);
889}
890//******************************************************************************
891//******************************************************************************
892BOOL WIN32API MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
893 BOOL repaint )
894{
895 int flags = SWP_NOZORDER | SWP_NOACTIVATE;
896
897 if (!repaint) flags |= SWP_NOREDRAW;
898 dprintf(("MoveWindow: %04x %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ));
899
900 return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
901}
902//******************************************************************************
903//******************************************************************************
904BOOL WIN32API ClientToScreen (HWND hwnd, PPOINT pt)
905{
906#ifdef DEBUG
907 WriteLog("USER32: ClientToScreen\n");
908#endif
909 Win32BaseWindow *wnd;
910 PRECT rcl;
911
912 if (!hwnd) {
913 SetLastError(ERROR_INVALID_PARAMETER);
914 return (FALSE);
915 }
916 wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
917 if (!wnd) {
918 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
919 return (FALSE);
920 }
921
922 rcl = wnd->getClientRect();
923 pt->y = (rcl->bottom - rcl->top) - pt->y;
924 OSLibWinMapWindowPoints (wnd->getOS2WindowHandle(), OSLIB_HWND_DESKTOP, (OSLIBPOINT *)pt, 1);
925 pt->y = ScreenHeight - pt->y;
926 return (TRUE);
927}
928//******************************************************************************
929//******************************************************************************
930HDWP WIN32API BeginDeferWindowPos(int count)
931{
932 HDWP handle;
933 DWP *pDWP;
934
935 dprintf(("USER32: BeginDeferWindowPos\n"));
936 if (count <= 0)
937 {
938 SetLastError(ERROR_INVALID_PARAMETER);
939 return 0;
940 }
941 handle = (HDWP)HeapAlloc(GetProcessHeap(), 0, sizeof(DWP) + (count-1)*sizeof(WINDOWPOS) );
942 if (!handle)
943 return 0;
944
945 pDWP = (DWP *) handle;
946 pDWP->actualCount = 0;
947 pDWP->suggestedCount = count;
948 pDWP->valid = TRUE;
949 pDWP->wMagic = DWP_MAGIC;
950 pDWP->hwndParent = 0;
951 return handle;
952}
953/***********************************************************************
954 * DeferWindowPos (USER32.128)
955 */
956HDWP WIN32API DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
957 INT x, INT y, INT cx, INT cy,
958 UINT flags )
959{
960 DWP *pDWP;
961 int i;
962 HDWP newhdwp = hdwp,retvalue;
963 Win32BaseWindow *window;
964
965 pDWP = (DWP *)hdwp;
966 if (!pDWP) {
967 SetLastError(ERROR_INVALID_PARAMETER);
968 return 0;
969 }
970
971 if (hwnd == GetDesktopWindow())
972 return 0;
973
974 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
975 if(!window) {
976 dprintf(("DeferWindowPos, window %x not found", hwnd));
977 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
978 HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
979 return 0;
980 }
981
982
983/* Numega Bounds Checker Demo dislikes the following code.
984 In fact, I've not been able to find any "same parent" requirement in any docu
985 [AM 980509]
986 */
987#if 0
988 /* All the windows of a DeferWindowPos() must have the same parent */
989 parent = pWnd->parent->hwndSelf;
990 if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
991 else if (parent != pDWP->hwndParent)
992 {
993 USER_HEAP_FREE( hdwp );
994 retvalue = 0;
995 goto END;
996 }
997#endif
998
999 for (i = 0; i < pDWP->actualCount; i++)
1000 {
1001 if (pDWP->winPos[i].hwnd == hwnd)
1002 {
1003 /* Merge with the other changes */
1004 if (!(flags & SWP_NOZORDER))
1005 {
1006 pDWP->winPos[i].hwndInsertAfter = hwndAfter;
1007 }
1008 if (!(flags & SWP_NOMOVE))
1009 {
1010 pDWP->winPos[i].x = x;
1011 pDWP->winPos[i].y = y;
1012 }
1013 if (!(flags & SWP_NOSIZE))
1014 {
1015 pDWP->winPos[i].cx = cx;
1016 pDWP->winPos[i].cy = cy;
1017 }
1018 pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
1019 SWP_NOZORDER | SWP_NOREDRAW |
1020 SWP_NOACTIVATE | SWP_NOCOPYBITS|
1021 SWP_NOOWNERZORDER);
1022 pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
1023 SWP_FRAMECHANGED);
1024 retvalue = hdwp;
1025 goto END;
1026 }
1027 }
1028 if (pDWP->actualCount >= pDWP->suggestedCount)
1029 {
1030 newhdwp = (HDWP)HeapReAlloc(GetProcessHeap(), 0, (LPVOID)hdwp,
1031 sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS));
1032 if (!newhdwp)
1033 {
1034 retvalue = 0;
1035 goto END;
1036 }
1037 pDWP = (DWP *) newhdwp;
1038 pDWP->suggestedCount++;
1039 }
1040 pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
1041 pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
1042 pDWP->winPos[pDWP->actualCount].x = x;
1043 pDWP->winPos[pDWP->actualCount].y = y;
1044 pDWP->winPos[pDWP->actualCount].cx = cx;
1045 pDWP->winPos[pDWP->actualCount].cy = cy;
1046 pDWP->winPos[pDWP->actualCount].flags = flags;
1047 pDWP->actualCount++;
1048 retvalue = newhdwp;
1049END:
1050 return retvalue;
1051}
1052//******************************************************************************
1053//******************************************************************************
1054BOOL WIN32API EndDeferWindowPos( HDWP hdwp)
1055{
1056 DWP *pDWP;
1057 WINDOWPOS *winpos;
1058 BOOL res = TRUE;
1059 int i;
1060
1061 dprintf(("EndDeferWindowPos\n"));
1062 pDWP = (DWP *) hdwp;
1063 if (!pDWP) {
1064 SetLastError(ERROR_INVALID_PARAMETER);
1065 return FALSE;
1066 }
1067 for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
1068 {
1069 if (!(res = SetWindowPos(winpos->hwnd, winpos->hwndInsertAfter,
1070 winpos->x, winpos->y, winpos->cx,
1071 winpos->cy, winpos->flags )))
1072 break;
1073 }
1074 HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
1075 return res;
1076}
1077//******************************************************************************
1078//******************************************************************************
1079HWND WIN32API ChildWindowFromPoint( HWND hwnd, POINT pt)
1080{
1081 dprintf(("USER32: ChildWindowFromPoint\n"));
1082// return O32_ChildWindowFromPoint(arg1, arg2);
1083 return ChildWindowFromPointEx(hwnd, pt, 0);
1084}
1085//******************************************************************************
1086//******************************************************************************
1087/*****************************************************************************
1088 * Name : HWND WIN32API ChildWindowFromPointEx
1089 * Purpose : The GetWindowRect function retrieves the dimensions of the
1090 * bounding rectangle of the specified window. The dimensions are
1091 * given in screen coordinates that are relative to the upper-left
1092 * corner of the screen.
1093 * Parameters:
1094 * Variables :
1095 * Result : If the function succeeds, the return value is the window handle.
1096 * If the function fails, the return value is zero
1097 * Remark :
1098 * Status : FULLY IMPLEMENTED AND TESTED
1099 *
1100 * Author : Rene Pronk [Sun, 1999/08/08 23:30]
1101 *****************************************************************************/
1102
1103HWND WIN32API ChildWindowFromPointEx (HWND hwndParent, POINT pt, UINT uFlags)
1104{
1105 RECT rect;
1106 HWND hWnd;
1107 POINT absolutePt;
1108
1109 dprintf(("ChildWindowFromPointEx(%08xh,%08xh,%08xh).\n",
1110 hwndParent, pt, uFlags));
1111
1112 if (GetWindowRect (hwndParent, &rect) == 0) {
1113 // oops, invalid handle
1114 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1115 return NULL;
1116 }
1117
1118 // absolutePt has its top in the upper-left corner of the screen
1119 absolutePt = pt;
1120 ClientToScreen (hwndParent, &absolutePt);
1121
1122 // make rect the size of the parent window
1123 GetWindowRect (hwndParent, &rect);
1124 rect.right = rect.right - rect.left;
1125 rect.bottom = rect.bottom - rect.top;
1126 rect.left = 0;
1127 rect.top = 0;
1128
1129 if (PtInRect (&rect, pt) == 0) {
1130 // point is outside window
1131 return NULL;
1132 }
1133
1134 // get first child
1135 hWnd = GetWindow (hwndParent, GW_CHILD);
1136
1137 while (hWnd != NULL) {
1138
1139 // do I need to skip this window?
1140 if (((uFlags & CWP_SKIPINVISIBLE) &&
1141 (IsWindowVisible (hWnd) == FALSE)) ||
1142 ((uFlags & CWP_SKIPDISABLED) &&
1143 (IsWindowEnabled (hWnd) == FALSE)) ||
1144 ((uFlags & CWP_SKIPTRANSPARENT) &&
1145 (GetWindowLongA (hWnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
1146
1147 {
1148 hWnd = GetWindow (hWnd, GW_HWNDNEXT);
1149 continue;
1150 }
1151
1152 // is the point in this window's rect?
1153 GetWindowRect (hWnd, &rect);
1154 if (PtInRect (&rect, absolutePt) == FALSE) {
1155 hWnd = GetWindow (hWnd, GW_HWNDNEXT);
1156 continue;
1157 }
1158
1159 dprintf(("ChildWindowFromPointEx returned %x", hWnd));
1160 // found it!
1161 return hWnd;
1162 }
1163
1164 // the point is in the parentwindow but the parentwindow has no child
1165 // at this coordinate
1166 dprintf(("ChildWindowFromPointEx returned parent %x", hwndParent));
1167 return hwndParent;
1168}
1169//******************************************************************************
1170//******************************************************************************
1171BOOL WIN32API CloseWindow(HWND hwnd)
1172{
1173 Win32BaseWindow *window;
1174
1175 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1176 if(!window) {
1177 dprintf(("CloseWindow, window %x not found", hwnd));
1178 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1179 return 0;
1180 }
1181 dprintf(("CloseWindow %x\n", hwnd));
1182 return window->CloseWindow();
1183}
1184//******************************************************************************
1185//TODO: Does this return handles of hidden or disabled windows?
1186//******************************************************************************
1187HWND WIN32API WindowFromPoint( POINT point)
1188{
1189 HWND hwnd;
1190
1191 dprintf(("WindowFromPoint (%d,%d)\n", point.x, point.y));
1192 hwnd = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&point);
1193 if(hwnd) {
1194 return Win32BaseWindow::OS2ToWin32Handle(hwnd);
1195 }
1196 return 0;
1197}
1198//******************************************************************************
1199//******************************************************************************
1200BOOL WIN32API IsWindowUnicode(HWND hwnd)
1201{
1202 Win32BaseWindow *window;
1203
1204 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1205 if(!window) {
1206 dprintf(("IsWindowUnicode, window %x not found", hwnd));
1207 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1208 return 0;
1209 }
1210 return window->IsUnicode();
1211}
1212/*****************************************************************************
1213 * Name : WORD WIN32API CascadeWindows
1214 * Purpose : The CascadeWindows function cascades the specified windows or
1215 * the child windows of the specified parent window.
1216 * Parameters: HWND hwndParent handle of parent window
1217 * UINT wHow types of windows not to arrange
1218 * CONST RECT * lpRect rectangle to arrange windows in
1219 * UINT cKids number of windows to arrange
1220 * const HWND FAR * lpKids array of window handles
1221 * Variables :
1222 * Result : If the function succeeds, the return value is the number of windows arranged.
1223 * If the function fails, the return value is zero.
1224 * Remark :
1225 * Status : UNTESTED STUB
1226 *
1227 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
1228 *****************************************************************************/
1229
1230WORD WIN32API CascadeWindows(HWND hwndParent,
1231 UINT wHow,
1232 CONST LPRECT lpRect,
1233 UINT cKids,
1234 const HWND *lpKids)
1235{
1236 dprintf(("USER32:CascadeWindows(%08xh,%u,%08xh,%u,%08x) not implemented.\n",
1237 hwndParent,
1238 wHow,
1239 lpRect,
1240 cKids,
1241 lpKids));
1242
1243 return (0);
1244}
1245/*****************************************************************************
1246 * Name : BOOL WIN32API SwitchToThisWindow
1247 * Purpose : Unknown
1248 * Parameters: Unknown
1249 * Variables :
1250 * Result :
1251 * Remark :
1252 * Status : UNTESTED UNKNOWN STUB
1253 *
1254 * Author : Patrick Haller [Wed, 1998/06/16 11:55]
1255 *****************************************************************************/
1256
1257BOOL WIN32API SwitchToThisWindow(HWND hwnd,
1258 BOOL x2)
1259{
1260 dprintf(("USER32: SwitchToThisWindow(%08xh,%08xh) not implemented.\n",
1261 hwnd,
1262 x2));
1263
1264 return (FALSE); /* default */
1265}
1266//******************************************************************************
1267//******************************************************************************
1268BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
1269{
1270 Win32BaseWindow *window;
1271 BOOL rc;
1272 ULONG henum;
1273 HWND hwndNext;
1274 ULONG tid;
1275 ULONG pid, curpid;
1276
1277 dprintf(("EnumThreadWindows\n"));
1278
1279 curpid = GetCurrentProcessId();
1280
1281 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
1282 while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
1283 {
1284 OSLibWinQueryWindowProcess(hwndNext, &pid, &tid);
1285 if(!(curpid == pid && dwThreadId == tid))
1286 continue;
1287
1288 window = Win32BaseWindow::GetWindowFromHandle(hwndNext);
1289 if(window == NULL) {
1290 //OS/2 window or non-frame window, so skip it
1291 continue;
1292 }
1293 if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE)
1294 break;
1295 }
1296 OSLibWinEndEnumWindows (henum);
1297 return TRUE;
1298}
1299//******************************************************************************
1300//******************************************************************************
1301BOOL WIN32API EnumChildWindows(HWND hwnd, WNDENUMPROC lpfn, LPARAM lParam)
1302{
1303 Win32BaseWindow *window, *parentwindow;
1304 BOOL rc = TRUE;
1305 ULONG henum;
1306 HWND hwndNext;
1307
1308 dprintf(("EnumChildWindows %x %x\n", hwnd, lParam));
1309
1310 parentwindow = Win32BaseWindow::GetWindowFromHandle(hwnd);
1311 if(!parentwindow) {
1312 dprintf(("EnumChildWindows, window %x not found", hwnd));
1313 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1314 return FALSE;
1315 }
1316
1317 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
1318 while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
1319 {
1320 window = Win32BaseWindow::GetWindowFromHandle(hwndNext);
1321 if(window == NULL) {
1322 //OS/2 window or non-frame window, so skip it
1323 continue;
1324 }
1325 if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE)
1326 {
1327 rc = FALSE;
1328 break;
1329 }
1330 }
1331 OSLibWinEndEnumWindows(henum);
1332 return rc;
1333}
1334//******************************************************************************
1335//******************************************************************************
1336BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
1337{
1338 Win32BaseWindow *window;
1339 BOOL rc;
1340 ULONG henum;
1341 HWND hwndNext, hwndParent = OSLIB_HWND_DESKTOP;
1342
1343 dprintf(("EnumThreadWindows\n"));
1344
1345 do {
1346 henum = OSLibWinBeginEnumWindows(hwndParent);
1347 while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
1348 {
1349 window = Win32BaseWindow::GetWindowFromHandle(hwndNext);
1350 if(window == NULL) {
1351 //OS/2 window or non-frame window, so skip it
1352 continue;
1353 }
1354 if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE) {
1355 goto Abort;
1356 }
1357 }
1358 if(hwndParent == OSLIB_HWND_OBJECT)
1359 break;
1360 hwndParent = OSLIB_HWND_OBJECT;
1361 OSLibWinEndEnumWindows(henum);
1362 }
1363 while(TRUE);
1364
1365Abort:
1366 OSLibWinEndEnumWindows(henum);
1367 return TRUE;
1368}
1369//******************************************************************************
1370//******************************************************************************
1371#if 0
1372BOOL WIN32API GetUpdateRect( HWND hwnd, PRECT lpRect, BOOL bErase)
1373{
1374 dprintf(("GetUpdateRect %x %d\n", hwnd, bErase));
1375 if (!lpRect) return FALSE;
1376
1377 return OSLibWinQueryUpdateRect(Win32BaseWindow::Win32ToOS2Handle(hwnd), lpRect);
1378}
1379#endif
1380//******************************************************************************
1381//******************************************************************************
1382#if 0
1383BOOL WIN32API InvalidateRect(HWND hWnd, const RECT *lpRect, BOOL bErase)
1384{
1385#ifdef DEBUG
1386 if(lpRect)
1387 WriteLog("USER32: InvalidateRect for window %X (%d,%d)(%d,%d) %d\n", hWnd, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, bErase);
1388 else WriteLog("USER32: InvalidateRect for window %X NULL, %d\n", hWnd, bErase);
1389#endif
1390
1391 //CB: bErase no quite the same
1392 hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
1393 if (lpRect)
1394 {
1395 return OSLibWinInvalidateRect(hWnd, (PRECT)lpRect, bErase);
1396 }
1397 else return OSLibWinInvalidateRect(hWnd,NULL,bErase);
1398}
1399#endif
1400//******************************************************************************
1401//******************************************************************************
1402UINT WIN32API ArrangeIconicWindows( HWND arg1)
1403{
1404#ifdef DEBUG
1405 WriteLog("USER32: ArrangeIconicWindows\n");
1406#endif
1407 return O32_ArrangeIconicWindows(arg1);
1408}
1409//******************************************************************************
1410//restores iconized window to previous size/position
1411//******************************************************************************
1412BOOL WIN32API OpenIcon(HWND hwnd)
1413{
1414#ifdef DEBUG
1415 WriteLog("USER32: OpenIcon\n");
1416#endif
1417 if(!IsIconic(hwnd))
1418 return FALSE;
1419 ShowWindow(hwnd, SW_SHOWNORMAL);
1420 return TRUE;
1421}
1422//******************************************************************************
1423//******************************************************************************
1424BOOL WIN32API ShowOwnedPopups( HWND arg1, BOOL arg2)
1425{
1426 dprintf(("USER32: ShowOwnedPopups\n"));
1427 return O32_ShowOwnedPopups(arg1, arg2);
1428}
1429//******************************************************************************
1430//******************************************************************************
1431
Note: See TracBrowser for help on using the repository browser.