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

Last change on this file since 1537 was 1537, checked in by dengert, 26 years ago

fix STATICs

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