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

Last change on this file since 5237 was 5237, checked in by sandervl, 25 years ago

Added CreateFakeWindowEx

File size: 66.9 KB
Line 
1/* $Id: window.cpp,v 1.89 2001-02-21 21:30:44 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 * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)
8 *
9 * Parts based on Wine Windows code (windows\win.c, windows\property.c, windows\winpos.c)
10 *
11 * Copyright 1993, 1994, 1995 Alexandre Julliard
12 * 1995, 1996, 1999 Alex Korobka
13 *
14 * Project Odin Software License can be found in LICENSE.TXT
15 *
16 *
17 * TODO: Decide what to do about commands for OS/2 windows (non-Win32 apps)
18 * TODO: ShowOwnedPopups needs to be tested
19 * GetLastActivePopup needs to be rewritten
20 * ArrangeIconicWindows probably also
21 *
22 */
23
24#include <os2win.h>
25#include <misc.h>
26#include <string.h>
27#include <stdio.h>
28#include <win32wbase.h>
29#include <win32wmdiclient.h>
30#include <win32wdesktop.h>
31#include "win32dlg.h"
32#include <oslibwin.h>
33#include <oslibgdi.h>
34#include "user32.h"
35#include "winicon.h"
36#include "oslibmsg.h"
37#include <win\winpos.h>
38#include <win\win.h>
39#include <heapstring.h>
40#include <winuser32.h>
41
42#define DBG_LOCALLOG DBG_window
43#include "dbglocal.h"
44
45//******************************************************************************
46//******************************************************************************
47HWND WIN32API CreateWindowExA(DWORD exStyle, LPCSTR className,
48 LPCSTR windowName, DWORD style, INT x,
49 INT y, INT width, INT height,
50 HWND parent, HMENU menu,
51 HINSTANCE instance, LPVOID data )
52{
53 Win32BaseWindow *window;
54 ATOM classAtom;
55 CREATESTRUCTA cs;
56 char tmpClass[20];
57
58 if(exStyle & WS_EX_MDICHILD)
59 return CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
60
61 /* Find the class atom */
62 if (!(classAtom = GlobalFindAtomA(className)))
63 {
64 if (!HIWORD(className))
65 dprintf(("CreateWindowEx32A: bad class name %04x\n",LOWORD(className)));
66 else
67 dprintf(("CreateWindowEx32A: bad class name '%s'\n", className));
68
69 SetLastError(ERROR_INVALID_PARAMETER);
70 return 0;
71 }
72
73 if (!HIWORD(className))
74 {
75 sprintf(tmpClass,"#%d", (int) className);
76 className = tmpClass;
77 }
78
79 /* Create the window */
80 cs.lpCreateParams = data;
81 cs.hInstance = instance;
82 cs.hMenu = menu;
83 cs.hwndParent = parent;
84 cs.x = x;
85 cs.y = y;
86 cs.cx = width;
87 cs.cy = height;
88 cs.style = style;
89 cs.lpszName = windowName;
90 cs.lpszClass = className;
91 cs.dwExStyle = exStyle;
92 if(HIWORD(className)) {
93 dprintf(("CreateWindowExA: class %s parent %x (%d,%d) (%d,%d), %x %x menu=%x", className, parent, x, y, width, height, style, exStyle, menu));
94 }
95 else dprintf(("CreateWindowExA: class %d parent %x (%d,%d) (%d,%d), %x %x menu=%x", className, parent, x, y, width, height, style, exStyle, menu));
96
97 if(!strcmpi(className, MDICLIENTCLASSNAMEA)) {
98 window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, FALSE);
99 }
100 else
101 if(!strcmpi((char *) className, DIALOG_CLASS_NAMEA))
102 {
103 DLG_TEMPLATE dlgTemplate = {0};
104 dlgTemplate.style = cs.style;
105 dlgTemplate.exStyle = cs.dwExStyle;
106 dlgTemplate.x = cs.x;
107 dlgTemplate.y = cs.y;
108 dlgTemplate.cx = cs.cx;
109 dlgTemplate.cy = cs.cy;
110 dlgTemplate.className = cs.lpszClass;
111 dlgTemplate.caption = cs.lpszName;
112 window = (Win32BaseWindow *) new Win32Dialog(cs.hInstance,
113 (LPCSTR) &dlgTemplate,
114 cs.hwndParent,
115 NULL,
116 (LPARAM) data,
117 FALSE);
118 }
119 else {
120 window = new Win32BaseWindow( &cs, classAtom, FALSE );
121 }
122 if(window == NULL)
123 {
124 dprintf(("Win32BaseWindow creation failed!!"));
125 return 0;
126 }
127 if(GetLastError() != 0)
128 {
129 dprintf(("Win32BaseWindow error found!!"));
130 delete window;
131 return 0;
132 }
133 return window->getWindowHandle();
134}
135//******************************************************************************
136//******************************************************************************
137HWND WIN32API CreateWindowExW(DWORD exStyle, LPCWSTR className,
138 LPCWSTR windowName, DWORD style, INT x,
139 INT y, INT width, INT height,
140 HWND parent, HMENU menu,
141 HINSTANCE instance, LPVOID data )
142{
143 Win32BaseWindow *window;
144 ATOM classAtom;
145 CREATESTRUCTA cs;
146 WCHAR tmpClassW[20];
147
148 if(exStyle & WS_EX_MDICHILD)
149 return CreateMDIWindowW(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
150
151 /* Find the class atom */
152 if (!(classAtom = GlobalFindAtomW(className)))
153 {
154 if (!HIWORD(className))
155 dprintf(("CreateWindowEx32W: bad class name %04x",LOWORD(className)));
156 else
157 dprintf(("CreateWindowEx32W: bad class name '%x'", className));
158
159 SetLastError(ERROR_INVALID_PARAMETER);
160 return 0;
161 }
162
163 if(HIWORD(className)) {
164 dprintf(("CreateWindowExW: class %ls name %x parent %x (%d,%d) (%d,%d), %x %x", className, windowName, parent, x, y, width, height, style, exStyle));
165 }
166 else dprintf(("CreateWindowExW: class %d name %x parent %x (%d,%d) (%d,%d), %x %x", className, windowName, parent, x, y, width, height, style, exStyle));
167
168 if (!HIWORD(className))
169 {
170 wsprintfW(tmpClassW, (LPCWSTR)L"#%d", (int) className);
171 className = tmpClassW;
172 }
173
174 /* Create the window */
175 cs.lpCreateParams = data;
176 cs.hInstance = instance;
177 cs.hMenu = menu;
178 cs.hwndParent = parent;
179 cs.x = x;
180 cs.y = y;
181 cs.cx = width;
182 cs.cy = height;
183 cs.style = style;
184 cs.lpszName = (LPSTR)windowName;
185 cs.lpszClass = (LPSTR)className;
186 cs.dwExStyle = exStyle;
187
188 if(!lstrcmpiW(className, (LPWSTR)MDICLIENTCLASSNAMEW)) {
189 window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, TRUE);
190 }
191 else
192 if(!lstrcmpiW(className, (LPWSTR)DIALOG_CLASS_NAMEW))
193 {
194 DLG_TEMPLATE dlgTemplate = {0};
195 dlgTemplate.style = cs.style;
196 dlgTemplate.exStyle = cs.dwExStyle;
197 dlgTemplate.x = cs.x;
198 dlgTemplate.y = cs.y;
199 dlgTemplate.cx = cs.cx;
200 dlgTemplate.cy = cs.cy;
201 dlgTemplate.className = cs.lpszClass;
202 dlgTemplate.caption = cs.lpszName;
203 window = (Win32BaseWindow *) new Win32Dialog(cs.hInstance,
204 (LPCSTR) &dlgTemplate,
205 cs.hwndParent,
206 NULL,
207 (LPARAM) data,
208 TRUE);
209 }
210 else {
211 window = new Win32BaseWindow( &cs, classAtom, TRUE );
212 }
213 if(window == NULL)
214 {
215 dprintf(("Win32BaseWindow creation failed!!"));
216 return 0;
217 }
218 if(GetLastError() != 0)
219 {
220 dprintf(("Win32BaseWindow error found!!"));
221 delete window;
222 return 0;
223 }
224 return window->getWindowHandle();
225}
226//******************************************************************************
227//******************************************************************************
228HWND WIN32API CreateFakeWindowEx(HWND hwndOS2)
229{
230 Win32BaseWindow *window;
231
232 window = new Win32BaseWindow(hwndOS2, 0);
233 if(window == NULL)
234 {
235 dprintf(("Win32BaseWindow creation failed!!"));
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 cs.szClass = lpszClassName;
258 cs.szTitle = lpszWindowName;
259 cs.hOwner = hInstance;
260 cs.x = x;
261 cs.y = y;
262 cs.cx = nHeight;
263 cs.cy = nWidth;
264 cs.style = dwStyle;
265 cs.lParam = lParam;
266
267 if(HIWORD(lpszClassName)) {
268 dprintf(("CreateMDIWindowA: class %s parent %x (%d,%d) (%d,%d), %x %x lParam=%x", lpszClassName, hwndParent, x, y, nWidth, nHeight, dwStyle, lParam));
269 }
270 else dprintf(("CreateMDIWindowA: class %d parent %x (%d,%d) (%d,%d), %x %x lParam=%x", lpszClassName, hwndParent, x, y, nWidth, nHeight, dwStyle, lParam));
271
272 return window->SendMessageA(WM_MDICREATE, 0, (LPARAM)&cs);
273}
274//******************************************************************************
275//******************************************************************************
276HWND WIN32API CreateMDIWindowW(LPCWSTR lpszClassName, LPCWSTR lpszWindowName,
277 DWORD dwStyle, int x, int y, int nWidth,
278 int nHeight, HWND hwndParent,
279 HINSTANCE hInstance, LPARAM lParam )
280{
281 HWND hwnd;
282 MDICREATESTRUCTW cs;
283 Win32BaseWindow *window;
284
285 window = Win32BaseWindow::GetWindowFromHandle(hwndParent);
286 if(!window) {
287 dprintf(("CreateMDIWindowW, window %x not found", hwndParent));
288 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
289 return 0;
290 }
291
292 dprintf(("USER32: CreateMDIWindowW\n"));
293 cs.szClass = lpszClassName;
294 cs.szTitle = lpszWindowName;
295 cs.hOwner = hInstance;
296 cs.x = x;
297 cs.y = y;
298 cs.cx = nHeight;
299 cs.cy = nWidth;
300 cs.style = dwStyle;
301 cs.lParam = lParam;
302
303 return window->SendMessageW(WM_MDICREATE, 0, (LPARAM)&cs);
304}
305//******************************************************************************
306//******************************************************************************
307BOOL WIN32API DestroyWindow(HWND hwnd)
308{
309 Win32BaseWindow *window;
310
311 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
312 if(!window) {
313 dprintf(("DestroyWindow, window %x not found", hwnd));
314 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
315 return 0;
316 }
317 if(window->isDesktopWindow()) {
318 dprintf(("WARNING: Trying to destroy desktop window!"));
319 return FALSE;
320 }
321 return window->DestroyWindow();
322}
323//******************************************************************************
324//******************************************************************************
325HWND WIN32API SetActiveWindow( HWND hwnd)
326{
327 Win32BaseWindow *window;
328
329 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
330 if(!window) {
331 dprintf(("SetActiveWindow, window %x not found", hwnd));
332 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
333 return 0;
334 }
335 return window->SetActiveWindow();
336}
337//******************************************************************************
338//Note: does not set last error if no parent (verified in NT4, SP6)
339//******************************************************************************
340HWND WIN32API GetParent( HWND hwnd)
341{
342 Win32BaseWindow *window;
343
344 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
345 if(!window) {
346 dprintf(("GetParent, window %x not found", hwnd));
347 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
348 return 0;
349 }
350 dprintf2(("GetParent %x", hwnd));
351 return window->GetParent();
352}
353//******************************************************************************
354//******************************************************************************
355HWND WIN32API SetParent( HWND hwndChild, HWND hwndNewParent)
356{
357 Win32BaseWindow *window, *parent;
358
359 window = Win32BaseWindow::GetWindowFromHandle(hwndChild);
360 if(!window) {
361 dprintf(("SetParent, window %x not found", hwndChild));
362 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
363 return 0;
364 }
365 if(hwndNewParent == HWND_DESKTOP) {
366 hwndNewParent = GetDesktopWindow();
367 }
368 else {
369 parent = Win32BaseWindow::GetWindowFromHandle(hwndNewParent);
370 if(!window) {
371 dprintf(("SetParent, parent %x not found", hwndNewParent));
372 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
373 return 0;
374 }
375 }
376 dprintf(("SetParent %x %x", hwndChild, hwndNewParent));
377 return window->SetParent(hwndNewParent);
378}
379//******************************************************************************
380//******************************************************************************
381BOOL WIN32API IsChild( HWND hwndParent, HWND hwnd)
382{
383 Win32BaseWindow *window;
384
385 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
386 if(!window) {
387 dprintf(("IsChild %x, window %x not found", hwndParent, hwnd));
388 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
389 return 0;
390 }
391 dprintf(("IsChild %x %x", hwndParent, hwnd));
392 return window->IsChild(hwndParent);
393}
394//******************************************************************************
395//******************************************************************************
396HWND WIN32API GetTopWindow( HWND hwnd)
397{
398 Win32BaseWindow *window;
399 HWND hwndTop;
400
401 if(hwnd == HWND_DESKTOP) {
402 window = windowDesktop;
403 }
404 else {
405 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
406 if(!window) {
407 dprintf(("GetTopWindow, window %x not found", hwnd));
408 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
409 return 0;
410 }
411 }
412 hwndTop = window->GetTopWindow();
413 dprintf2(("GetTopWindow %x returned %x", hwnd, hwndTop));
414 return hwndTop;
415}
416//******************************************************************************
417//******************************************************************************
418BOOL WIN32API IsIconic( HWND hwnd)
419{
420 Win32BaseWindow *window;
421 BOOL rc;
422
423 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
424 if(!window) {
425 dprintf(("IsIconic, window %x not found", hwnd));
426 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
427 return FALSE;
428 }
429 rc = window->IsWindowIconic();
430 dprintf(("IsIconic %x returned %d", hwnd, rc));
431 return rc;
432}
433//******************************************************************************
434//******************************************************************************
435HWND WIN32API GetWindow(HWND hwnd, UINT uCmd)
436{
437 Win32BaseWindow *window;
438 HWND rc;
439
440 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
441 if(!window) {
442 dprintf(("GetWindow, window %x not found", hwnd));
443 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
444 return 0;
445 }
446 return window->GetWindow(uCmd);
447}
448//******************************************************************************
449//******************************************************************************
450BOOL WIN32API EnableWindow( HWND hwnd, BOOL fEnable)
451{
452 Win32BaseWindow *window;
453
454 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
455 if(!window) {
456 dprintf(("EnableWindow, window %x not found", hwnd));
457 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
458 return 0;
459 }
460 dprintf(("EnableWindow %x %d", hwnd, fEnable));
461 return window->EnableWindow(fEnable);
462}
463//******************************************************************************
464//******************************************************************************
465BOOL WIN32API BringWindowToTop(HWND hwnd)
466{
467 return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
468}
469/***********************************************************************
470 * SetInternalWindowPos (USER32.483)
471 */
472void WIN32API SetInternalWindowPos(HWND hwnd,
473 UINT showCmd,
474 LPRECT lpRect,
475 LPPOINT lpPoint )
476{
477 dprintf(("USER32: SetInternalWindowPos(%08xh,%08xh,%08xh,%08xh)",
478 hwnd, showCmd, lpRect, lpPoint));
479
480 if( IsWindow(hwnd) )
481 {
482 WINDOWPLACEMENT wndpl;
483 UINT flags;
484
485 GetWindowPlacement(hwnd, &wndpl);
486 wndpl.length = sizeof(wndpl);
487 wndpl.showCmd = showCmd;
488 wndpl.flags = 0;
489
490 if(lpPoint)
491 {
492 wndpl.flags |= WPF_SETMINPOSITION;
493 wndpl.ptMinPosition = *lpPoint;
494 }
495 if(lpRect)
496 {
497 wndpl.rcNormalPosition = *lpRect;
498 }
499 SetWindowPlacement( hwnd, &wndpl);
500 }
501
502}
503/***********************************************************************
504 * GetInternalWindowPos (USER32.245)
505 */
506UINT WIN32API GetInternalWindowPos(HWND hwnd,
507 LPRECT rectWnd,
508 LPPOINT ptIcon )
509{
510 WINDOWPLACEMENT wndpl;
511
512 dprintf(("USER32: GetInternalWindowPos(%08xh,%08xh,%08xh)\n",
513 hwnd,
514 rectWnd,
515 ptIcon));
516
517 if(GetWindowPlacement( hwnd, &wndpl ))
518 {
519 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
520 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
521 return wndpl.showCmd;
522 }
523 return 0;
524}
525//******************************************************************************
526//******************************************************************************
527HWND WIN32API GetActiveWindow()
528{
529 return Win32BaseWindow::GetActiveWindow();
530}
531//******************************************************************************
532//******************************************************************************
533BOOL WIN32API ShowWindow(HWND hwnd, int nCmdShow)
534{
535 Win32BaseWindow *window;
536
537 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
538 if(!window) {
539 dprintf(("ShowWindow, window %x not found", hwnd));
540 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
541 return 0;
542 }
543 return window->ShowWindow(nCmdShow);
544}
545/*****************************************************************************
546 * Name : BOOL WIN32API ShowWindowAsync
547 * Purpose : The ShowWindowAsync function sets the show state of a window
548 * created by a different thread.
549 * Parameters: HWND hwnd handle of window
550 * int nCmdShow show state of window
551 * Variables :
552 * Result : If the window was previously visible, the return value is TRUE.
553 * If the window was previously hidden, the return value is FALSE.
554 * Remark :
555 * Status : UNTESTED STUB
556 *
557 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
558 *****************************************************************************/
559BOOL WIN32API ShowWindowAsync (HWND hwnd,
560 int nCmdShow)
561{
562 dprintf(("USER32:ShowWindowAsync (%08xh,%08x) not correctly implemented.\n",
563 hwnd,
564 nCmdShow));
565
566 return ShowWindow(hwnd, nCmdShow);
567}
568//******************************************************************************
569//******************************************************************************
570BOOL WIN32API SetWindowPos(HWND hwnd, HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
571{
572 Win32BaseWindow *window;
573
574 if (!hwnd)
575 {
576 dprintf(("SetWindowPos: Can't move desktop!"));
577 return TRUE;
578 }
579 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
580 if(!window) {
581 dprintf(("SetWindowPos, window %x not found", hwnd));
582 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
583 return FALSE;
584 }
585 dprintf(("SetWindowPos %x %x x=%d y=%d cx=%d cy=%d %x", hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
586 return window->SetWindowPos(hwndInsertAfter, x, y, cx, cy, fuFlags);
587}
588//******************************************************************************
589//NOTE: length must equal structure size or else api fails (verified in NT4, SP6)
590//******************************************************************************
591BOOL WIN32API SetWindowPlacement(HWND hwnd, const WINDOWPLACEMENT *winpos)
592{
593 Win32BaseWindow *window;
594
595 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
596 if(!window) {
597 dprintf(("SetWindowPlacement, window %x not found", hwnd));
598 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
599 return FALSE;
600 }
601 if(!winpos || winpos->length != sizeof(WINDOWPLACEMENT)) {
602 dprintf(("SetWindowPlacement %x invalid parameter", hwnd));
603 SetLastError(ERROR_INVALID_PARAMETER);
604 return FALSE;
605 }
606 dprintf(("USER32: SetWindowPlacement %x %x", hwnd, winpos));
607 return window->SetWindowPlacement((WINDOWPLACEMENT *)winpos);
608}
609//******************************************************************************
610//NOTE: Length does not need to be correct (even though the SDK docs claim otherwise)
611// (Verified in NT4, SP6)
612//******************************************************************************
613BOOL WIN32API GetWindowPlacement(HWND hwnd, LPWINDOWPLACEMENT winpos)
614{
615 Win32BaseWindow *window;
616
617 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
618 if(!window) {
619 dprintf(("GetWindowPlacement, window %x not found", hwnd));
620 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
621 return FALSE;
622 }
623 if(!winpos) {
624 dprintf(("GetWindowPlacement %x invalid parameter", hwnd));
625 SetLastError(ERROR_INVALID_PARAMETER);
626 return FALSE;
627 }
628 dprintf(("USER32: GetWindowPlacement %x %x", hwnd, winpos));
629 return window->GetWindowPlacement(winpos);
630}
631//******************************************************************************
632//******************************************************************************
633BOOL WIN32API IsWindow( HWND hwnd)
634{
635 Win32BaseWindow *window;
636
637 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
638 if(!window) {
639 dprintf(("IsWindow, window %x not found", hwnd));
640 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
641 return FALSE;
642 }
643 dprintf2(("IsWindow %x", hwnd));
644 return window->IsWindow();
645}
646//******************************************************************************
647//******************************************************************************
648BOOL WIN32API IsWindowEnabled( HWND hwnd)
649{
650 Win32BaseWindow *window;
651
652 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
653 if(!window) {
654 dprintf(("IsWindowEnabled, window %x not found", hwnd));
655 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
656 return 0;
657 }
658 dprintf(("IsWindowEnabled %x", hwnd));
659 return window->IsWindowEnabled();
660}
661//******************************************************************************
662//******************************************************************************
663BOOL WIN32API IsWindowVisible( HWND hwnd)
664{
665 Win32BaseWindow *window;
666 BOOL rc;
667
668 if (hwnd)
669 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
670 else
671 window = windowDesktop;
672 if(!window) {
673 dprintf(("IsWindowVisible, window %x not found", hwnd));
674 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
675 return 0;
676 }
677 rc = window->IsWindowVisible();
678 dprintf(("IsWindowVisible %x returned %d", hwnd, rc));
679 return rc;
680}
681//******************************************************************************
682//******************************************************************************
683HWND WIN32API SetFocus (HWND hwnd)
684{
685 HWND lastFocus, lastFocus_W, hwnd_O;
686 BOOL activate;
687 TEB *teb;
688
689 teb = GetThreadTEB();
690 if(teb == NULL) {
691 DebugInt3();
692 return 0;
693 }
694
695 hwnd_O = Win32ToOS2Handle (hwnd);
696 lastFocus = OSLibWinQueryFocus (OSLIB_HWND_DESKTOP);
697 activate = ((hwnd_O == lastFocus) || OSLibWinIsChild (lastFocus, hwnd_O));
698 lastFocus_W = OS2ToWin32Handle (lastFocus);
699
700 dprintf(("SetFocus %x (%x) -> %x (%x)\n", lastFocus_W, lastFocus, hwnd, hwnd_O));
701
702 //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
703 //must delay this function call
704 if(teb->o.odin.fWM_SETFOCUS) {
705 dprintf(("USER32: Delay SetFocus call!"));
706 teb->o.odin.hwndFocus = hwnd;
707 //mp1 = win32 window handle
708 //mp2 = activate flag
709 OSLibPostMessageDirect(hwnd_O, WIN32APP_SETFOCUSMSG, hwnd, activate);
710 return lastFocus_W;
711 }
712 return (OSLibWinSetFocus (OSLIB_HWND_DESKTOP, hwnd_O, activate)) ? lastFocus_W : 0;
713}
714//******************************************************************************
715//******************************************************************************
716HWND WIN32API GetFocus(void)
717{
718 TEB *teb;
719 HWND hwnd;
720
721 teb = GetThreadTEB();
722 if(teb == NULL) {
723 DebugInt3();
724 return 0;
725 }
726 //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
727 //If focus was changed during WM_SETFOCUS, the focus window handle is
728 //stored in teb->o.odin.hwndFocus (set back to 0 when delayed SetFocus
729 //is activated)
730 if(teb->o.odin.hwndFocus) {
731 dprintf(("USER32: GetFocus %x (DURING WM_SETFOCUS PROCESSING)", teb->o.odin.hwndFocus));
732 return teb->o.odin.hwndFocus;
733 }
734
735 hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP);
736 hwnd = OS2ToWin32Handle(hwnd);
737 dprintf(("USER32: GetFocus %x\n", hwnd));
738 return hwnd;
739}
740//******************************************************************************
741//******************************************************************************
742BOOL WIN32API IsZoomed(HWND hwnd)
743{
744 DWORD style;
745
746 style = GetWindowLongA(hwnd, GWL_STYLE);
747 dprintf(("USER32: IsZoomed %x returned %d", hwnd, ((style & WS_MAXIMIZE) != 0)));
748
749 return (style & WS_MAXIMIZE) != 0;
750}
751//******************************************************************************
752//******************************************************************************
753BOOL WIN32API LockWindowUpdate(HWND hwnd)
754{
755 dprintf(("USER32: LockWindowUpdate %x", hwnd));
756 return OSLibWinLockWindowUpdate(Win32ToOS2Handle(hwnd));
757}
758//******************************************************************************
759//******************************************************************************
760BOOL WIN32API GetWindowRect( HWND hwnd, PRECT pRect)
761{
762 Win32BaseWindow *window;
763
764 if (hwnd)
765 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
766 else
767 window = windowDesktop;
768
769 if(!window) {
770 dprintf(("GetWindowRect, window %x not found", hwnd));
771 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
772 return FALSE;
773 }
774 if(pRect == NULL) {
775 SetLastError(ERROR_INVALID_PARAMETER);
776 return FALSE;
777 }
778 *pRect = *window->getWindowRect();
779
780 //convert from parent coordinates to screen (if necessary)
781 if(window->getParent()) {
782 MapWindowPoints(window->getParent()->getWindowHandle(), 0, (PPOINT)pRect, 2);
783 }
784
785 dprintf(("GetWindowRect %x (%d,%d) (%d,%d)", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
786 return TRUE;
787}
788//******************************************************************************
789//******************************************************************************
790int WIN32API GetWindowTextLengthA( HWND hwnd)
791{
792 Win32BaseWindow *window;
793
794 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
795 if(!window) {
796 dprintf(("GetWindowTextLength, window %x not found", hwnd));
797 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
798 return 0;
799 }
800 dprintf(("GetWindowTextLength %x", hwnd));
801 return window->GetWindowTextLength();
802}
803//******************************************************************************
804//******************************************************************************
805int WIN32API GetWindowTextA( HWND hwnd, LPSTR lpsz, int cch)
806{
807 Win32BaseWindow *window;
808 int rc;
809
810 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
811 if(!window) {
812 dprintf(("GetWindowTextA, window %x not found", hwnd));
813 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
814 return 0;
815 }
816 rc = window->GetWindowTextA(lpsz, cch);
817 dprintf(("GetWindowTextA %x %s", hwnd, lpsz));
818 return rc;
819}
820//******************************************************************************
821//******************************************************************************
822int WIN32API GetWindowTextLengthW( HWND hwnd)
823{
824 dprintf(("USER32: GetWindowTextLengthW\n"));
825 return GetWindowTextLengthA(hwnd);
826}
827//******************************************************************************
828//******************************************************************************
829int WIN32API GetWindowTextW(HWND hwnd, LPWSTR lpsz, int cch)
830{
831 Win32BaseWindow *window;
832
833 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
834 if(!window) {
835 dprintf(("GetWindowTextW, window %x not found", hwnd));
836 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
837 return 0;
838 }
839#ifdef DEBUG
840 int rc = window->GetWindowTextW(lpsz, cch);
841 if(rc) {
842 LPSTR astring = UnicodeToAsciiString(lpsz);
843 dprintf(("GetWindowTextW %x %s", hwnd, lpsz));
844 free(astring);
845 }
846 else dprintf(("GetWindowTextW %x returned %d", hwnd, rc));
847 return rc;
848#else
849 return window->GetWindowTextW(lpsz, cch);
850#endif
851}
852//******************************************************************************
853//******************************************************************************
854BOOL WIN32API SetWindowTextA(HWND hwnd, LPCSTR lpsz)
855{
856 Win32BaseWindow *window;
857
858 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
859 if(!window) {
860 dprintf(("SetWindowTextA, window %x not found", hwnd));
861 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
862 return 0;
863 }
864 dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
865 return window->SetWindowTextA((LPSTR)lpsz);
866}
867//******************************************************************************
868//******************************************************************************
869BOOL WIN32API SetWindowTextW( HWND hwnd, LPCWSTR lpsz)
870{
871 Win32BaseWindow *window;
872
873 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
874 if(!window) {
875 dprintf(("SetWindowTextA, window %x not found", hwnd));
876 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
877 return 0;
878 }
879#ifdef DEBUG
880 LPSTR astring = UnicodeToAsciiString(lpsz);
881 dprintf(("SetWindowTextW %x %s", hwnd, astring));
882 free(astring);
883#endif
884 return window->SetWindowTextW((LPWSTR)lpsz);
885}
886/*******************************************************************
887 * InternalGetWindowText (USER32.326)
888 */
889int WIN32API InternalGetWindowText(HWND hwnd,
890 LPWSTR lpString,
891 INT nMaxCount )
892{
893 dprintf(("USER32: InternalGetWindowText(%08xh,%08xh,%08xh) not properly implemented.\n",
894 hwnd,
895 lpString,
896 nMaxCount));
897
898 return GetWindowTextW(hwnd,lpString,nMaxCount);
899}
900//******************************************************************************
901//TODO: Correct?
902//******************************************************************************
903BOOL WIN32API SetForegroundWindow(HWND hwnd)
904{
905 dprintf((" SetForegroundWindow %x", hwnd));
906
907 return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
908}
909//******************************************************************************
910//******************************************************************************
911BOOL WIN32API GetClientRect( HWND hwnd, PRECT pRect)
912{
913 HWND hwndWin32 = hwnd;
914 Win32BaseWindow *window;
915
916 if (!pRect)
917 {
918 SetLastError(ERROR_INVALID_PARAMETER);
919 return FALSE;
920 }
921 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
922 if(!window) {
923 dprintf(("GetClientRect, window %x not found", hwnd));
924 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
925 return FALSE;
926 }
927 window->getClientRect(pRect);
928 dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom));
929 return TRUE;
930}
931//******************************************************************************
932//******************************************************************************
933BOOL WIN32API AdjustWindowRect(PRECT rect, DWORD style, BOOL menu)
934{
935 return AdjustWindowRectEx(rect, style, menu, 0);
936}
937//******************************************************************************
938//Calculate window rectangle based on given client rectangle, style, menu and extended style
939//******************************************************************************
940BOOL WIN32API AdjustWindowRectEx( PRECT rect, DWORD style, BOOL menu, DWORD exStyle)
941{
942 if(style == 0 && menu == FALSE && exStyle == 0) {
943 dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d) -> no change required", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
944 return TRUE; //nothing needs to be changed (VERIFIED in NT 4)
945 }
946 dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d)\n", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
947 /* Correct the window style */
948 if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
949 style |= WS_CAPTION;
950
951 //SvL: Include WS_POPUP -> otherwise HAS_THINFRAME is true for popup windows
952 // Also include WS_CHILD -> otherwise HAS_THICKFRAME doesn't work correctly
953 style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_POPUP);
954 exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
955 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
956
957 //Adjust rect outer (Win32BaseWindow::AdjustRectOuter)
958 if (HAS_THICKFRAME(style,exStyle))
959 InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
960 else
961 if (HAS_DLGFRAME(style,exStyle))
962 InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
963 else
964 if (HAS_THINFRAME(style))
965 InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
966
967 if ((style & WS_CAPTION) == WS_CAPTION)
968 {
969 if (exStyle & WS_EX_TOOLWINDOW)
970 rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
971 else
972 rect->top -= GetSystemMetrics(SM_CYCAPTION);
973 }
974
975 if (menu)
976 rect->top -= GetSystemMetrics(SM_CYMENU);
977
978 //Adjust rect inner (Win32BaseWindow::AdjustRectInner)
979 if(!(style & WS_ICONIC)) {
980 if (exStyle & WS_EX_CLIENTEDGE)
981 InflateRect (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
982
983 if (exStyle & WS_EX_STATICEDGE)
984 InflateRect (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
985
986 //SvL: scrollbars aren't checked *UNLESS* the style includes a border (any border)
987 // --> VERIFIED IN NT4, SP6 (fixes MFC apps with scrollbars + bar controls)
988 if(style & (WS_THICKFRAME|WS_BORDER|WS_DLGFRAME)) {
989 if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
990 if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
991 }
992 }
993
994 dprintf(("AdjustWindowRectEx returned (%d,%d)(%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom));
995
996 return TRUE;
997}
998//******************************************************************************
999/* Coordinate Space and Transformation Functions */
1000//******************************************************************************
1001/*******************************************************************
1002 * WINPOS_GetWinOffset
1003 *
1004 * Calculate the offset between the origin of the two windows. Used
1005 * to implement MapWindowPoints.
1006 */
1007static void WINPOS_GetWinOffset( Win32BaseWindow *wndFrom, Win32BaseWindow *wndTo,
1008 POINT *offset )
1009{
1010 Win32BaseWindow *window;
1011
1012 offset->x = offset->y = 0;
1013
1014 /* Translate source window origin to screen coords */
1015 if(wndFrom != windowDesktop)
1016 {
1017 window = wndFrom;
1018 while(window)
1019 {
1020 offset->x += window->getClientRectPtr()->left + window->getWindowRect()->left;
1021 offset->y += window->getClientRectPtr()->top + window->getWindowRect()->top;
1022 window = window->getParent();
1023 }
1024 }
1025
1026 /* Translate origin to destination window coords */
1027 if(wndTo != windowDesktop)
1028 {
1029 window = wndTo;
1030 while(window)
1031 {
1032 offset->x -= window->getClientRectPtr()->left + window->getWindowRect()->left;
1033 offset->y -= window->getClientRectPtr()->top + window->getWindowRect()->top;
1034 window = window->getParent();
1035 }
1036 }
1037}
1038//******************************************************************************
1039//******************************************************************************
1040int WIN32API MapWindowPoints(HWND hwndFrom, HWND hwndTo, LPPOINT lpPoints,
1041 UINT cPoints)
1042{
1043 Win32BaseWindow *wndfrom, *wndto;
1044 int retval = 0;
1045 POINT offset;
1046
1047 SetLastError(0);
1048 if(lpPoints == NULL || cPoints == 0) {
1049 SetLastError(ERROR_INVALID_PARAMETER);
1050 return 0;
1051 }
1052 if(hwndFrom)
1053 {
1054 wndfrom = Win32BaseWindow::GetWindowFromHandle(hwndFrom);
1055 if(!wndfrom) {
1056 dprintf(("MapWindowPoints, window %x not found", hwndFrom));
1057 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1058 return 0;
1059 }
1060 }
1061 else wndfrom = windowDesktop;
1062
1063 if(hwndTo)
1064 {
1065 wndto = Win32BaseWindow::GetWindowFromHandle(hwndTo);
1066 if(!wndto) {
1067 dprintf(("MapWindowPoints, window %x not found", hwndTo));
1068 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1069 return 0;
1070 }
1071 }
1072 else wndto = windowDesktop;
1073
1074 if(wndto == wndfrom)
1075 return 0; //nothing to do
1076
1077 dprintf2(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
1078 WINPOS_GetWinOffset(wndfrom, wndto, &offset);
1079
1080 for(int i=0;i<cPoints;i++)
1081 {
1082 lpPoints[i].x += offset.x;
1083 lpPoints[i].y += offset.y;
1084 }
1085 retval = ((LONG)offset.y << 16) | offset.x;
1086 return retval;
1087}
1088//******************************************************************************
1089//******************************************************************************
1090BOOL WIN32API ScreenToClient(HWND hwnd, LPPOINT pt)
1091{
1092 Win32BaseWindow *wnd;
1093 PRECT rcl;
1094 BOOL rc;
1095
1096 if(!hwnd) {
1097 return (TRUE);
1098 }
1099 wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
1100 if (!wnd) {
1101 dprintf(("warning: ScreenToClient: window %x not found!", hwnd));
1102 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1103 return FALSE;
1104 }
1105 SetLastError(0);
1106#ifdef DEBUG
1107 POINT tmp = *pt;
1108#endif
1109 MapWindowPoints(0, hwnd, pt, 1);
1110 dprintf2(("ScreenToClient %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
1111 return TRUE;
1112}
1113//******************************************************************************
1114//******************************************************************************
1115HWND WIN32API GetDesktopWindow(void)
1116{
1117 HWND DesktopWindow = windowDesktop->getWindowHandle();
1118 dprintf2(("USER32: GetDesktopWindow, returned %x\n", DesktopWindow));
1119 return DesktopWindow;
1120}
1121//******************************************************************************
1122//******************************************************************************
1123HWND WIN32API FindWindowA(LPCSTR lpszClass, LPCSTR lpszWindow)
1124{
1125 return FindWindowExA( NULL, NULL, lpszClass, lpszWindow );
1126}
1127//******************************************************************************
1128//******************************************************************************
1129HWND WIN32API FindWindowW( LPCWSTR lpClassName, LPCWSTR lpWindowName)
1130{
1131 return FindWindowExW( NULL, NULL, lpClassName, lpWindowName );
1132}
1133//******************************************************************************
1134//******************************************************************************
1135HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow)
1136{
1137 ATOM atom = 0;
1138
1139 if (lpszClass)
1140 {
1141 /* If the atom doesn't exist, then no class */
1142 /* with this name exists either. */
1143 if (!(atom = GlobalFindAtomA( lpszClass )))
1144 {
1145 SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
1146 return 0;
1147 }
1148 }
1149 return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, (LPSTR)lpszWindow);
1150}
1151/*****************************************************************************
1152 * Name : HWND WIN32API FindWindowExW
1153 * Purpose : The FindWindowEx function retrieves the handle of a window whose
1154 * class name and window name match the specified strings. The
1155 * function searches child windows, beginning with the one following
1156 * the given child window.
1157 * Parameters: HWND hwndParent handle of parent window
1158 * HWND hwndChildAfter handle of a child window
1159 * LPCTSTR lpszClass address of class name
1160 * LPCTSTR lpszWindow address of window name
1161 * Variables :
1162 * Result : If the function succeeds, the return value is the handle of the
1163 * window that has the specified class and window names.
1164 * If the function fails, the return value is NULL. To get extended
1165 * error information, call GetLastError.
1166 * Remark :
1167 *
1168 *****************************************************************************/
1169
1170HWND WIN32API FindWindowExW(HWND hwndParent,
1171 HWND hwndChildAfter,
1172 LPCWSTR lpszClass,
1173 LPCWSTR lpszWindow)
1174{
1175 ATOM atom = 0;
1176 char *buffer;
1177 HWND hwnd;
1178
1179 if (lpszClass)
1180 {
1181 /* If the atom doesn't exist, then no class */
1182 /* with this name exists either. */
1183 if (!(atom = GlobalFindAtomW( lpszClass )))
1184 {
1185 SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
1186 return 0;
1187 }
1188 }
1189 buffer = HEAP_strdupWtoA( GetProcessHeap(), 0, lpszWindow );
1190 hwnd = Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, buffer);
1191 HeapFree( GetProcessHeap(), 0, buffer );
1192 return hwnd;
1193}
1194//******************************************************************************
1195//******************************************************************************
1196BOOL WIN32API FlashWindow(HWND hwnd, BOOL fFlash)
1197{
1198 dprintf(("FlashWindow %x %d\n", hwnd, fFlash));
1199// return OSLibWinFlashWindow(Win32ToOS2Handle(hwnd), fFlash);
1200 return 1;
1201}
1202//******************************************************************************
1203//******************************************************************************
1204BOOL WIN32API MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
1205 BOOL repaint )
1206{
1207 int flags = SWP_NOZORDER | SWP_NOACTIVATE;
1208
1209 if (!repaint) flags |= SWP_NOREDRAW;
1210 dprintf(("MoveWindow: %x %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ));
1211
1212 return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
1213}
1214//******************************************************************************
1215//******************************************************************************
1216BOOL WIN32API ClientToScreen (HWND hwnd, PPOINT pt)
1217{
1218 Win32BaseWindow *wnd;
1219 PRECT rcl;
1220
1221 if (!hwnd) {
1222 SetLastError(ERROR_INVALID_PARAMETER);
1223 return (FALSE);
1224 }
1225 wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
1226 if (!wnd) {
1227 dprintf(("warning: ClientToScreen window %x not found!", hwnd));
1228 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1229 return (FALSE);
1230 }
1231#ifdef DEBUG
1232 POINT tmp = *pt;
1233#endif
1234 MapWindowPoints(hwnd, 0, pt, 1);
1235 dprintf2(("ClientToScreen %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
1236
1237 return TRUE;
1238}
1239//******************************************************************************
1240//Note: count 0 is a legal parameter (verified in NT4)
1241//******************************************************************************
1242HDWP WIN32API BeginDeferWindowPos(int count)
1243{
1244 HDWP handle;
1245 DWP *pDWP;
1246
1247 if (count < 0)
1248 {
1249 dprintf(("USER32: BeginDeferWindowPos invalid param %d", count));
1250 SetLastError(ERROR_INVALID_PARAMETER);
1251 return 0;
1252 }
1253 dprintf(("USER32: BeginDeferWindowPos %d", count));
1254 if(count == 0)
1255 count = 8; // change to any non-zero value
1256
1257 handle = (HDWP)HeapAlloc(GetProcessHeap(), 0, sizeof(DWP) + (count-1)*sizeof(WINDOWPOS));
1258 if (!handle)
1259 return 0;
1260
1261 pDWP = (DWP *) handle;
1262 pDWP->actualCount = 0;
1263 pDWP->suggestedCount = count;
1264 pDWP->valid = TRUE;
1265 pDWP->wMagic = DWP_MAGIC;
1266 pDWP->hwndParent = 0;
1267 return handle;
1268}
1269/***********************************************************************
1270 * DeferWindowPos (USER32.128)
1271 *
1272 * TODO: SvL: Does this need to be thread safe?
1273 *
1274 */
1275HDWP WIN32API DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
1276 INT x, INT y, INT cx, INT cy,
1277 UINT flags )
1278{
1279 DWP *pDWP;
1280 int i;
1281 HDWP newhdwp = hdwp,retvalue;
1282 Win32BaseWindow *window;
1283
1284 pDWP = (DWP *)hdwp;
1285 if (!pDWP) {
1286 SetLastError(ERROR_INVALID_PARAMETER);
1287 return 0;
1288 }
1289
1290 if (hwnd == GetDesktopWindow())
1291 return 0;
1292
1293 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1294 if(!window) {
1295 dprintf(("DeferWindowPos, window %x not found", hwnd));
1296 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1297 HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
1298 return 0;
1299 }
1300
1301 dprintf(("USER32: DeferWindowPos hdwp %x hwnd %x hwndAfter %x (%d,%d)(%d,%d) %x", hdwp, hwnd, hwndAfter,
1302 x, y, cx, cy, flags));
1303
1304/* Numega Bounds Checker Demo dislikes the following code.
1305 In fact, I've not been able to find any "same parent" requirement in any docu
1306 [AM 980509]
1307 */
1308#if 0
1309 /* All the windows of a DeferWindowPos() must have the same parent */
1310 parent = pWnd->parent->hwndSelf;
1311 if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
1312 else if (parent != pDWP->hwndParent)
1313 {
1314 USER_HEAP_FREE( hdwp );
1315 retvalue = 0;
1316 goto END;
1317 }
1318#endif
1319
1320 for (i = 0; i < pDWP->actualCount; i++)
1321 {
1322 if (pDWP->winPos[i].hwnd == hwnd)
1323 {
1324 /* Merge with the other changes */
1325 if (!(flags & SWP_NOZORDER))
1326 {
1327 pDWP->winPos[i].hwndInsertAfter = hwndAfter;
1328 }
1329 if (!(flags & SWP_NOMOVE))
1330 {
1331 pDWP->winPos[i].x = x;
1332 pDWP->winPos[i].y = y;
1333 }
1334 if (!(flags & SWP_NOSIZE))
1335 {
1336 pDWP->winPos[i].cx = cx;
1337 pDWP->winPos[i].cy = cy;
1338 }
1339 pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
1340 SWP_NOZORDER | SWP_NOREDRAW |
1341 SWP_NOACTIVATE | SWP_NOCOPYBITS|
1342 SWP_NOOWNERZORDER);
1343 pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
1344 SWP_FRAMECHANGED);
1345 retvalue = hdwp;
1346 goto END;
1347 }
1348 }
1349 if (pDWP->actualCount >= pDWP->suggestedCount)
1350 {
1351 //DWP structure already contains WINDOWPOS, allocated with (count-1)
1352 //in BeginDeferWindowPos; pDWP->suggestedCount alloc increases it by one
1353 newhdwp = (HDWP)HeapReAlloc(GetProcessHeap(), 0, (LPVOID)hdwp,
1354 sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS));
1355 if (!newhdwp)
1356 {
1357 retvalue = 0;
1358 goto END;
1359 }
1360 pDWP = (DWP *) newhdwp;
1361 pDWP->suggestedCount++;
1362 }
1363 pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
1364 pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
1365 pDWP->winPos[pDWP->actualCount].x = x;
1366 pDWP->winPos[pDWP->actualCount].y = y;
1367 pDWP->winPos[pDWP->actualCount].cx = cx;
1368 pDWP->winPos[pDWP->actualCount].cy = cy;
1369 pDWP->winPos[pDWP->actualCount].flags = flags;
1370 pDWP->actualCount++;
1371 retvalue = newhdwp;
1372END:
1373 return retvalue;
1374}
1375//******************************************************************************
1376//******************************************************************************
1377BOOL WIN32API EndDeferWindowPos( HDWP hdwp)
1378{
1379 DWP *pDWP;
1380 WINDOWPOS *winpos;
1381 BOOL res = TRUE;
1382 int i;
1383
1384 pDWP = (DWP *) hdwp;
1385 if (!pDWP) {
1386 dprintf(("**EndDeferWindowPos invalid parameter\n"));
1387 SetLastError(ERROR_INVALID_PARAMETER);
1388 return FALSE;
1389 }
1390 dprintf(("**EndDeferWindowPos for %d windows", pDWP->actualCount));
1391 for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
1392 {
1393 dprintf(("**EndDeferWindowPos %x (%d,%d) (%d,%d) %x", winpos->hwnd, winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags));
1394 if (!(res = SetWindowPos(winpos->hwnd, winpos->hwndInsertAfter,
1395 winpos->x, winpos->y, winpos->cx,
1396 winpos->cy, winpos->flags )))
1397 break;
1398 }
1399 dprintf(("**EndDeferWindowPos DONE"));
1400 HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
1401 return res;
1402}
1403//******************************************************************************
1404//******************************************************************************
1405HWND WIN32API ChildWindowFromPoint( HWND hwnd, POINT pt)
1406{
1407 dprintf(("USER32: ChildWindowFromPoint\n"));
1408 return ChildWindowFromPointEx(hwnd, pt, 0);
1409}
1410/*****************************************************************************
1411 * Name : HWND WIN32API ChildWindowFromPointEx
1412 * Purpose : pt: client coordinates
1413 * Parameters:
1414 * Variables :
1415 * Result : If the function succeeds, the return value is the window handle.
1416 * If the function fails, the return value is zero
1417 * Remark :
1418 * Status : COMPLETELY IMPLEMENTED AND TESTED
1419 *
1420 * Author : Rene Pronk [Sun, 1999/08/08 23:30]
1421 *****************************************************************************/
1422HWND WIN32API ChildWindowFromPointEx (HWND hwndParent, POINT pt, UINT uFlags)
1423{
1424 RECT rect;
1425 HWND hWnd;
1426
1427 dprintf(("ChildWindowFromPointEx(%08xh,%08xh,%08xh).\n",
1428 hwndParent, pt, uFlags));
1429
1430 if (GetWindowRect (hwndParent, &rect) == 0) {
1431 // oops, invalid handle
1432 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1433 return NULL;
1434 }
1435
1436 ClientToScreen(hwndParent, &pt);
1437 if (PtInRect (&rect, pt) == 0) {
1438 // point is outside window
1439 return NULL;
1440 }
1441
1442 // get first child
1443 hWnd = GetWindow (hwndParent, GW_CHILD);
1444
1445 while (hWnd != NULL)
1446 {
1447 // do I need to skip this window?
1448 if (((uFlags & CWP_SKIPINVISIBLE) &&
1449 (IsWindowVisible (hWnd) == FALSE)) ||
1450 ((uFlags & CWP_SKIPDISABLED) &&
1451 (IsWindowEnabled (hWnd) == FALSE)) ||
1452 ((uFlags & CWP_SKIPTRANSPARENT) &&
1453 (GetWindowLongA (hWnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
1454 {
1455 hWnd = GetWindow (hWnd, GW_HWNDNEXT);
1456 continue;
1457 }
1458
1459 // is the point in this window's rect?
1460 GetWindowRect (hWnd, &rect);
1461 if (PtInRect (&rect,pt) == FALSE) {
1462 hWnd = GetWindow (hWnd, GW_HWNDNEXT);
1463 continue;
1464 }
1465
1466 dprintf(("ChildWindowFromPointEx returned %x", hWnd));
1467 // found it!
1468 return hWnd;
1469 }
1470 // the point is in the parentwindow but the parentwindow has no child
1471 // at this coordinate
1472 dprintf(("ChildWindowFromPointEx returned parent %x", hwndParent));
1473 return hwndParent;
1474}
1475//******************************************************************************
1476//******************************************************************************
1477BOOL WIN32API CloseWindow(HWND hwnd)
1478{
1479 Win32BaseWindow *window;
1480
1481 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1482 if(!window) {
1483 dprintf(("CloseWindow, window %x not found", hwnd));
1484 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1485 return 0;
1486 }
1487 dprintf(("CloseWindow %x\n", hwnd));
1488 return window->CloseWindow();
1489}
1490//******************************************************************************
1491//TODO: Does this return handles of hidden or disabled windows?
1492//******************************************************************************
1493HWND WIN32API WindowFromPoint( POINT point)
1494{
1495#if 0
1496 INT hittest = HTERROR;
1497 HWND retvalue = 0;
1498 HWND hwnd = GetDesktopWindow();
1499 DWORD dwStyle;
1500 RECT rectWindow, rectClient;
1501 Win32BaseWindow *window;
1502
1503 dprintf(("WindowFromPoint (%d,%d)", point.x, point.y));
1504
1505 while(hwnd)
1506 {
1507 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1508
1509 /* If point is in window, and window is visible, and it */
1510 /* is enabled (or it's a top-level window), then explore */
1511 /* its children. Otherwise, go to the next window. */
1512 dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
1513
1514 if ((dwStyle & WS_VISIBLE) && (!(dwStyle & WS_DISABLED) ||
1515 ((dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)))
1516 {
1517 GetWindowRect(hwnd, &rectWindow);
1518 if(PtInRect(&rectWindow, point) == TRUE)
1519 {
1520 /* If window is minimized or disabled, return at once */
1521 if(dwStyle & WS_MINIMIZE)
1522 {
1523 break;
1524 }
1525 if(dwStyle & WS_DISABLED)
1526 {
1527 break;
1528 }
1529 retvalue = hwnd;
1530
1531 GetClientRect(hwnd, &rectClient);
1532 InflateRect(&rectClient, rectWindow.left, rectWindow.top);
1533
1534 /* If point is not in client area, ignore the children */
1535 if(PtInRect(&rectClient, point) == FALSE) {
1536 break;
1537 }
1538 if(window->getFirstChild()) {
1539 hwnd = ((Win32BaseWindow *)window->getFirstChild())->getWindowHandle();
1540 }
1541 else break;
1542 }
1543 else
1544 {
1545 if(window->getNextChild()) {
1546 hwnd = ((Win32BaseWindow *)window->getNextChild())->getWindowHandle();
1547 }
1548 else hwnd = 0;
1549 }
1550 }
1551 else
1552 {
1553 if(window->getNextChild()) {
1554 hwnd = ((Win32BaseWindow *)window->getNextChild())->getWindowHandle();
1555 }
1556 else hwnd = 0;
1557 }
1558 }
1559
1560 dprintf(("WindowFromPoint (%d,%d) -> %x", point.x, point.y, hwnd));
1561 return retvalue;
1562#else
1563 HWND hwndOS2, hwnd;
1564 POINT wPoint;
1565
1566 wPoint.x = point.x;
1567 wPoint.y = mapScreenY(point.y);
1568
1569 hwndOS2 = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&wPoint);
1570 if(hwndOS2)
1571 {
1572 hwnd = OS2ToWin32Handle(hwndOS2);
1573 if(hwnd) {
1574 dprintf(("WindowFromPoint (%d,%d) %x->%x\n", point.x, point.y, hwndOS2, hwnd));
1575 return hwnd;
1576 }
1577 }
1578 dprintf(("WindowFromPoint (%d,%d) %x->1\n", point.x, point.y, hwndOS2));
1579 return windowDesktop->getWindowHandle();
1580#endif
1581}
1582//******************************************************************************
1583//******************************************************************************
1584BOOL WIN32API IsWindowUnicode(HWND hwnd)
1585{
1586 Win32BaseWindow *window;
1587
1588 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1589 if(!window) {
1590 dprintf(("IsWindowUnicode, window %x not found", hwnd));
1591 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1592 return 0;
1593 }
1594 return window->IsWindowUnicode();
1595}
1596/***********************************************************************
1597 * SwitchToThisWindow (USER32.539)
1598 */
1599DWORD WINAPI SwitchToThisWindow( HWND hwnd, BOOL restore )
1600{
1601 return ShowWindow( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED );
1602}
1603//******************************************************************************
1604//******************************************************************************
1605BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
1606{
1607 return windowDesktop->EnumThreadWindows(dwThreadId, lpfn, lParam);
1608}
1609//******************************************************************************
1610//******************************************************************************
1611BOOL WIN32API EnumChildWindows(HWND hwnd, WNDENUMPROC lpfn, LPARAM lParam)
1612{
1613 Win32BaseWindow *window;
1614 BOOL rc = TRUE;
1615 ULONG henum;
1616 HWND hwndNext;
1617
1618 if(lpfn == NULL) {
1619 dprintf(("EnumChildWindows invalid parameter %x %x\n", hwnd, lParam));
1620 SetLastError(ERROR_INVALID_PARAMETER);
1621 return FALSE;
1622 }
1623 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1624 if(!window) {
1625 dprintf(("EnumChildWindows, window %x not found", hwnd));
1626 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1627 return FALSE;
1628 }
1629 return window->EnumChildWindows(lpfn, lParam);
1630}
1631//******************************************************************************
1632//******************************************************************************
1633BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
1634{
1635 return windowDesktop->EnumWindows(lpfn, lParam);
1636}
1637//******************************************************************************
1638//******************************************************************************
1639UINT WIN32API ArrangeIconicWindows( HWND hwnd)
1640{
1641 dprintf(("USER32: ArrangeIconicWindows %x", hwnd));
1642 return O32_ArrangeIconicWindows(Win32ToOS2Handle(hwnd));
1643}
1644//******************************************************************************
1645//restores iconized window to previous size/position
1646//******************************************************************************
1647BOOL WIN32API OpenIcon(HWND hwnd)
1648{
1649 dprintf(("USER32: OpenIcon %x", hwnd));
1650
1651 if(!IsIconic(hwnd))
1652 return FALSE;
1653 ShowWindow(hwnd, SW_SHOWNORMAL);
1654 return TRUE;
1655}
1656//******************************************************************************
1657//SDK: Windows can only be shown with ShowOwnedPopups if they were previously
1658// hidden with the same api
1659//TODO: -> needs testing
1660//******************************************************************************
1661BOOL WIN32API ShowOwnedPopups(HWND hwndOwner, BOOL fShow)
1662{
1663 Win32BaseWindow *window, *owner;
1664 HWND hwnd;
1665
1666 owner = Win32BaseWindow::GetWindowFromHandle(hwndOwner);
1667 if(!owner) {
1668 dprintf(("ShowOwnedPopups, window %x not found", hwndOwner));
1669 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1670 return FALSE;
1671 }
1672 dprintf(("USER32: ShowOwnedPopups %x %d", hwnd, fShow));
1673
1674 hwnd = GetWindow(GetDesktopWindow(), GW_CHILD);
1675 while(hwnd) {
1676 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1677 if(window) {
1678 if(window == owner && (window->getStyle() & WS_POPUP))
1679 {
1680 if(fShow) {
1681 if(window->getFlags() & WIN_NEEDS_SHOW_OWNEDPOPUP)
1682 {
1683 /*
1684 * In Windows, ShowOwnedPopups(TRUE) generates WM_SHOWWINDOW messages with SW_PARENTOPENING,
1685 * regardless of the state of the owner
1686 */
1687 SendMessageA(hwnd, WM_SHOWWINDOW, SW_SHOW, SW_PARENTOPENING);
1688 window->setFlags(window->getFlags() & ~WIN_NEEDS_SHOW_OWNEDPOPUP);
1689 }
1690 }
1691 else
1692 {
1693 if(IsWindowVisible(hwnd))
1694 {
1695 /*
1696 * In Windows, ShowOwnedPopups(FALSE) generates WM_SHOWWINDOW messages with SW_PARENTCLOSING,
1697 * regardless of the state of the owner
1698 */
1699 SendMessageA(hwnd, WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
1700 window->setFlags(window->getFlags() | WIN_NEEDS_SHOW_OWNEDPOPUP);
1701 }
1702 }
1703 }
1704 }
1705 else dprintf(("WARNING: window %x is not valid", hwnd));
1706
1707 hwnd = GetWindow(hwnd, GW_HWNDNEXT);
1708 }
1709 return TRUE;
1710}
1711//******************************************************************************
1712//******************************************************************************
1713HWND WIN32API GetForegroundWindow(void)
1714{
1715 HWND hwnd;
1716
1717 hwnd = OS2ToWin32Handle(OSLibWinQueryActiveWindow());
1718 dprintf(("USER32: GetForegroundWindow returned %x", hwnd));
1719 return hwnd;
1720}
1721//******************************************************************************
1722//******************************************************************************
1723HWND WIN32API GetLastActivePopup( HWND hWnd)
1724{
1725 HWND hwnd;
1726
1727 hwnd = Win32ToOS2Handle(hWnd);
1728 hwnd = OS2ToWin32Handle(O32_GetLastActivePopup(hwnd));
1729
1730 dprintf(("GetLastActivePopup %x returned %x NOT CORRECTLY IMPLEMENTED", hWnd, hwnd));
1731 return hwnd;
1732}
1733//******************************************************************************
1734//******************************************************************************
1735DWORD WIN32API GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
1736{
1737 dprintf2(("USER32: GetWindowThreadProcessId"));
1738 hWnd = Win32ToOS2Handle(hWnd);
1739
1740 return O32_GetWindowThreadProcessId(hWnd,lpdwProcessId);
1741}
1742//******************************************************************************
1743//******************************************************************************
1744DWORD WIN32API GetWindowContextHelpId(HWND hwnd)
1745{
1746 Win32BaseWindow *window;
1747
1748 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1749 if(!window) {
1750 dprintf(("GetWindowContextHelpId, window %x not found", hwnd));
1751 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1752 return 0;
1753 }
1754 dprintf(("GetWindowContextHelpId %x", hwnd));
1755 return window->getWindowContextHelpId();
1756}
1757//******************************************************************************
1758//******************************************************************************
1759BOOL WIN32API SetWindowContextHelpId(HWND hwnd, DWORD dwContextHelpId)
1760{
1761 Win32BaseWindow *window;
1762
1763 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1764 if(!window) {
1765 dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
1766 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1767 return 0;
1768 }
1769 dprintf(("SetWindowContextHelpId %x %d", hwnd, dwContextHelpId));
1770 window->setWindowContextHelpId(dwContextHelpId);
1771 return(TRUE);
1772}
1773//******************************************************************************
1774//******************************************************************************
1775HANDLE WINAPI GetPropA( HWND hwnd, LPCSTR str )
1776{
1777 Win32BaseWindow *window;
1778
1779 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1780 if(!window) {
1781 dprintf(("GetPropA, window %x not found", hwnd));
1782 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1783 return 0;
1784 }
1785 return window->getProp(str);
1786}
1787//******************************************************************************
1788//******************************************************************************
1789HANDLE WINAPI GetPropW( HWND hwnd, LPCWSTR str )
1790{
1791 LPSTR strA;
1792 HANDLE ret;
1793
1794 if (!HIWORD(str)) return GetPropA( hwnd, (LPCSTR)(UINT)LOWORD(str) );
1795 strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
1796 ret = GetPropA( hwnd, strA );
1797 HeapFree( GetProcessHeap(), 0, strA );
1798 return ret;
1799}
1800//******************************************************************************
1801//******************************************************************************
1802BOOL WINAPI SetPropA( HWND hwnd, LPCSTR str, HANDLE handle )
1803{
1804 Win32BaseWindow *window;
1805
1806 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1807 if(!window) {
1808 dprintf(("SetPropA, window %x not found", hwnd));
1809 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1810 return FALSE;
1811 }
1812 return window->setProp(str, handle);
1813}
1814//******************************************************************************
1815//******************************************************************************
1816BOOL WINAPI SetPropW( HWND hwnd, LPCWSTR str, HANDLE handle )
1817{
1818 BOOL ret;
1819 LPSTR strA;
1820
1821 if (!HIWORD(str))
1822 return SetPropA( hwnd, (LPCSTR)(UINT)LOWORD(str), handle );
1823 strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
1824 ret = SetPropA( hwnd, strA, handle );
1825 HeapFree( GetProcessHeap(), 0, strA );
1826 return ret;
1827}
1828//******************************************************************************
1829//******************************************************************************
1830HANDLE WINAPI RemovePropA( HWND hwnd, LPCSTR str )
1831{
1832 Win32BaseWindow *window;
1833
1834 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1835 if(!window) {
1836 dprintf(("RemovePropA, window %x not found", hwnd));
1837 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1838 return 0;
1839 }
1840 return window->removeProp(str);
1841}
1842//******************************************************************************
1843//******************************************************************************
1844HANDLE WINAPI RemovePropW( HWND hwnd, LPCWSTR str )
1845{
1846 LPSTR strA;
1847 HANDLE ret;
1848
1849 if (!HIWORD(str))
1850 return RemovePropA( hwnd, (LPCSTR)(UINT)LOWORD(str) );
1851 strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
1852 ret = RemovePropA( hwnd, strA );
1853 HeapFree( GetProcessHeap(), 0, strA );
1854 return ret;
1855}
1856//******************************************************************************
1857//******************************************************************************
1858INT WINAPI EnumPropsA( HWND hwnd, PROPENUMPROCA func )
1859{
1860 return EnumPropsExA( hwnd, (PROPENUMPROCEXA)func, 0 );
1861}
1862//******************************************************************************
1863//******************************************************************************
1864INT WINAPI EnumPropsW( HWND hwnd, PROPENUMPROCW func )
1865{
1866 return EnumPropsExW( hwnd, (PROPENUMPROCEXW)func, 0 );
1867}
1868//******************************************************************************
1869//******************************************************************************
1870INT WINAPI EnumPropsExA(HWND hwnd, PROPENUMPROCEXA func, LPARAM lParam)
1871{
1872 Win32BaseWindow *window;
1873
1874 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1875 if(!window) {
1876 dprintf(("EnumPropsExA, window %x not found", hwnd));
1877 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1878 return -1;
1879 }
1880 return window->enumPropsExA(func, lParam);
1881}
1882//******************************************************************************
1883//******************************************************************************
1884INT WINAPI EnumPropsExW(HWND hwnd, PROPENUMPROCEXW func, LPARAM lParam)
1885{
1886 Win32BaseWindow *window;
1887
1888 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1889 if(!window) {
1890 dprintf(("EnumPropsExA, window %x not found", hwnd));
1891 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1892 return -1;
1893 }
1894 return window->enumPropsExW(func, lParam);
1895}
1896//******************************************************************************
1897//******************************************************************************
Note: See TracBrowser for help on using the repository browser.