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

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

MapDialogRect fix

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