source: trunk/src/user32/new/window.cpp@ 750

Last change on this file since 750 was 750, checked in by sandervl, 26 years ago

Added MDI class + ChildWindowFromPointEx by Rene Pronk

File size: 37.1 KB
Line 
1/* $Id: window.cpp,v 1.20 1999-08-31 10:36:24 sandervl Exp $ */
2/*
3 * Win32 window apis for OS/2
4 *
5 * Copyright 1999 Sander van Leeuwen
6 *
7 * Parts based on Wine Windows code (windows\win.c)
8 *
9 * Copyright 1993, 1994 Alexandre Julliard
10 *
11 * Project Odin Software License can be found in LICENSE.TXT
12 *
13 *
14 * TODO: Decide what to do about commands for OS/2 windows (non-Win32 apps)
15 *
16 */
17
18#include <os2win.h>
19#include <misc.h>
20#include <win32wbase.h>
21#include <oslibwin.h>
22#include <oslibgdi.h>
23#include "user32.h"
24#include "winicon.h"
25#include "usrcall.h"
26
27//******************************************************************************
28//******************************************************************************
29HWND WIN32API CreateWindowExA(DWORD exStyle, LPCSTR className,
30 LPCSTR windowName, DWORD style, INT x,
31 INT y, INT width, INT height,
32 HWND parent, HMENU menu,
33 HINSTANCE instance, LPVOID data )
34{
35 Win32BaseWindow *window;
36 ATOM classAtom;
37 CREATESTRUCTA cs;
38
39 if(exStyle & WS_EX_MDICHILD)
40 return CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
41
42 /* Find the class atom */
43 if (!(classAtom = GlobalFindAtomA(className)))
44 {
45 dprintf(("CreateWindowEx32A: bad class name "));
46 if (!HIWORD(className)) {
47 dprintf(("CreateWindowEx32A: bad class name %04x\n", LOWORD(className)));
48 }
49 else dprintf(("CreateWindowEx32A: bad class name '%s'\n", className ));
50 SetLastError(ERROR_INVALID_PARAMETER);
51 return 0;
52 }
53
54 /* Create the window */
55 cs.lpCreateParams = data;
56 cs.hInstance = instance;
57 cs.hMenu = menu;
58 cs.hwndParent = parent;
59 cs.x = x;
60 cs.y = y;
61 cs.cx = width;
62 cs.cy = height;
63 cs.style = style;
64 cs.lpszName = windowName;
65 cs.lpszClass = className;
66 cs.dwExStyle = exStyle;
67 dprintf(("CreateWindowExA: (%d,%d) (%d,%d), %x %x", x, y, width, height, style, exStyle));
68 window = new Win32BaseWindow( &cs, classAtom, FALSE );
69 if(window == NULL)
70 {
71 dprintf(("Win32BaseWindow creation failed!!"));
72 return 0;
73 }
74 if(GetLastError() != 0)
75 {
76 dprintf(("Win32BaseWindow error found!!"));
77 delete window;
78 return 0;
79 }
80 return window->getWindowHandle();
81}
82//******************************************************************************
83//******************************************************************************
84HWND WIN32API CreateWindowExW(DWORD exStyle, LPCWSTR className,
85 LPCWSTR windowName, DWORD style, INT x,
86 INT y, INT width, INT height,
87 HWND parent, HMENU menu,
88 HINSTANCE instance, LPVOID data )
89{
90 Win32BaseWindow *window;
91 ATOM classAtom;
92 CREATESTRUCTA cs;
93
94 if(exStyle & WS_EX_MDICHILD)
95 return CreateMDIWindowW(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
96
97 /* Find the class atom */
98 if (!(classAtom = GlobalFindAtomW(className)))
99 {
100 dprintf(("CreateWindowEx32A: bad class name "));
101 if (!HIWORD(className)) {
102 dprintf(("CreateWindowEx32A: bad class name %04x\n", LOWORD(className)));
103 }
104// else dprintf(("CreateWindowEx32A: bad class name '%s'\n", className ));
105 SetLastError(ERROR_INVALID_PARAMETER);
106 return 0;
107 }
108
109 /* Create the window */
110 cs.lpCreateParams = data;
111 cs.hInstance = instance;
112 cs.hMenu = menu;
113 cs.hwndParent = parent;
114 cs.x = x;
115 cs.y = y;
116 cs.cx = width;
117 cs.cy = height;
118 cs.style = style;
119 cs.lpszName = (LPSTR)windowName;
120 cs.lpszClass = (LPSTR)className;
121 cs.dwExStyle = exStyle;
122 window = new Win32BaseWindow( &cs, classAtom, TRUE );
123 if(window == NULL)
124 {
125 dprintf(("Win32BaseWindow creation failed!!"));
126 return 0;
127 }
128 if(GetLastError() != 0)
129 {
130 dprintf(("Win32BaseWindow error found!!"));
131 delete window;
132 return 0;
133 }
134 return window->getWindowHandle();
135}
136//******************************************************************************
137//******************************************************************************
138HWND WIN32API CreateMDIWindowA(LPCSTR lpszClassName, LPCSTR lpszWindowName,
139 DWORD dwStyle, int x, int y, int nWidth,
140 int nHeight, HWND hwndParent,
141 HINSTANCE hInstance, LPARAM lParam )
142{
143 HWND hwnd;
144 MDICREATESTRUCTA cs;
145 Win32BaseWindow *window;
146
147 window = Win32BaseWindow::GetWindowFromHandle(hwndParent);
148 if(!window) {
149 dprintf(("CreateMDIWindowA, window %x not found", hwndParent));
150 return 0;
151 }
152
153 dprintf(("USER32: CreateMDIWindowA\n"));
154 cs.szClass = lpszClassName;
155 cs.szTitle = lpszWindowName;
156 cs.hOwner = hInstance;
157 cs.x = x;
158 cs.y = y;
159 cs.cx = nHeight;
160 cs.cy = nWidth;
161 cs.style = dwStyle;
162 cs.lParam = lParam;
163
164 return window->SendMessageA(WM_MDICREATE, 0, (LPARAM)&cs);
165}
166//******************************************************************************
167//******************************************************************************
168HWND WIN32API CreateMDIWindowW(LPCWSTR lpszClassName, LPCWSTR lpszWindowName,
169 DWORD dwStyle, int x, int y, int nWidth,
170 int nHeight, HWND hwndParent,
171 HINSTANCE hInstance, LPARAM lParam )
172{
173 HWND hwnd;
174 MDICREATESTRUCTW cs;
175 Win32BaseWindow *window;
176
177 window = Win32BaseWindow::GetWindowFromHandle(hwndParent);
178 if(!window) {
179 dprintf(("CreateMDIWindowW, window %x not found", hwndParent));
180 return 0;
181 }
182
183 dprintf(("USER32: CreateMDIWindowW\n"));
184 cs.szClass = lpszClassName;
185 cs.szTitle = lpszWindowName;
186 cs.hOwner = hInstance;
187 cs.x = x;
188 cs.y = y;
189 cs.cx = nHeight;
190 cs.cy = nWidth;
191 cs.style = dwStyle;
192 cs.lParam = lParam;
193
194 return window->SendMessageW(WM_MDICREATE, 0, (LPARAM)&cs);
195}
196//******************************************************************************
197//******************************************************************************
198BOOL WIN32API DestroyWindow(HWND hwnd)
199{
200 Win32BaseWindow *window;
201
202 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
203 if(!window) {
204 dprintf(("DestroyWindow, window %x not found", hwnd));
205 return 0;
206 }
207 dprintf(("DestroyWindow %x", hwnd));
208 return window->DestroyWindow();
209}
210//******************************************************************************
211//******************************************************************************
212HWND WIN32API SetActiveWindow( HWND hwnd)
213{
214 Win32BaseWindow *window;
215
216 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
217 if(!window) {
218 dprintf(("SetActiveWindow, window %x not found", hwnd));
219 return 0;
220 }
221 dprintf(("SetActiveWindow %x", hwnd));
222 return window->SetActiveWindow();
223}
224//******************************************************************************
225//******************************************************************************
226HWND WIN32API GetParent( HWND hwnd)
227{
228 Win32BaseWindow *window;
229
230 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
231 if(!window) {
232 dprintf(("GetParent, window %x not found", hwnd));
233 return 0;
234 }
235 dprintf(("GetParent %x", hwnd));
236 return window->GetParent();
237}
238//******************************************************************************
239//******************************************************************************
240HWND WIN32API SetParent( HWND hwndChild, HWND hwndNewParent)
241{
242 Win32BaseWindow *window;
243
244 window = Win32BaseWindow::GetWindowFromHandle(hwndChild);
245 if(!window) {
246 dprintf(("SetParent, window %x not found", hwndChild));
247 return 0;
248 }
249 dprintf(("SetParent %x %x", hwndChild, hwndNewParent));
250 return window->SetParent(hwndNewParent);
251}
252//******************************************************************************
253//******************************************************************************
254BOOL WIN32API IsChild( HWND hwndParent, HWND hwnd)
255{
256 Win32BaseWindow *window;
257
258 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
259 if(!window) {
260 dprintf(("IsChild, window %x not found", hwnd));
261 return 0;
262 }
263 dprintf(("IsChild %x %x", hwndParent, hwnd));
264 return window->IsChild(hwndParent);
265}
266//******************************************************************************
267//******************************************************************************
268HWND WIN32API GetTopWindow( HWND hwnd)
269{
270 Win32BaseWindow *window;
271
272 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
273 if(!window) {
274 dprintf(("GetTopWindow, window %x not found", hwnd));
275 return 0;
276 }
277 dprintf(("GetTopWindow %x", hwnd));
278 return window->GetTopWindow();
279}
280//******************************************************************************
281//******************************************************************************
282BOOL WIN32API UpdateWindow(HWND hwnd)
283{
284 Win32BaseWindow *window;
285
286 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
287 if(!window) {
288 dprintf(("UpdateWindow, window %x not found", hwnd));
289 return 0;
290 }
291 dprintf(("UpdateWindow %x", hwnd));
292 return window->UpdateWindow();
293}
294//******************************************************************************
295//******************************************************************************
296BOOL WIN32API IsIconic( HWND hwnd)
297{
298 Win32BaseWindow *window;
299
300 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
301 if(!window) {
302 dprintf(("IsIconic, window %x not found", hwnd));
303 return 0;
304 }
305 dprintf(("IsIconic %x", hwnd));
306 return window->IsIconic();
307}
308//******************************************************************************
309//******************************************************************************
310HWND WIN32API GetWindow(HWND hwnd, UINT uCmd)
311{
312 Win32BaseWindow *window;
313
314 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
315 if(!window) {
316 dprintf(("GetWindow, window %x not found", hwnd));
317 return 0;
318 }
319 dprintf(("GetWindow %x %d", hwnd, uCmd));
320 return window->GetWindow(uCmd);
321}
322//******************************************************************************
323//******************************************************************************
324BOOL WIN32API EnableWindow( HWND hwnd, BOOL fEnable)
325{
326 Win32BaseWindow *window;
327
328 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
329 if(!window) {
330 dprintf(("EnableWindow, window %x not found", hwnd));
331 return 0;
332 }
333 dprintf(("EnableWindow %x %d", hwnd, fEnable));
334 return window->EnableWindow(fEnable);
335}
336//******************************************************************************
337//******************************************************************************
338BOOL WIN32API BringWindowToTop(HWND hwnd)
339{
340 return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
341}
342//******************************************************************************
343//******************************************************************************
344HWND WIN32API GetActiveWindow()
345{
346 return Win32BaseWindow::GetActiveWindow();
347}
348//******************************************************************************
349//******************************************************************************
350BOOL WIN32API ShowWindow(HWND hwnd, int nCmdShow)
351{
352 Win32BaseWindow *window;
353
354 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
355 if(!window) {
356 dprintf(("ShowWindow, window %x not found", hwnd));
357 return 0;
358 }
359 dprintf(("ShowWindow %x", hwnd));
360 return window->ShowWindow(nCmdShow);
361}
362//******************************************************************************
363//******************************************************************************
364BOOL WIN32API SetWindowPos(HWND hwnd, HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
365{
366 Win32BaseWindow *window;
367
368 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
369 if(!window) {
370 dprintf(("SetWindowPos, window %x not found", hwnd));
371 return 0;
372 }
373 dprintf(("SetWindowPos %x %x x=%d y=%d cx=%d cy=%d %x", hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
374 return window->SetWindowPos(hwndInsertAfter, x, y, cx, cy, fuFlags);
375}
376//******************************************************************************
377//******************************************************************************
378BOOL WIN32API SetWindowPlacement( HWND arg1, const WINDOWPLACEMENT * arg2)
379{
380 dprintf(("USER32: SetWindowPlacement\n"));
381 return O32_SetWindowPlacement(arg1, arg2);
382}
383//******************************************************************************
384//******************************************************************************
385BOOL WIN32API GetWindowPlacement( HWND arg1, LPWINDOWPLACEMENT arg2)
386{
387#ifdef DEBUG
388 WriteLog("USER32: GetWindowPlacement\n");
389#endif
390 return O32_GetWindowPlacement(arg1, arg2);
391}
392//******************************************************************************
393//******************************************************************************
394BOOL WIN32API IsWindow( HWND hwnd)
395{
396 Win32BaseWindow *window;
397
398 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
399 if(!window) {
400 dprintf(("IsWindow, window %x not found", hwnd));
401 return FALSE;
402 }
403 dprintf(("IsWindow %x", hwnd));
404 return window->IsWindow();
405}
406//******************************************************************************
407//******************************************************************************
408BOOL WIN32API IsWindowEnabled( HWND hwnd)
409{
410 Win32BaseWindow *window;
411
412 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
413 if(!window) {
414 dprintf(("IsWindowEnabled, window %x not found", hwnd));
415 return 0;
416 }
417 dprintf(("IsWindowEnabled %x", hwnd));
418 return window->IsWindowEnabled();
419}
420//******************************************************************************
421//******************************************************************************
422BOOL WIN32API IsWindowVisible( HWND hwnd)
423{
424 Win32BaseWindow *window;
425
426 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
427 if(!window) {
428 dprintf(("IsWindowVisible, window %x not found", hwnd));
429 return 0;
430 }
431 dprintf(("IsWindowVisible %x", hwnd));
432 return window->IsWindowVisible();
433}
434//******************************************************************************
435//******************************************************************************
436HWND WIN32API SetFocus( HWND hwnd)
437{
438 HWND lastFocus;
439
440 dprintf(("USER32: SetFocus\n"));
441
442 lastFocus = GetFocus();
443 hwnd = Win32BaseWindow::Win32ToOS2Handle(hwnd);
444 return (OSLibWinSetFocus(OSLIB_HWND_DESKTOP,hwnd)) ? lastFocus:0;
445}
446//******************************************************************************
447//******************************************************************************
448HWND WIN32API GetFocus(void)
449{
450 HWND hwnd;
451// dprintf(("USER32: GetFocus\n"));
452
453 hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP);
454 return Win32BaseWindow::OS2ToWin32Handle(hwnd);
455}
456//******************************************************************************
457//******************************************************************************
458/***********************************************************************
459 * GetInternalWindowPos (USER32.245)
460 */
461UINT WIN32API GetInternalWindowPos(HWND hwnd,
462 LPRECT rectWnd,
463 LPPOINT ptIcon )
464{
465 WINDOWPLACEMENT wndpl;
466
467 dprintf(("USER32: GetInternalWindowPos(%08xh,%08xh,%08xh)\n",
468 hwnd,
469 rectWnd,
470 ptIcon));
471
472 if (GetWindowPlacement( hwnd, &wndpl ))
473 {
474 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
475 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
476 return wndpl.showCmd;
477 }
478 return 0;
479}
480//******************************************************************************
481//******************************************************************************
482BOOL WIN32API IsZoomed( HWND arg1)
483{
484#ifdef DEBUG
485 WriteLog("USER32: IsZoomed\n");
486#endif
487 return O32_IsZoomed(arg1);
488}
489//******************************************************************************
490//******************************************************************************
491BOOL WIN32API LockWindowUpdate( HWND arg1)
492{
493#ifdef DEBUG
494 WriteLog("USER32: LockWindowUpdate\n");
495#endif
496 return O32_LockWindowUpdate(arg1);
497}
498//******************************************************************************
499//******************************************************************************
500BOOL WIN32API RedrawWindow( HWND arg1, const RECT * arg2, HRGN arg3, UINT arg4)
501{
502 BOOL rc;
503
504 rc = O32_RedrawWindow(arg1, arg2, arg3, arg4);
505#ifdef DEBUG
506 WriteLog("USER32: RedrawWindow %X , %X, %X, %X returned %d\n", arg1, arg2, arg3, arg4, rc);
507#endif
508 InvalidateRect(arg1, arg2, TRUE);
509 UpdateWindow(arg1);
510 SendMessageA(arg1, WM_PAINT, 0, 0);
511 return(rc);
512}
513//******************************************************************************
514//******************************************************************************
515BOOL WIN32API GetWindowRect( HWND hwnd, PRECT pRect)
516{
517 Win32BaseWindow *window;
518
519 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
520 if(!window) {
521 dprintf(("GetWindowRect, window %x not found", hwnd));
522 return 0;
523 }
524 dprintf(("GetWindowRect %x", hwnd));
525 return window->GetWindowRect(pRect);
526}
527//******************************************************************************
528//******************************************************************************
529int WIN32API GetWindowTextLengthA( HWND hwnd)
530{
531 Win32BaseWindow *window;
532
533 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
534 if(!window) {
535 dprintf(("GetWindowTextLength, window %x not found", hwnd));
536 return 0;
537 }
538 dprintf(("GetWindowTextLength %x", hwnd));
539 return window->GetWindowTextLengthA();
540}
541//******************************************************************************
542//******************************************************************************
543int WIN32API GetWindowTextA( HWND hwnd, LPSTR lpsz, int cch)
544{
545 Win32BaseWindow *window;
546
547 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
548 if(!window) {
549 dprintf(("GetWindowTextA, window %x not found", hwnd));
550 return 0;
551 }
552 dprintf(("GetWindowTextA %x", hwnd));
553 return window->GetWindowTextA(lpsz, cch);
554}
555//******************************************************************************
556//******************************************************************************
557int WIN32API GetWindowTextLengthW( HWND hwnd)
558{
559 dprintf(("USER32: GetWindowTextLengthW\n"));
560 return GetWindowTextLengthA(hwnd);
561}
562//******************************************************************************
563//******************************************************************************
564int WIN32API GetWindowTextW(HWND hwnd, LPWSTR lpsz, int cch)
565{
566 char title[128];
567 int rc;
568
569 rc = O32_GetWindowText(hwnd, title, sizeof(title));
570#ifdef DEBUG
571 WriteLog("USER32: GetWindowTextW returned %s\n", title);
572#endif
573 if(rc > cch) {
574 title[cch-1] = 0;
575 rc = cch;
576 }
577 AsciiToUnicode(title, lpsz);
578 return(rc);
579}
580//******************************************************************************
581//******************************************************************************
582BOOL WIN32API SetWindowTextA(HWND hwnd, LPCSTR lpsz)
583{
584 Win32BaseWindow *window;
585
586 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
587 if(!window) {
588 dprintf(("SetWindowTextA, window %x not found", hwnd));
589 return 0;
590 }
591 dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
592 return window->SetWindowText((LPSTR)lpsz);
593}
594//******************************************************************************
595//******************************************************************************
596BOOL WIN32API SetWindowTextW( HWND arg1, LPCWSTR arg2)
597{
598 char *astring = UnicodeToAsciiString((LPWSTR)arg2);
599 BOOL rc;
600
601 rc = SetWindowTextA(arg1, (LPCSTR)astring);
602 dprintf(("USER32: SetWindowTextW %X %s returned %d\n", arg1, astring, rc));
603 FreeAsciiString(astring);
604 return(rc);
605}
606/*******************************************************************
607 * InternalGetWindowText (USER32.326)
608 */
609int WIN32API InternalGetWindowText(HWND hwnd,
610 LPWSTR lpString,
611 INT nMaxCount )
612{
613 dprintf(("USER32: InternalGetWindowText(%08xh,%08xh,%08xh) not properly implemented.\n",
614 hwnd,
615 lpString,
616 nMaxCount));
617
618 return GetWindowTextW(hwnd,lpString,nMaxCount);
619}
620//******************************************************************************
621//TODO: Correct?
622//******************************************************************************
623BOOL WIN32API SetForegroundWindow(HWND hwnd)
624{
625 dprintf((" SetForegroundWindow %x", hwnd));
626
627 return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER );
628}
629//******************************************************************************
630//******************************************************************************
631BOOL WIN32API GetClientRect( HWND hwnd, PRECT pRect)
632{
633 BOOL rc;
634
635 hwnd = Win32BaseWindow::Win32ToOS2Handle(hwnd);
636 rc = OSLibWinQueryWindowRect(hwnd, pRect);
637 dprintf(("USER32: GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
638 return rc;
639}
640//******************************************************************************
641//******************************************************************************
642BOOL WIN32API AdjustWindowRect( PRECT arg1, DWORD arg2, BOOL arg3)
643{
644#ifdef DEBUG
645 WriteLog("USER32: AdjustWindowRect\n");
646#endif
647 return O32_AdjustWindowRect(arg1, arg2, arg3);
648}
649//******************************************************************************
650//******************************************************************************
651BOOL WIN32API AdjustWindowRectEx( PRECT arg1, DWORD arg2, BOOL arg3, DWORD arg4)
652{
653#ifdef DEBUG
654 WriteLog("USER32: AdjustWindowRectEx\n");
655#endif
656 return O32_AdjustWindowRectEx(arg1, arg2, arg3, arg4);
657}
658//******************************************************************************
659//******************************************************************************
660HWND WIN32API GetDesktopWindow(void)
661{
662 dprintf(("USER32: GetDesktopWindow\n"));
663 return OSLIB_HWND_DESKTOP;
664}
665//******************************************************************************
666//******************************************************************************
667HWND WIN32API FindWindowA(LPCSTR lpszClass, LPCSTR lpszWindow)
668{
669 if(!lpszClass) {
670 SetLastError(ERROR_INVALID_PARAMETER);
671 return 0;
672 }
673 if(HIWORD(lpszClass)) {
674 dprintf(("USER32: FindWindow %s %s\n", lpszClass, lpszWindow));
675 }
676 else dprintf(("USER32: FindWindow %x %s\n", lpszClass, lpszWindow));
677
678 return Win32BaseWindow::FindWindowEx(OSLIB_HWND_DESKTOP, 0, (LPSTR)lpszClass, (LPSTR)lpszWindow);
679}
680//******************************************************************************
681//******************************************************************************
682HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow)
683{
684 if(!lpszClass) {
685 SetLastError(ERROR_INVALID_PARAMETER);
686 return 0;
687 }
688 if(HIWORD(lpszClass)) {
689 dprintf(("USER32: FindWindowExA (%x,%x) %s %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
690 }
691 else dprintf(("USER32: FindWindowExA (%x,%x)%x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
692
693 return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
694}
695/*****************************************************************************
696 * Name : HWND WIN32API FindWindowExW
697 * Purpose : The FindWindowEx function retrieves the handle of a window whose
698 * class name and window name match the specified strings. The
699 * function searches child windows, beginning with the one following
700 * the given child window.
701 * Parameters: HWND hwndParent handle of parent window
702 * HWND hwndChildAfter handle of a child window
703 * LPCTSTR lpszClass address of class name
704 * LPCTSTR lpszWindow address of window name
705 * Variables :
706 * Result : If the function succeeds, the return value is the handle of the
707 * window that has the specified class and window names.
708 * If the function fails, the return value is NULL. To get extended
709 * error information, call GetLastError.
710 * Remark :
711 * Status : UNTESTED STUB
712 *
713 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
714 *****************************************************************************/
715
716HWND WIN32API FindWindowExW(HWND hwndParent,
717 HWND hwndChildAfter,
718 LPCWSTR lpszClass,
719 LPCWSTR lpszWindow)
720{
721 if(!lpszClass) {
722 SetLastError(ERROR_INVALID_PARAMETER);
723 return 0;
724 }
725 dprintf(("USER32: FindWindowExW (%x,%x) %x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
726
727 return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
728}
729//******************************************************************************
730//******************************************************************************
731BOOL WIN32API FlashWindow(HWND hwnd, BOOL fFlash)
732{
733 dprintf(("FlashWindow %x %d\n", hwnd, fFlash));
734 return OSLibWinFlashWindow(Win32BaseWindow::Win32ToOS2Handle(hwnd), fFlash);
735}
736//******************************************************************************
737//******************************************************************************
738BOOL WIN32API MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
739 BOOL repaint )
740{
741 int flags = SWP_NOZORDER | SWP_NOACTIVATE;
742
743 if (!repaint) flags |= SWP_NOREDRAW;
744 dprintf(("MoveWindow: %04x %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ));
745
746 return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
747}
748//******************************************************************************
749//******************************************************************************
750BOOL WIN32API ClientToScreen( HWND arg1, PPOINT arg2)
751{
752#ifdef DEBUG
753//// WriteLog("USER32: ClientToScreen\n");
754#endif
755 return O32_ClientToScreen(arg1, arg2);
756}
757//******************************************************************************
758//******************************************************************************
759HDWP WIN32API BeginDeferWindowPos( int arg1)
760{
761#ifdef DEBUG
762 WriteLog("USER32: BeginDeferWindowPos\n");
763#endif
764 return O32_BeginDeferWindowPos(arg1);
765}
766//******************************************************************************
767//******************************************************************************
768HDWP WIN32API DeferWindowPos( HDWP arg1, HWND arg2, HWND arg3, int arg4, int arg5, int arg6, int arg7, UINT arg8)
769{
770#ifdef DEBUG
771 WriteLog("USER32: DeferWindowPos\n");
772#endif
773 return O32_DeferWindowPos(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
774}
775//******************************************************************************
776//******************************************************************************
777HWND WIN32API ChildWindowFromPoint( HWND arg1, POINT arg2)
778{
779#ifdef DEBUG
780 WriteLog("USER32: ChildWindowFromPoint\n");
781#endif
782 return O32_ChildWindowFromPoint(arg1, arg2);
783}
784//******************************************************************************
785//******************************************************************************
786/*****************************************************************************
787 * Name : HWND WIN32API ChildWindowFromPointEx
788 * Purpose : The GetWindowRect function retrieves the dimensions of the
789 * bounding rectangle of the specified window. The dimensions are
790 * given in screen coordinates that are relative to the upper-left
791 * corner of the screen.
792 * Parameters:
793 * Variables :
794 * Result : If the function succeeds, the return value is the window handle.
795 * If the function fails, the return value is zero
796 * Remark :
797 * Status : FULLY IMPLEMENTED AND TESTED
798 *
799 * Author : Rene Pronk [Sun, 1999/08/08 23:30]
800 *****************************************************************************/
801
802HWND WIN32API ChildWindowFromPointEx (HWND hwndParent, POINT pt, UINT uFlags)
803{
804 RECT rect;
805 HWND hWnd;
806 POINT absolutePt;
807
808 dprintf(("USER32: ChildWindowFromPointEx(%08xh,%08xh,%08xh).\n",
809 hwndParent, pt, uFlags));
810
811 if (GetWindowRect (hwndParent, &rect) == 0) {
812 // oops, invalid handle
813 return NULL;
814 }
815
816 // absolutePt has its top in the upper-left corner of the screen
817 absolutePt = pt;
818 ClientToScreen (hwndParent, &absolutePt);
819
820 // make rect the size of the parent window
821 GetWindowRect (hwndParent, &rect);
822 rect.right = rect.right - rect.left;
823 rect.bottom = rect.bottom - rect.top;
824 rect.left = 0;
825 rect.top = 0;
826
827 if (PtInRect (&rect, pt) == 0) {
828 // point is outside window
829 return NULL;
830 }
831
832 // get first child
833 hWnd = GetWindow (hwndParent, GW_CHILD);
834
835 while (hWnd != NULL) {
836
837 // do I need to skip this window?
838 if (((uFlags & CWP_SKIPINVISIBLE) &&
839 (IsWindowVisible (hWnd) == FALSE)) ||
840 ((uFlags & CWP_SKIPDISABLED) &&
841 (IsWindowEnabled (hWnd) == FALSE)) ||
842 ((uFlags & CWP_SKIPTRANSPARENT) &&
843 (GetWindowLongA (hWnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
844
845 {
846 hWnd = GetWindow (hWnd, GW_HWNDNEXT);
847 continue;
848 }
849
850 // is the point in this window's rect?
851 GetWindowRect (hWnd, &rect);
852 if (PtInRect (&rect, absolutePt) == FALSE) {
853 hWnd = GetWindow (hWnd, GW_HWNDNEXT);
854 continue;
855 }
856
857 // found it!
858 return hWnd;
859 }
860
861 // the point is in the parentwindow but the parentwindow has no child
862 // at this coordinate
863 return hwndParent;
864}
865//******************************************************************************
866//******************************************************************************
867BOOL WIN32API CloseWindow(HWND hwnd)
868{
869 Win32BaseWindow *window;
870
871 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
872 if(!window) {
873 dprintf(("CloseWindow, window %x not found", hwnd));
874 return 0;
875 }
876 dprintf(("CloseWindow %x\n", hwnd));
877 return window->CloseWindow();
878}
879//******************************************************************************
880//TODO: Does this return handles of hidden or disabled windows?
881//******************************************************************************
882HWND WIN32API WindowFromPoint( POINT point)
883{
884 HWND hwnd;
885
886 dprintf(("WindowFromPoint (%d,%d)\n", point.x, point.y));
887 hwnd = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&point);
888 if(hwnd) {
889 return Win32BaseWindow::OS2ToWin32Handle(hwnd);
890 }
891 return 0;
892}
893//******************************************************************************
894//******************************************************************************
895BOOL WIN32API IsWindowUnicode(HWND hwnd)
896{
897 Win32BaseWindow *window;
898
899 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
900 if(!window) {
901 dprintf(("IsWindowUnicode, window %x not found", hwnd));
902 return 0;
903 }
904 return window->IsUnicode();
905}
906/*****************************************************************************
907 * Name : WORD WIN32API CascadeWindows
908 * Purpose : The CascadeWindows function cascades the specified windows or
909 * the child windows of the specified parent window.
910 * Parameters: HWND hwndParent handle of parent window
911 * UINT wHow types of windows not to arrange
912 * CONST RECT * lpRect rectangle to arrange windows in
913 * UINT cKids number of windows to arrange
914 * const HWND FAR * lpKids array of window handles
915 * Variables :
916 * Result : If the function succeeds, the return value is the number of windows arranged.
917 * If the function fails, the return value is zero.
918 * Remark :
919 * Status : UNTESTED STUB
920 *
921 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
922 *****************************************************************************/
923
924WORD WIN32API CascadeWindows(HWND hwndParent,
925 UINT wHow,
926 CONST LPRECT lpRect,
927 UINT cKids,
928 const HWND *lpKids)
929{
930 dprintf(("USER32:CascadeWindows(%08xh,%u,%08xh,%u,%08x) not implemented.\n",
931 hwndParent,
932 wHow,
933 lpRect,
934 cKids,
935 lpKids));
936
937 return (0);
938}
939/*****************************************************************************
940 * Name : BOOL WIN32API SwitchToThisWindow
941 * Purpose : Unknown
942 * Parameters: Unknown
943 * Variables :
944 * Result :
945 * Remark :
946 * Status : UNTESTED UNKNOWN STUB
947 *
948 * Author : Patrick Haller [Wed, 1998/06/16 11:55]
949 *****************************************************************************/
950
951BOOL WIN32API SwitchToThisWindow(HWND hwnd,
952 BOOL x2)
953{
954 dprintf(("USER32: SwitchToThisWindow(%08xh,%08xh) not implemented.\n",
955 hwnd,
956 x2));
957
958 return (FALSE); /* default */
959}
960//******************************************************************************
961//******************************************************************************
962BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
963{
964 BOOL rc;
965 EnumWindowCallback *callback = new EnumWindowCallback(lpfn, lParam);
966
967 dprintf(("USER32: EnumThreadWindows\n"));
968 //CB: replace
969 rc = O32_EnumThreadWindows(dwThreadId, callback->GetOS2Callback(), (LPARAM)callback);
970 if(callback)
971 delete callback;
972 return(rc);
973}
974//******************************************************************************
975//******************************************************************************
976BOOL WIN32API GetUpdateRect( HWND hwnd, PRECT lpRect, BOOL bErase)
977{
978 dprintf(("GetUpdateRect %x %d\n", hwnd, bErase));
979 if (!lpRect) return FALSE;
980
981 return OSLibWinQueryUpdateRect(Win32BaseWindow::Win32ToOS2Handle(hwnd), lpRect);
982}
983//******************************************************************************
984//******************************************************************************
985BOOL WIN32API InvalidateRect(HWND hWnd, const RECT *lpRect, BOOL bErase)
986{
987#ifdef DEBUG
988 if(lpRect)
989 WriteLog("USER32: InvalidateRect for window %X (%d,%d)(%d,%d) %d\n", hWnd, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, bErase);
990 else WriteLog("USER32: InvalidateRect for window %X NULL, %d\n", hWnd, bErase);
991#endif
992
993 //CB: bErase no quite the same
994 hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
995 if (lpRect)
996 {
997 return OSLibWinInvalidateRect(hWnd, (PRECT)lpRect, bErase);
998 }
999 else return OSLibWinInvalidateRect(hWnd,NULL,bErase);
1000}
1001//******************************************************************************
1002//******************************************************************************
1003UINT WIN32API ArrangeIconicWindows( HWND arg1)
1004{
1005#ifdef DEBUG
1006 WriteLog("USER32: ArrangeIconicWindows\n");
1007#endif
1008 return O32_ArrangeIconicWindows(arg1);
1009}
1010//******************************************************************************
1011//restores iconized window to previous size/position
1012//******************************************************************************
1013BOOL WIN32API OpenIcon(HWND hwnd)
1014{
1015#ifdef DEBUG
1016 WriteLog("USER32: OpenIcon\n");
1017#endif
1018 if(!IsIconic(hwnd))
1019 return FALSE;
1020 ShowWindow(hwnd, SW_SHOWNORMAL);
1021 return TRUE;
1022}
1023//******************************************************************************
1024//******************************************************************************
1025BOOL WIN32API ShowOwnedPopups( HWND arg1, BOOL arg2)
1026{
1027 dprintf(("USER32: ShowOwnedPopups\n"));
1028 return O32_ShowOwnedPopups(arg1, arg2);
1029}
1030//******************************************************************************
1031//******************************************************************************
Note: See TracBrowser for help on using the repository browser.