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

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

MDI fixes, ChildWindowFromPointEx

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