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

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

Moved new user32 here

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