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

Last change on this file since 1530 was 1530, checked in by cbratschi, 26 years ago

pmframe, scrollbar fixes. window.cpp compiles again

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