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

Last change on this file since 5496 was 5496, checked in by sandervl, 24 years ago

Sofiya: DBCS fixes

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