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

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

client/frame rewrite

File size: 68.0 KB
Line 
1/* $Id: window.cpp,v 1.95 2001-05-11 08:39:46 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 DWORD dwStyle;
656
657 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
658 if(!window) {
659 dprintf(("IsWindowEnabled, window %x not found", hwnd));
660 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
661 return 0;
662 }
663 dprintf(("IsWindowEnabled %x", hwnd));
664 dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
665 if(dwStyle & WS_DISABLED) {
666 return FALSE;
667 }
668 return TRUE;
669}
670//******************************************************************************
671//******************************************************************************
672BOOL WIN32API IsWindowVisible(HWND hwnd)
673{
674 Win32BaseWindow *window;
675 BOOL ret;
676 HWND hwndParent;
677 DWORD dwStyle;
678
679 if(!hwnd) {//TODO: verify in NT!
680 dprintf(("IsWindowVisible DESKTOP returned TRUE"));
681 return TRUE; //desktop is always visible
682 }
683 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
684
685 if(!window) {
686 dprintf(("IsWindowVisible, window %x not found", hwnd));
687 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
688 return 0;
689 }
690 //check visibility of this window
691 dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
692 if(!(dwStyle & WS_VISIBLE)) {
693 ret = FALSE;
694 goto end;
695 }
696 ret = TRUE;
697
698 //check visibility of parents
699 hwndParent = GetParent(hwnd);
700 while(hwndParent) {
701 dwStyle = GetWindowLongA(hwndParent, GWL_STYLE);
702 if(!(dwStyle & WS_VISIBLE)) {
703 dprintf(("IsWindowVisible %x returned FALSE (parent %x invisible)", hwnd, hwndParent));
704 return FALSE;
705 }
706 hwndParent = GetParent(hwndParent);
707 }
708
709end:
710 dprintf(("IsWindowVisible %x returned %d", hwnd, ret));
711 return ret;
712}
713//******************************************************************************
714//******************************************************************************
715HWND WIN32API SetFocus(HWND hwnd)
716{
717 HWND lastFocus, lastFocus_W, hwnd_O;
718 BOOL activate;
719 TEB *teb;
720
721 teb = GetThreadTEB();
722 if(teb == NULL) {
723 DebugInt3();
724 return 0;
725 }
726
727 hwnd_O = Win32ToOS2Handle (hwnd);
728 lastFocus = OSLibWinQueryFocus (OSLIB_HWND_DESKTOP);
729 activate = ((hwnd_O == lastFocus) || OSLibWinIsChild (lastFocus, hwnd_O));
730 lastFocus_W = OS2ToWin32Handle (lastFocus);
731
732 dprintf(("SetFocus %x (%x) -> %x (%x)\n", lastFocus_W, lastFocus, hwnd, hwnd_O));
733
734 //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
735 //must delay this function call
736 if(teb->o.odin.fWM_SETFOCUS) {
737 dprintf(("USER32: Delay SetFocus call!"));
738 teb->o.odin.hwndFocus = hwnd;
739 //mp1 = win32 window handle
740 //mp2 = activate flag
741 OSLibPostMessageDirect(hwnd_O, WIN32APP_SETFOCUSMSG, hwnd, activate);
742 return lastFocus_W;
743 }
744 return (OSLibWinSetFocus (OSLIB_HWND_DESKTOP, hwnd_O, activate)) ? lastFocus_W : 0;
745}
746//******************************************************************************
747//******************************************************************************
748HWND WIN32API GetFocus(void)
749{
750 TEB *teb;
751 HWND hwnd;
752
753 teb = GetThreadTEB();
754 if(teb == NULL) {
755 DebugInt3();
756 return 0;
757 }
758 //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
759 //If focus was changed during WM_SETFOCUS, the focus window handle is
760 //stored in teb->o.odin.hwndFocus (set back to 0 when delayed SetFocus
761 //is activated)
762 if(teb->o.odin.hwndFocus) {
763 dprintf(("USER32: GetFocus %x (DURING WM_SETFOCUS PROCESSING)", teb->o.odin.hwndFocus));
764 return teb->o.odin.hwndFocus;
765 }
766
767 hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP);
768 hwnd = OS2ToWin32Handle(hwnd);
769 dprintf(("USER32: GetFocus %x\n", hwnd));
770 return hwnd;
771}
772//******************************************************************************
773//******************************************************************************
774BOOL WIN32API IsZoomed(HWND hwnd)
775{
776 DWORD style;
777
778 style = GetWindowLongA(hwnd, GWL_STYLE);
779 dprintf(("USER32: IsZoomed %x returned %d", hwnd, ((style & WS_MAXIMIZE) != 0)));
780
781 return (style & WS_MAXIMIZE) != 0;
782}
783//******************************************************************************
784//******************************************************************************
785BOOL WIN32API LockWindowUpdate(HWND hwnd)
786{
787 dprintf(("USER32: LockWindowUpdate %x", hwnd));
788 return OSLibWinLockWindowUpdate(Win32ToOS2Handle(hwnd));
789}
790//******************************************************************************
791//******************************************************************************
792BOOL WIN32API GetWindowRect( HWND hwnd, PRECT pRect)
793{
794 Win32BaseWindow *window;
795
796 if (hwnd)
797 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
798 else
799 window = windowDesktop;
800
801 if(!window) {
802 dprintf(("GetWindowRect, window %x not found", hwnd));
803 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
804 return FALSE;
805 }
806 if(pRect == NULL) {
807 SetLastError(ERROR_INVALID_PARAMETER);
808 return FALSE;
809 }
810 *pRect = *window->getWindowRect();
811
812 //convert from parent coordinates to screen (if necessary)
813 if(window->getParent()) {
814 MapWindowPoints(window->getParent()->getWindowHandle(), 0, (PPOINT)pRect, 2);
815 }
816
817 dprintf(("GetWindowRect %x (%d,%d) (%d,%d)", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
818 return TRUE;
819}
820//******************************************************************************
821//******************************************************************************
822int WIN32API GetWindowTextLengthA( HWND hwnd)
823{
824 Win32BaseWindow *window;
825
826 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
827 if(!window) {
828 dprintf(("GetWindowTextLengthA, window %x not found", hwnd));
829 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
830 return 0;
831 }
832 dprintf(("GetWindowTextLengthA %x", hwnd));
833 return window->GetWindowTextLengthA();
834}
835//******************************************************************************
836//******************************************************************************
837int WIN32API GetWindowTextA( HWND hwnd, LPSTR lpsz, int cch)
838{
839 Win32BaseWindow *window;
840 int rc;
841
842 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
843 if(!window) {
844 dprintf(("GetWindowTextA, window %x not found", hwnd));
845 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
846 return 0;
847 }
848 rc = window->GetWindowTextA(lpsz, cch);
849 dprintf(("GetWindowTextA %x %s", hwnd, lpsz));
850 return rc;
851}
852//******************************************************************************
853//******************************************************************************
854int WIN32API GetWindowTextLengthW( HWND hwnd)
855{
856 Win32BaseWindow *window;
857
858 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
859 if(!window) {
860 dprintf(("GetWindowTextLengthW, window %x not found", hwnd));
861 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
862 return 0;
863 }
864 dprintf(("GetWindowTextLengthW %x", hwnd));
865 return window->GetWindowTextLengthW();
866}
867//******************************************************************************
868//******************************************************************************
869int WIN32API GetWindowTextW(HWND hwnd, LPWSTR lpsz, int cch)
870{
871 Win32BaseWindow *window;
872
873 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
874 if(!window) {
875 dprintf(("GetWindowTextW, window %x not found", hwnd));
876 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
877 return 0;
878 }
879#ifdef DEBUG
880 int rc = window->GetWindowTextW(lpsz, cch);
881 dprintf(("GetWindowTextW %x %ls", hwnd, lpsz));
882 return rc;
883#else
884 return window->GetWindowTextW(lpsz, cch);
885#endif
886}
887//******************************************************************************
888//******************************************************************************
889BOOL WIN32API SetWindowTextA(HWND hwnd, LPCSTR lpsz)
890{
891 Win32BaseWindow *window;
892
893 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
894 if(!window) {
895 dprintf(("SetWindowTextA, window %x not found", hwnd));
896 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
897 return 0;
898 }
899 dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
900 return window->SetWindowTextA((LPSTR)lpsz);
901}
902//******************************************************************************
903//******************************************************************************
904BOOL WIN32API SetWindowTextW( HWND hwnd, LPCWSTR lpsz)
905{
906 Win32BaseWindow *window;
907
908 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
909 if(!window) {
910 dprintf(("SetWindowTextA, window %x not found", hwnd));
911 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
912 return 0;
913 }
914 dprintf(("SetWindowTextW %x %ls", hwnd, lpsz));
915 return window->SetWindowTextW((LPWSTR)lpsz);
916}
917/*******************************************************************
918 * InternalGetWindowText (USER32.326)
919 */
920int WIN32API InternalGetWindowText(HWND hwnd,
921 LPWSTR lpString,
922 INT nMaxCount )
923{
924 dprintf(("USER32: InternalGetWindowText(%08xh,%08xh,%08xh) not properly implemented.\n",
925 hwnd,
926 lpString,
927 nMaxCount));
928
929 return GetWindowTextW(hwnd,lpString,nMaxCount);
930}
931//******************************************************************************
932//TODO: Correct?
933//******************************************************************************
934BOOL WIN32API SetForegroundWindow(HWND hwnd)
935{
936 dprintf((" SetForegroundWindow %x", hwnd));
937
938 return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
939}
940//******************************************************************************
941//******************************************************************************
942BOOL WIN32API GetClientRect( HWND hwnd, PRECT pRect)
943{
944 HWND hwndWin32 = hwnd;
945 Win32BaseWindow *window;
946
947 if (!pRect)
948 {
949 SetLastError(ERROR_INVALID_PARAMETER);
950 return FALSE;
951 }
952 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
953 if(!window) {
954 dprintf(("GetClientRect, window %x not found", hwnd));
955 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
956 return FALSE;
957 }
958 window->getClientRect(pRect);
959 dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom));
960 return TRUE;
961}
962//******************************************************************************
963//******************************************************************************
964BOOL WIN32API AdjustWindowRect(PRECT rect, DWORD style, BOOL menu)
965{
966 return AdjustWindowRectEx(rect, style, menu, 0);
967}
968//******************************************************************************
969//Calculate window rectangle based on given client rectangle, style, menu and extended style
970//******************************************************************************
971BOOL WIN32API AdjustWindowRectEx( PRECT rect, DWORD style, BOOL menu, DWORD exStyle)
972{
973 if(style == 0 && menu == FALSE && exStyle == 0) {
974 dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d) -> no change required", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
975 return TRUE; //nothing needs to be changed (VERIFIED in NT 4)
976 }
977 dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d)\n", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
978 /* Correct the window style */
979 if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */
980 style |= WS_CAPTION;
981
982 //SvL: Include WS_POPUP -> otherwise HAS_THINFRAME is true for popup windows
983 // Also include WS_CHILD -> otherwise HAS_THICKFRAME doesn't work correctly
984 style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_POPUP);
985 exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
986 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME;
987
988 //Adjust rect outer (Win32BaseWindow::AdjustRectOuter)
989 if (HAS_THICKFRAME(style,exStyle))
990 InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
991 else
992 if (HAS_DLGFRAME(style,exStyle))
993 InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
994 else
995 if (HAS_THINFRAME(style))
996 InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
997
998 if ((style & WS_CAPTION) == WS_CAPTION)
999 {
1000 if (exStyle & WS_EX_TOOLWINDOW)
1001 rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
1002 else
1003 rect->top -= GetSystemMetrics(SM_CYCAPTION);
1004 }
1005
1006 if (menu)
1007 rect->top -= GetSystemMetrics(SM_CYMENU);
1008
1009 //Adjust rect inner (Win32BaseWindow::AdjustRectInner)
1010 if(!(style & WS_ICONIC)) {
1011 if (exStyle & WS_EX_CLIENTEDGE)
1012 InflateRect (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
1013
1014 if (exStyle & WS_EX_STATICEDGE)
1015 InflateRect (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
1016
1017 //SvL: scrollbars aren't checked *UNLESS* the style includes a border (any border)
1018 // --> VERIFIED IN NT4, SP6 (fixes MFC apps with scrollbars + bar controls)
1019 if(style & (WS_THICKFRAME|WS_BORDER|WS_DLGFRAME)) {
1020 if (style & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
1021 if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
1022 }
1023 }
1024
1025 dprintf(("AdjustWindowRectEx returned (%d,%d)(%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom));
1026
1027 return TRUE;
1028}
1029//******************************************************************************
1030/* Coordinate Space and Transformation Functions */
1031//******************************************************************************
1032/*******************************************************************
1033 * WINPOS_GetWinOffset
1034 *
1035 * Calculate the offset between the origin of the two windows. Used
1036 * to implement MapWindowPoints.
1037 */
1038static void WINPOS_GetWinOffset( Win32BaseWindow *wndFrom, Win32BaseWindow *wndTo,
1039 POINT *offset )
1040{
1041 Win32BaseWindow *window;
1042
1043 offset->x = offset->y = 0;
1044
1045 /* Translate source window origin to screen coords */
1046 if(wndFrom != windowDesktop)
1047 {
1048 window = wndFrom;
1049 while(window)
1050 {
1051 offset->x += window->getClientRectPtr()->left + window->getWindowRect()->left;
1052 offset->y += window->getClientRectPtr()->top + window->getWindowRect()->top;
1053 window = window->getParent();
1054 }
1055 }
1056
1057 /* Translate origin to destination window coords */
1058 if(wndTo != windowDesktop)
1059 {
1060 window = wndTo;
1061 while(window)
1062 {
1063 offset->x -= window->getClientRectPtr()->left + window->getWindowRect()->left;
1064 offset->y -= window->getClientRectPtr()->top + window->getWindowRect()->top;
1065 window = window->getParent();
1066 }
1067 }
1068}
1069//******************************************************************************
1070//******************************************************************************
1071int WIN32API MapWindowPoints(HWND hwndFrom, HWND hwndTo, LPPOINT lpPoints,
1072 UINT cPoints)
1073{
1074 Win32BaseWindow *wndfrom, *wndto;
1075 int retval = 0;
1076 POINT offset;
1077
1078 SetLastError(0);
1079 if(lpPoints == NULL || cPoints == 0) {
1080 SetLastError(ERROR_INVALID_PARAMETER);
1081 return 0;
1082 }
1083 if(hwndFrom)
1084 {
1085 wndfrom = Win32BaseWindow::GetWindowFromHandle(hwndFrom);
1086 if(!wndfrom) {
1087 dprintf(("MapWindowPoints, window %x not found", hwndFrom));
1088 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1089 return 0;
1090 }
1091 }
1092 else wndfrom = windowDesktop;
1093
1094 if(hwndTo)
1095 {
1096 wndto = Win32BaseWindow::GetWindowFromHandle(hwndTo);
1097 if(!wndto) {
1098 dprintf(("MapWindowPoints, window %x not found", hwndTo));
1099 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1100 return 0;
1101 }
1102 }
1103 else wndto = windowDesktop;
1104
1105 if(wndto == wndfrom)
1106 return 0; //nothing to do
1107
1108 dprintf2(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
1109 WINPOS_GetWinOffset(wndfrom, wndto, &offset);
1110
1111 for(int i=0;i<cPoints;i++)
1112 {
1113 lpPoints[i].x += offset.x;
1114 lpPoints[i].y += offset.y;
1115 }
1116 retval = ((LONG)offset.y << 16) | offset.x;
1117 return retval;
1118}
1119//******************************************************************************
1120//******************************************************************************
1121BOOL WIN32API ScreenToClient(HWND hwnd, LPPOINT pt)
1122{
1123 Win32BaseWindow *wnd;
1124 PRECT rcl;
1125 BOOL rc;
1126
1127 if(!hwnd) {
1128 return (TRUE);
1129 }
1130 wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
1131 if (!wnd) {
1132 dprintf(("warning: ScreenToClient: window %x not found!", hwnd));
1133 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1134 return FALSE;
1135 }
1136 SetLastError(0);
1137#ifdef DEBUG
1138 POINT tmp = *pt;
1139#endif
1140 MapWindowPoints(0, hwnd, pt, 1);
1141 dprintf2(("ScreenToClient %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
1142 return TRUE;
1143}
1144//******************************************************************************
1145//******************************************************************************
1146HWND WIN32API GetDesktopWindow(void)
1147{
1148 HWND DesktopWindow = windowDesktop->getWindowHandle();
1149 dprintf2(("USER32: GetDesktopWindow, returned %x\n", DesktopWindow));
1150 return DesktopWindow;
1151}
1152//******************************************************************************
1153//******************************************************************************
1154HWND WIN32API FindWindowA(LPCSTR lpszClass, LPCSTR lpszWindow)
1155{
1156 return FindWindowExA( NULL, NULL, lpszClass, lpszWindow );
1157}
1158//******************************************************************************
1159//******************************************************************************
1160HWND WIN32API FindWindowW( LPCWSTR lpClassName, LPCWSTR lpWindowName)
1161{
1162 return FindWindowExW( NULL, NULL, lpClassName, lpWindowName );
1163}
1164//******************************************************************************
1165//******************************************************************************
1166HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow)
1167{
1168 ATOM atom = 0;
1169
1170 if (lpszClass)
1171 {
1172 /* If the atom doesn't exist, then no class */
1173 /* with this name exists either. */
1174 if (!(atom = GlobalFindAtomA( lpszClass )))
1175 {
1176 SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
1177 return 0;
1178 }
1179 }
1180 return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, (LPSTR)lpszWindow);
1181}
1182/*****************************************************************************
1183 * Name : HWND WIN32API FindWindowExW
1184 * Purpose : The FindWindowEx function retrieves the handle of a window whose
1185 * class name and window name match the specified strings. The
1186 * function searches child windows, beginning with the one following
1187 * the given child window.
1188 * Parameters: HWND hwndParent handle of parent window
1189 * HWND hwndChildAfter handle of a child window
1190 * LPCTSTR lpszClass address of class name
1191 * LPCTSTR lpszWindow address of window name
1192 * Variables :
1193 * Result : If the function succeeds, the return value is the handle of the
1194 * window that has the specified class and window names.
1195 * If the function fails, the return value is NULL. To get extended
1196 * error information, call GetLastError.
1197 * Remark :
1198 *
1199 *****************************************************************************/
1200
1201HWND WIN32API FindWindowExW(HWND hwndParent,
1202 HWND hwndChildAfter,
1203 LPCWSTR lpszClass,
1204 LPCWSTR lpszWindow)
1205{
1206 ATOM atom = 0;
1207 char *buffer;
1208 HWND hwnd;
1209
1210 if (lpszClass)
1211 {
1212 /* If the atom doesn't exist, then no class */
1213 /* with this name exists either. */
1214 if (!(atom = GlobalFindAtomW( lpszClass )))
1215 {
1216 SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
1217 return 0;
1218 }
1219 }
1220 buffer = HEAP_strdupWtoA( GetProcessHeap(), 0, lpszWindow );
1221 hwnd = Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, buffer);
1222 HeapFree( GetProcessHeap(), 0, buffer );
1223 return hwnd;
1224}
1225//******************************************************************************
1226//******************************************************************************
1227BOOL WIN32API FlashWindow(HWND hwnd, BOOL fFlash)
1228{
1229 dprintf(("FlashWindow %x %d\n", hwnd, fFlash));
1230// return OSLibWinFlashWindow(Win32ToOS2Handle(hwnd), fFlash);
1231 return 1;
1232}
1233//******************************************************************************
1234//******************************************************************************
1235BOOL WIN32API MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
1236 BOOL repaint )
1237{
1238 int flags = SWP_NOZORDER | SWP_NOACTIVATE;
1239
1240 if (!repaint) flags |= SWP_NOREDRAW;
1241 dprintf(("MoveWindow: %x %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ));
1242
1243 return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
1244}
1245//******************************************************************************
1246//******************************************************************************
1247BOOL WIN32API ClientToScreen (HWND hwnd, PPOINT pt)
1248{
1249 Win32BaseWindow *wnd;
1250 PRECT rcl;
1251
1252 if (!hwnd) {
1253 SetLastError(ERROR_INVALID_PARAMETER);
1254 return (FALSE);
1255 }
1256 wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
1257 if (!wnd) {
1258 dprintf(("warning: ClientToScreen window %x not found!", hwnd));
1259 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1260 return (FALSE);
1261 }
1262#ifdef DEBUG
1263 POINT tmp = *pt;
1264#endif
1265 MapWindowPoints(hwnd, 0, pt, 1);
1266 dprintf2(("ClientToScreen %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
1267
1268 return TRUE;
1269}
1270//******************************************************************************
1271//Note: count 0 is a legal parameter (verified in NT4)
1272//******************************************************************************
1273HDWP WIN32API BeginDeferWindowPos(int count)
1274{
1275 HDWP handle;
1276 DWP *pDWP;
1277
1278 if (count < 0)
1279 {
1280 dprintf(("USER32: BeginDeferWindowPos invalid param %d", count));
1281 SetLastError(ERROR_INVALID_PARAMETER);
1282 return 0;
1283 }
1284 dprintf(("USER32: BeginDeferWindowPos %d", count));
1285 if(count == 0)
1286 count = 8; // change to any non-zero value
1287
1288 handle = (HDWP)HeapAlloc(GetProcessHeap(), 0, sizeof(DWP) + (count-1)*sizeof(WINDOWPOS));
1289 if (!handle)
1290 return 0;
1291
1292 pDWP = (DWP *) handle;
1293 pDWP->actualCount = 0;
1294 pDWP->suggestedCount = count;
1295 pDWP->valid = TRUE;
1296 pDWP->wMagic = DWP_MAGIC;
1297 pDWP->hwndParent = 0;
1298 return handle;
1299}
1300/***********************************************************************
1301 * DeferWindowPos (USER32.128)
1302 *
1303 * TODO: SvL: Does this need to be thread safe?
1304 *
1305 */
1306HDWP WIN32API DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
1307 INT x, INT y, INT cx, INT cy,
1308 UINT flags )
1309{
1310 DWP *pDWP;
1311 int i;
1312 HDWP newhdwp = hdwp,retvalue;
1313 Win32BaseWindow *window;
1314
1315 pDWP = (DWP *)hdwp;
1316 if (!pDWP) {
1317 SetLastError(ERROR_INVALID_PARAMETER);
1318 return 0;
1319 }
1320
1321 if (hwnd == GetDesktopWindow())
1322 return 0;
1323
1324 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1325 if(!window) {
1326 dprintf(("DeferWindowPos, window %x not found", hwnd));
1327 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1328 HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
1329 return 0;
1330 }
1331
1332 dprintf(("USER32: DeferWindowPos hdwp %x hwnd %x hwndAfter %x (%d,%d)(%d,%d) %x", hdwp, hwnd, hwndAfter,
1333 x, y, cx, cy, flags));
1334
1335/* Numega Bounds Checker Demo dislikes the following code.
1336 In fact, I've not been able to find any "same parent" requirement in any docu
1337 [AM 980509]
1338 */
1339#if 0
1340 /* All the windows of a DeferWindowPos() must have the same parent */
1341 parent = pWnd->parent->hwndSelf;
1342 if (pDWP->actualCount == 0) pDWP->hwndParent = parent;
1343 else if (parent != pDWP->hwndParent)
1344 {
1345 USER_HEAP_FREE( hdwp );
1346 retvalue = 0;
1347 goto END;
1348 }
1349#endif
1350
1351 for (i = 0; i < pDWP->actualCount; i++)
1352 {
1353 if (pDWP->winPos[i].hwnd == hwnd)
1354 {
1355 /* Merge with the other changes */
1356 if (!(flags & SWP_NOZORDER))
1357 {
1358 pDWP->winPos[i].hwndInsertAfter = hwndAfter;
1359 }
1360 if (!(flags & SWP_NOMOVE))
1361 {
1362 pDWP->winPos[i].x = x;
1363 pDWP->winPos[i].y = y;
1364 }
1365 if (!(flags & SWP_NOSIZE))
1366 {
1367 pDWP->winPos[i].cx = cx;
1368 pDWP->winPos[i].cy = cy;
1369 }
1370 pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE |
1371 SWP_NOZORDER | SWP_NOREDRAW |
1372 SWP_NOACTIVATE | SWP_NOCOPYBITS|
1373 SWP_NOOWNERZORDER);
1374 pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW |
1375 SWP_FRAMECHANGED);
1376 retvalue = hdwp;
1377 goto END;
1378 }
1379 }
1380 if (pDWP->actualCount >= pDWP->suggestedCount)
1381 {
1382 //DWP structure already contains WINDOWPOS, allocated with (count-1)
1383 //in BeginDeferWindowPos; pDWP->suggestedCount alloc increases it by one
1384 newhdwp = (HDWP)HeapReAlloc(GetProcessHeap(), 0, (LPVOID)hdwp,
1385 sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS));
1386 if (!newhdwp)
1387 {
1388 retvalue = 0;
1389 goto END;
1390 }
1391 pDWP = (DWP *) newhdwp;
1392 pDWP->suggestedCount++;
1393 }
1394 pDWP->winPos[pDWP->actualCount].hwnd = hwnd;
1395 pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter;
1396 pDWP->winPos[pDWP->actualCount].x = x;
1397 pDWP->winPos[pDWP->actualCount].y = y;
1398 pDWP->winPos[pDWP->actualCount].cx = cx;
1399 pDWP->winPos[pDWP->actualCount].cy = cy;
1400 pDWP->winPos[pDWP->actualCount].flags = flags;
1401 pDWP->actualCount++;
1402 retvalue = newhdwp;
1403END:
1404 return retvalue;
1405}
1406//******************************************************************************
1407//******************************************************************************
1408BOOL WIN32API EndDeferWindowPos( HDWP hdwp)
1409{
1410 DWP *pDWP;
1411 WINDOWPOS *winpos;
1412 BOOL res = TRUE;
1413 int i;
1414
1415 pDWP = (DWP *) hdwp;
1416 if (!pDWP) {
1417 dprintf(("**EndDeferWindowPos invalid parameter\n"));
1418 SetLastError(ERROR_INVALID_PARAMETER);
1419 return FALSE;
1420 }
1421 dprintf(("**EndDeferWindowPos for %d windows", pDWP->actualCount));
1422 for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
1423 {
1424 dprintf(("**EndDeferWindowPos %x (%d,%d) (%d,%d) %x", winpos->hwnd, winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags));
1425 if (!(res = SetWindowPos(winpos->hwnd, winpos->hwndInsertAfter,
1426 winpos->x, winpos->y, winpos->cx,
1427 winpos->cy, winpos->flags )))
1428 break;
1429 }
1430 dprintf(("**EndDeferWindowPos DONE"));
1431 HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp);
1432 return res;
1433}
1434//******************************************************************************
1435//******************************************************************************
1436HWND WIN32API ChildWindowFromPoint( HWND hwnd, POINT pt)
1437{
1438 dprintf(("USER32: ChildWindowFromPoint\n"));
1439 return ChildWindowFromPointEx(hwnd, pt, 0);
1440}
1441/*****************************************************************************
1442 * Name : HWND WIN32API ChildWindowFromPointEx
1443 * Purpose : pt: client coordinates
1444 * Parameters:
1445 * Variables :
1446 * Result : If the function succeeds, the return value is the window handle.
1447 * If the function fails, the return value is zero
1448 * Remark :
1449 * Status : COMPLETELY IMPLEMENTED AND TESTED
1450 *
1451 * Author : Rene Pronk [Sun, 1999/08/08 23:30]
1452 *****************************************************************************/
1453HWND WIN32API ChildWindowFromPointEx (HWND hwndParent, POINT pt, UINT uFlags)
1454{
1455 RECT rect;
1456 HWND hWnd;
1457
1458 dprintf(("ChildWindowFromPointEx(%08xh,%08xh,%08xh).\n",
1459 hwndParent, pt, uFlags));
1460
1461 if (GetWindowRect (hwndParent, &rect) == 0) {
1462 // oops, invalid handle
1463 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1464 return NULL;
1465 }
1466
1467 ClientToScreen(hwndParent, &pt);
1468 if (PtInRect (&rect, pt) == 0) {
1469 // point is outside window
1470 return NULL;
1471 }
1472
1473 // get first child
1474 hWnd = GetWindow (hwndParent, GW_CHILD);
1475
1476 while (hWnd != NULL)
1477 {
1478 // do I need to skip this window?
1479 if (((uFlags & CWP_SKIPINVISIBLE) &&
1480 (IsWindowVisible (hWnd) == FALSE)) ||
1481 ((uFlags & CWP_SKIPDISABLED) &&
1482 (IsWindowEnabled (hWnd) == FALSE)) ||
1483 ((uFlags & CWP_SKIPTRANSPARENT) &&
1484 (GetWindowLongA (hWnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
1485 {
1486 hWnd = GetWindow (hWnd, GW_HWNDNEXT);
1487 continue;
1488 }
1489
1490 // is the point in this window's rect?
1491 GetWindowRect (hWnd, &rect);
1492 if (PtInRect (&rect,pt) == FALSE) {
1493 hWnd = GetWindow (hWnd, GW_HWNDNEXT);
1494 continue;
1495 }
1496
1497 dprintf(("ChildWindowFromPointEx returned %x", hWnd));
1498 // found it!
1499 return hWnd;
1500 }
1501 // the point is in the parentwindow but the parentwindow has no child
1502 // at this coordinate
1503 dprintf(("ChildWindowFromPointEx returned parent %x", hwndParent));
1504 return hwndParent;
1505}
1506//******************************************************************************
1507//******************************************************************************
1508BOOL WIN32API CloseWindow(HWND hwnd)
1509{
1510 Win32BaseWindow *window;
1511
1512 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1513 if(!window) {
1514 dprintf(("CloseWindow, window %x not found", hwnd));
1515 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1516 return 0;
1517 }
1518 dprintf(("CloseWindow %x\n", hwnd));
1519 return window->CloseWindow();
1520}
1521//******************************************************************************
1522//******************************************************************************
1523static BOOL IsPointInWindow(HWND hwnd, POINT point)
1524{
1525 RECT rectWindow;
1526 DWORD hittest, dwStyle, dwExStyle;
1527
1528 dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
1529 dwExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
1530
1531 GetWindowRect(hwnd, &rectWindow);
1532
1533 /* If point is in window, and window is visible, and it */
1534 /* is enabled (or it's a top-level window), then explore */
1535 /* its children. Otherwise, go to the next window. */
1536
1537 if( (dwStyle & WS_VISIBLE) &&
1538 ((dwExStyle & (WS_EX_LAYERED | WS_EX_TRANSPARENT)) != (WS_EX_LAYERED | WS_EX_TRANSPARENT)) &&
1539 (!(dwStyle & WS_DISABLED) || ((dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)) &&
1540 ((point.x >= rectWindow.left) && (point.x < rectWindow.right) &&
1541 (point.y >= rectWindow.top) && (point.y < rectWindow.bottom))
1542#if 1
1543 )
1544#else
1545 &&
1546 (wndPtr->hrgnWnd ? PtInRegion(wndPtr->hrgnWnd, 1))
1547#endif
1548 {
1549 hittest = SendMessageA(hwnd, WM_NCHITTEST, 0, MAKELONG(point.x, point.y));
1550 if(hittest != HTTRANSPARENT) {
1551 return TRUE;
1552 }
1553 }
1554 return FALSE;
1555}
1556//******************************************************************************
1557//TODO: Does this return handles of hidden or disabled windows?
1558//******************************************************************************
1559HWND WIN32API WindowFromPoint( POINT point)
1560{
1561 HWND hwndOS2, hwnd;
1562 POINT wPoint;
1563
1564 wPoint.x = point.x;
1565 wPoint.y = mapScreenY(point.y);
1566
1567 hwndOS2 = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&wPoint);
1568 if(hwndOS2)
1569 {
1570 hwnd = OS2ToWin32Handle(hwndOS2);
1571 while(hwnd)
1572 {
1573 if(IsPointInWindow(hwnd, point)) {
1574 dprintf(("WindowFromPoint (%d,%d) %x->%x\n", point.x, point.y, hwndOS2, hwnd));
1575 return hwnd;
1576 }
1577 //try siblings
1578 HWND hwndSibling;
1579 HWND hwndParent = GetParent(hwnd);
1580
1581 if(hwndParent) {
1582 hwndSibling = GetWindow(hwndParent, GW_CHILD);
1583 while(hwndSibling) {
1584 if(hwndSibling != hwnd) {
1585 if(IsPointInWindow(hwndSibling, point)) {
1586 dprintf(("WindowFromPoint (%d,%d) %x->%x\n", point.x, point.y, hwndOS2, hwndSibling));
1587 return hwndSibling;
1588 }
1589 }
1590 hwndSibling = GetWindow(hwndSibling, GW_HWNDNEXT);
1591 }
1592 }
1593 hwnd = hwndParent;
1594 }
1595 }
1596 dprintf(("WindowFromPoint (%d,%d) %x->1\n", point.x, point.y, hwndOS2));
1597 return windowDesktop->getWindowHandle();
1598}
1599//******************************************************************************
1600//******************************************************************************
1601BOOL WIN32API IsWindowUnicode(HWND hwnd)
1602{
1603 Win32BaseWindow *window;
1604
1605 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1606 if(!window) {
1607 dprintf(("IsWindowUnicode, window %x not found", hwnd));
1608 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1609 return 0;
1610 }
1611 return window->IsWindowUnicode();
1612}
1613/***********************************************************************
1614 * SwitchToThisWindow (USER32.539)
1615 */
1616DWORD WINAPI SwitchToThisWindow( HWND hwnd, BOOL restore )
1617{
1618 return ShowWindow( hwnd, restore ? SW_RESTORE : SW_SHOWMINIMIZED );
1619}
1620//******************************************************************************
1621//******************************************************************************
1622BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
1623{
1624 return windowDesktop->EnumThreadWindows(dwThreadId, lpfn, lParam);
1625}
1626//******************************************************************************
1627//******************************************************************************
1628BOOL WIN32API EnumChildWindows(HWND hwnd, WNDENUMPROC lpfn, LPARAM lParam)
1629{
1630 Win32BaseWindow *window;
1631 BOOL rc = TRUE;
1632 ULONG henum;
1633 HWND hwndNext;
1634
1635 if(lpfn == NULL) {
1636 dprintf(("EnumChildWindows invalid parameter %x %x\n", hwnd, lParam));
1637 SetLastError(ERROR_INVALID_PARAMETER);
1638 return FALSE;
1639 }
1640 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1641 if(!window) {
1642 dprintf(("EnumChildWindows, window %x not found", hwnd));
1643 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1644 return FALSE;
1645 }
1646 return window->EnumChildWindows(lpfn, lParam);
1647}
1648//******************************************************************************
1649//******************************************************************************
1650BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
1651{
1652 return windowDesktop->EnumWindows(lpfn, lParam);
1653}
1654//******************************************************************************
1655//******************************************************************************
1656UINT WIN32API ArrangeIconicWindows( HWND hwnd)
1657{
1658 dprintf(("USER32: ArrangeIconicWindows %x", hwnd));
1659 return O32_ArrangeIconicWindows(Win32ToOS2Handle(hwnd));
1660}
1661//******************************************************************************
1662//restores iconized window to previous size/position
1663//******************************************************************************
1664BOOL WIN32API OpenIcon(HWND hwnd)
1665{
1666 dprintf(("USER32: OpenIcon %x", hwnd));
1667
1668 if(!IsIconic(hwnd))
1669 return FALSE;
1670 ShowWindow(hwnd, SW_SHOWNORMAL);
1671 return TRUE;
1672}
1673//******************************************************************************
1674//SDK: Windows can only be shown with ShowOwnedPopups if they were previously
1675// hidden with the same api
1676//TODO: -> needs testing
1677//******************************************************************************
1678BOOL WIN32API ShowOwnedPopups(HWND hwndOwner, BOOL fShow)
1679{
1680 Win32BaseWindow *window, *owner;
1681 HWND hwnd;
1682
1683 owner = Win32BaseWindow::GetWindowFromHandle(hwndOwner);
1684 if(!owner) {
1685 dprintf(("ShowOwnedPopups, window %x not found", hwndOwner));
1686 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1687 return FALSE;
1688 }
1689 dprintf(("USER32: ShowOwnedPopups %x %d", hwndOwner, fShow));
1690
1691 hwnd = GetWindow(GetDesktopWindow(), GW_CHILD);
1692 while(hwnd) {
1693 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1694 if(window) {
1695 if(window == owner && (window->getStyle() & WS_POPUP))
1696 {
1697 if(fShow) {
1698 if(window->getFlags() & WIN_NEEDS_SHOW_OWNEDPOPUP)
1699 {
1700 /*
1701 * In Windows, ShowOwnedPopups(TRUE) generates WM_SHOWWINDOW messages with SW_PARENTOPENING,
1702 * regardless of the state of the owner
1703 */
1704 SendMessageA(hwnd, WM_SHOWWINDOW, SW_SHOW, SW_PARENTOPENING);
1705 window->setFlags(window->getFlags() & ~WIN_NEEDS_SHOW_OWNEDPOPUP);
1706 }
1707 }
1708 else
1709 {
1710 if(IsWindowVisible(hwnd))
1711 {
1712 /*
1713 * In Windows, ShowOwnedPopups(FALSE) generates WM_SHOWWINDOW messages with SW_PARENTCLOSING,
1714 * regardless of the state of the owner
1715 */
1716 SendMessageA(hwnd, WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
1717 window->setFlags(window->getFlags() | WIN_NEEDS_SHOW_OWNEDPOPUP);
1718 }
1719 }
1720 }
1721 }
1722 else dprintf(("WARNING: window %x is not valid", hwnd));
1723
1724 hwnd = GetWindow(hwnd, GW_HWNDNEXT);
1725 }
1726 return TRUE;
1727}
1728//******************************************************************************
1729//******************************************************************************
1730HWND WIN32API GetForegroundWindow(void)
1731{
1732 HWND hwnd;
1733
1734 hwnd = OS2ToWin32Handle(OSLibWinQueryActiveWindow());
1735 dprintf(("USER32: GetForegroundWindow returned %x", hwnd));
1736 return hwnd;
1737}
1738//******************************************************************************
1739//******************************************************************************
1740HWND WIN32API GetLastActivePopup( HWND hWnd)
1741{
1742 HWND hwnd;
1743
1744 hwnd = Win32ToOS2Handle(hWnd);
1745 hwnd = OS2ToWin32Handle(O32_GetLastActivePopup(hwnd));
1746
1747 dprintf(("GetLastActivePopup %x returned %x NOT CORRECTLY IMPLEMENTED", hWnd, hwnd));
1748 return hwnd;
1749}
1750//******************************************************************************
1751//******************************************************************************
1752DWORD WIN32API GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
1753{
1754 dprintf2(("USER32: GetWindowThreadProcessId"));
1755 hWnd = Win32ToOS2Handle(hWnd);
1756
1757 return O32_GetWindowThreadProcessId(hWnd,lpdwProcessId);
1758}
1759//******************************************************************************
1760//******************************************************************************
1761DWORD WIN32API GetWindowContextHelpId(HWND hwnd)
1762{
1763 Win32BaseWindow *window;
1764
1765 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1766 if(!window) {
1767 dprintf(("GetWindowContextHelpId, window %x not found", hwnd));
1768 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1769 return 0;
1770 }
1771 dprintf(("GetWindowContextHelpId %x", hwnd));
1772 return window->getWindowContextHelpId();
1773}
1774//******************************************************************************
1775//******************************************************************************
1776BOOL WIN32API SetWindowContextHelpId(HWND hwnd, DWORD dwContextHelpId)
1777{
1778 Win32BaseWindow *window;
1779
1780 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1781 if(!window) {
1782 dprintf(("SetWindowContextHelpId, window %x not found", hwnd));
1783 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1784 return 0;
1785 }
1786 dprintf(("SetWindowContextHelpId %x %d", hwnd, dwContextHelpId));
1787 window->setWindowContextHelpId(dwContextHelpId);
1788 return(TRUE);
1789}
1790//******************************************************************************
1791//******************************************************************************
1792HANDLE WINAPI GetPropA( HWND hwnd, LPCSTR str )
1793{
1794 Win32BaseWindow *window;
1795
1796 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1797 if(!window) {
1798 dprintf(("GetPropA, window %x not found", hwnd));
1799 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1800 return 0;
1801 }
1802 return window->getProp(str);
1803}
1804//******************************************************************************
1805//******************************************************************************
1806HANDLE WINAPI GetPropW( HWND hwnd, LPCWSTR str )
1807{
1808 LPSTR strA;
1809 HANDLE ret;
1810
1811 if (!HIWORD(str)) return GetPropA( hwnd, (LPCSTR)(UINT)LOWORD(str) );
1812 strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
1813 ret = GetPropA( hwnd, strA );
1814 HeapFree( GetProcessHeap(), 0, strA );
1815 return ret;
1816}
1817//******************************************************************************
1818//******************************************************************************
1819BOOL WINAPI SetPropA( HWND hwnd, LPCSTR str, HANDLE handle )
1820{
1821 Win32BaseWindow *window;
1822
1823 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1824 if(!window) {
1825 dprintf(("SetPropA, window %x not found", hwnd));
1826 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1827 return FALSE;
1828 }
1829 return window->setProp(str, handle);
1830}
1831//******************************************************************************
1832//******************************************************************************
1833BOOL WINAPI SetPropW( HWND hwnd, LPCWSTR str, HANDLE handle )
1834{
1835 BOOL ret;
1836 LPSTR strA;
1837
1838 if (!HIWORD(str))
1839 return SetPropA( hwnd, (LPCSTR)(UINT)LOWORD(str), handle );
1840 strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
1841 ret = SetPropA( hwnd, strA, handle );
1842 HeapFree( GetProcessHeap(), 0, strA );
1843 return ret;
1844}
1845//******************************************************************************
1846//******************************************************************************
1847HANDLE WINAPI RemovePropA( HWND hwnd, LPCSTR str )
1848{
1849 Win32BaseWindow *window;
1850
1851 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1852 if(!window) {
1853 dprintf(("RemovePropA, window %x not found", hwnd));
1854 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1855 return 0;
1856 }
1857 return window->removeProp(str);
1858}
1859//******************************************************************************
1860//******************************************************************************
1861HANDLE WINAPI RemovePropW( HWND hwnd, LPCWSTR str )
1862{
1863 LPSTR strA;
1864 HANDLE ret;
1865
1866 if (!HIWORD(str))
1867 return RemovePropA( hwnd, (LPCSTR)(UINT)LOWORD(str) );
1868 strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
1869 ret = RemovePropA( hwnd, strA );
1870 HeapFree( GetProcessHeap(), 0, strA );
1871 return ret;
1872}
1873//******************************************************************************
1874//******************************************************************************
1875INT WINAPI EnumPropsA( HWND hwnd, PROPENUMPROCA func )
1876{
1877 return EnumPropsExA( hwnd, (PROPENUMPROCEXA)func, 0 );
1878}
1879//******************************************************************************
1880//******************************************************************************
1881INT WINAPI EnumPropsW( HWND hwnd, PROPENUMPROCW func )
1882{
1883 return EnumPropsExW( hwnd, (PROPENUMPROCEXW)func, 0 );
1884}
1885//******************************************************************************
1886//******************************************************************************
1887INT WINAPI EnumPropsExA(HWND hwnd, PROPENUMPROCEXA func, LPARAM lParam)
1888{
1889 Win32BaseWindow *window;
1890
1891 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1892 if(!window) {
1893 dprintf(("EnumPropsExA, window %x not found", hwnd));
1894 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1895 return -1;
1896 }
1897 return window->enumPropsExA(func, lParam);
1898}
1899//******************************************************************************
1900//******************************************************************************
1901INT WINAPI EnumPropsExW(HWND hwnd, PROPENUMPROCEXW func, LPARAM lParam)
1902{
1903 Win32BaseWindow *window;
1904
1905 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
1906 if(!window) {
1907 dprintf(("EnumPropsExA, window %x not found", hwnd));
1908 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
1909 return -1;
1910 }
1911 return window->enumPropsExW(func, lParam);
1912}
1913//******************************************************************************
1914//******************************************************************************
Note: See TracBrowser for help on using the repository browser.