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

Last change on this file since 962 was 962, checked in by dengert, 26 years ago

some more DC related functions

File size: 40.6 KB
Line 
1/* $Id: window.cpp,v 1.2 1999-09-16 18:00:43 dengert 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//******************************************************************************
302#if 0
303BOOL WIN32API UpdateWindow(HWND hwnd)
304{
305 Win32BaseWindow *window;
306
307 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
308 if(!window) {
309 dprintf(("UpdateWindow, window %x not found", hwnd));
310 return 0;
311 }
312 dprintf(("UpdateWindow %x", hwnd));
313 return window->UpdateWindow();
314}
315#endif
316//******************************************************************************
317//******************************************************************************
318BOOL WIN32API IsIconic( HWND hwnd)
319{
320 Win32BaseWindow *window;
321
322 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
323 if(!window) {
324 dprintf(("IsIconic, window %x not found", hwnd));
325 return 0;
326 }
327 dprintf(("IsIconic %x", hwnd));
328 return window->IsIconic();
329}
330//******************************************************************************
331//******************************************************************************
332HWND WIN32API GetWindow(HWND hwnd, UINT uCmd)
333{
334 Win32BaseWindow *window;
335
336 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
337 if(!window) {
338 dprintf(("GetWindow, window %x not found", hwnd));
339 return 0;
340 }
341 dprintf(("GetWindow %x %d", hwnd, uCmd));
342 return window->GetWindow(uCmd);
343}
344//******************************************************************************
345//******************************************************************************
346BOOL WIN32API EnableWindow( HWND hwnd, BOOL fEnable)
347{
348 Win32BaseWindow *window;
349
350 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
351 if(!window) {
352 dprintf(("EnableWindow, window %x not found", hwnd));
353 return 0;
354 }
355 dprintf(("EnableWindow %x %d", hwnd, fEnable));
356 return window->EnableWindow(fEnable);
357}
358//******************************************************************************
359//******************************************************************************
360BOOL WIN32API BringWindowToTop(HWND hwnd)
361{
362 return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
363}
364//******************************************************************************
365//******************************************************************************
366HWND WIN32API GetActiveWindow()
367{
368 return Win32BaseWindow::GetActiveWindow();
369}
370//******************************************************************************
371//******************************************************************************
372BOOL WIN32API ShowWindow(HWND hwnd, int nCmdShow)
373{
374 Win32BaseWindow *window;
375
376 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
377 if(!window) {
378 dprintf(("ShowWindow, window %x not found", hwnd));
379 return 0;
380 }
381 dprintf(("ShowWindow %x", hwnd));
382 return window->ShowWindow(nCmdShow);
383}
384//******************************************************************************
385//******************************************************************************
386BOOL WIN32API SetWindowPos(HWND hwnd, HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
387{
388 Win32BaseWindow *window;
389
390 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
391 if(!window) {
392 dprintf(("SetWindowPos, window %x not found", hwnd));
393 return 0;
394 }
395 dprintf(("SetWindowPos %x %x x=%d y=%d cx=%d cy=%d %x", hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
396 return window->SetWindowPos(hwndInsertAfter, x, y, cx, cy, fuFlags);
397}
398//******************************************************************************
399//******************************************************************************
400BOOL WIN32API SetWindowPlacement( HWND arg1, const WINDOWPLACEMENT * arg2)
401{
402 dprintf(("USER32: SetWindowPlacement\n"));
403 return O32_SetWindowPlacement(arg1, arg2);
404}
405//******************************************************************************
406//******************************************************************************
407BOOL WIN32API GetWindowPlacement( HWND arg1, LPWINDOWPLACEMENT arg2)
408{
409#ifdef DEBUG
410 WriteLog("USER32: GetWindowPlacement\n");
411#endif
412 return O32_GetWindowPlacement(arg1, arg2);
413}
414//******************************************************************************
415//******************************************************************************
416BOOL WIN32API IsWindow( HWND hwnd)
417{
418 Win32BaseWindow *window;
419
420 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
421 if(!window) {
422 dprintf(("IsWindow, window %x not found", hwnd));
423 return FALSE;
424 }
425 dprintf(("IsWindow %x", hwnd));
426 return window->IsWindow();
427}
428//******************************************************************************
429//******************************************************************************
430BOOL WIN32API IsWindowEnabled( HWND hwnd)
431{
432 Win32BaseWindow *window;
433
434 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
435 if(!window) {
436 dprintf(("IsWindowEnabled, window %x not found", hwnd));
437 return 0;
438 }
439 dprintf(("IsWindowEnabled %x", hwnd));
440 return window->IsWindowEnabled();
441}
442//******************************************************************************
443//******************************************************************************
444BOOL WIN32API IsWindowVisible( HWND hwnd)
445{
446 Win32BaseWindow *window;
447
448 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
449 if(!window) {
450 dprintf(("IsWindowVisible, window %x not found", hwnd));
451 return 0;
452 }
453 dprintf(("IsWindowVisible %x", hwnd));
454 return window->IsWindowVisible();
455}
456//******************************************************************************
457//******************************************************************************
458HWND WIN32API SetFocus( HWND hwnd)
459{
460 HWND lastFocus;
461
462 dprintf(("USER32: SetFocus\n"));
463
464 lastFocus = GetFocus();
465 hwnd = Win32BaseWindow::Win32ToOS2Handle(hwnd);
466 return (OSLibWinSetFocus(OSLIB_HWND_DESKTOP,hwnd)) ? lastFocus:0;
467}
468//******************************************************************************
469//******************************************************************************
470HWND WIN32API GetFocus(void)
471{
472 HWND hwnd;
473// dprintf(("USER32: GetFocus\n"));
474
475 hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP);
476 return Win32BaseWindow::OS2ToWin32Handle(hwnd);
477}
478//******************************************************************************
479//******************************************************************************
480/***********************************************************************
481 * GetInternalWindowPos (USER32.245)
482 */
483UINT WIN32API GetInternalWindowPos(HWND hwnd,
484 LPRECT rectWnd,
485 LPPOINT ptIcon )
486{
487 WINDOWPLACEMENT wndpl;
488
489 dprintf(("USER32: GetInternalWindowPos(%08xh,%08xh,%08xh)\n",
490 hwnd,
491 rectWnd,
492 ptIcon));
493
494 if (GetWindowPlacement( hwnd, &wndpl ))
495 {
496 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
497 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
498 return wndpl.showCmd;
499 }
500 return 0;
501}
502//******************************************************************************
503//******************************************************************************
504BOOL WIN32API IsZoomed( HWND arg1)
505{
506#ifdef DEBUG
507 WriteLog("USER32: IsZoomed\n");
508#endif
509 return O32_IsZoomed(arg1);
510}
511//******************************************************************************
512//******************************************************************************
513BOOL WIN32API LockWindowUpdate( HWND arg1)
514{
515#ifdef DEBUG
516 WriteLog("USER32: LockWindowUpdate\n");
517#endif
518 return O32_LockWindowUpdate(arg1);
519}
520//******************************************************************************
521//******************************************************************************
522
523#if 0
524BOOL WIN32API RedrawWindow( HWND arg1, const RECT * arg2, HRGN arg3, UINT arg4)
525{
526 BOOL rc;
527
528 rc = O32_RedrawWindow(arg1, arg2, arg3, arg4);
529#ifdef DEBUG
530 WriteLog("USER32: RedrawWindow %X , %X, %X, %X returned %d\n", arg1, arg2, arg3, arg4, rc);
531#endif
532 InvalidateRect(arg1, arg2, TRUE);
533 UpdateWindow(arg1);
534 SendMessageA(arg1, WM_PAINT, 0, 0);
535 return(rc);
536}
537#endif
538//******************************************************************************
539//******************************************************************************
540BOOL WIN32API GetWindowRect( HWND hwnd, PRECT pRect)
541{
542 Win32BaseWindow *window;
543
544 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
545 if(!window) {
546 dprintf(("GetWindowRect, window %x not found", hwnd));
547 return 0;
548 }
549 dprintf(("GetWindowRect %x", hwnd));
550 return window->GetWindowRect(pRect);
551}
552//******************************************************************************
553//******************************************************************************
554int WIN32API GetWindowTextLengthA( HWND hwnd)
555{
556 Win32BaseWindow *window;
557
558 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
559 if(!window) {
560 dprintf(("GetWindowTextLength, window %x not found", hwnd));
561 return 0;
562 }
563 dprintf(("GetWindowTextLength %x", hwnd));
564 return window->GetWindowTextLength();
565}
566//******************************************************************************
567//******************************************************************************
568int WIN32API GetWindowTextA( HWND hwnd, LPSTR lpsz, int cch)
569{
570 Win32BaseWindow *window;
571 int rc;
572
573 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
574 if(!window) {
575 dprintf(("GetWindowTextA, window %x not found", hwnd));
576 return 0;
577 }
578 rc = window->GetWindowTextA(lpsz, cch);
579 dprintf(("GetWindowTextA %x %s", hwnd, lpsz));
580 return rc;
581}
582//******************************************************************************
583//******************************************************************************
584int WIN32API GetWindowTextLengthW( HWND hwnd)
585{
586 dprintf(("USER32: GetWindowTextLengthW\n"));
587 return GetWindowTextLengthA(hwnd);
588}
589//******************************************************************************
590//******************************************************************************
591int WIN32API GetWindowTextW(HWND hwnd, LPWSTR lpsz, int cch)
592{
593 Win32BaseWindow *window;
594
595 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
596 if(!window) {
597 dprintf(("GetWindowTextW, window %x not found", hwnd));
598 return 0;
599 }
600 dprintf(("GetWindowTextW %x", hwnd));
601 return window->GetWindowTextW(lpsz, cch);
602}
603//******************************************************************************
604//******************************************************************************
605BOOL WIN32API SetWindowTextA(HWND hwnd, LPCSTR lpsz)
606{
607 Win32BaseWindow *window;
608
609 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
610 if(!window) {
611 dprintf(("SetWindowTextA, window %x not found", hwnd));
612 return 0;
613 }
614 dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
615 return window->SetWindowTextA((LPSTR)lpsz);
616}
617//******************************************************************************
618//******************************************************************************
619BOOL WIN32API SetWindowTextW( HWND hwnd, LPCWSTR lpsz)
620{
621 Win32BaseWindow *window;
622
623 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
624 if(!window) {
625 dprintf(("SetWindowTextA, window %x not found", hwnd));
626 return 0;
627 }
628 dprintf(("SetWindowTextW %x", hwnd));
629 return window->SetWindowTextW((LPWSTR)lpsz);
630}
631/*******************************************************************
632 * InternalGetWindowText (USER32.326)
633 */
634int WIN32API InternalGetWindowText(HWND hwnd,
635 LPWSTR lpString,
636 INT nMaxCount )
637{
638 dprintf(("USER32: InternalGetWindowText(%08xh,%08xh,%08xh) not properly implemented.\n",
639 hwnd,
640 lpString,
641 nMaxCount));
642
643 return GetWindowTextW(hwnd,lpString,nMaxCount);
644}
645//******************************************************************************
646//TODO: Correct?
647//******************************************************************************
648BOOL WIN32API SetForegroundWindow(HWND hwnd)
649{
650 dprintf((" SetForegroundWindow %x", hwnd));
651
652 return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER );
653}
654//******************************************************************************
655//******************************************************************************
656BOOL WIN32API GetClientRect( HWND hwnd, PRECT pRect)
657{
658 BOOL rc;
659
660 hwnd = Win32BaseWindow::Win32ToOS2Handle(hwnd);
661 rc = OSLibWinQueryWindowRect(hwnd, pRect);
662 dprintf(("USER32: GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
663 return rc;
664}
665//******************************************************************************
666//******************************************************************************
667BOOL WIN32API AdjustWindowRect( PRECT arg1, DWORD arg2, BOOL arg3)
668{
669#ifdef DEBUG
670 WriteLog("USER32: AdjustWindowRect\n");
671#endif
672 return O32_AdjustWindowRect(arg1, arg2, arg3);
673}
674//******************************************************************************
675//******************************************************************************
676BOOL WIN32API AdjustWindowRectEx( PRECT arg1, DWORD arg2, BOOL arg3, DWORD arg4)
677{
678#ifdef DEBUG
679 WriteLog("USER32: AdjustWindowRectEx\n");
680#endif
681 return O32_AdjustWindowRectEx(arg1, arg2, arg3, arg4);
682}
683//******************************************************************************
684//******************************************************************************
685HWND WIN32API GetDesktopWindow(void)
686{
687 dprintf(("USER32: GetDesktopWindow\n"));
688 return OSLIB_HWND_DESKTOP;
689}
690//******************************************************************************
691//******************************************************************************
692HWND WIN32API FindWindowA(LPCSTR lpszClass, LPCSTR lpszWindow)
693{
694 if(!lpszClass) {
695 SetLastError(ERROR_INVALID_PARAMETER);
696 return 0;
697 }
698 if(HIWORD(lpszClass)) {
699 dprintf(("USER32: FindWindow %s %s\n", lpszClass, lpszWindow));
700 }
701 else dprintf(("USER32: FindWindow %x %s\n", lpszClass, lpszWindow));
702
703 return Win32BaseWindow::FindWindowEx(OSLIB_HWND_DESKTOP, 0, (LPSTR)lpszClass, (LPSTR)lpszWindow);
704}
705//******************************************************************************
706//******************************************************************************
707HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow)
708{
709 if(!lpszClass) {
710 SetLastError(ERROR_INVALID_PARAMETER);
711 return 0;
712 }
713 if(HIWORD(lpszClass)) {
714 dprintf(("USER32: FindWindowExA (%x,%x) %s %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
715 }
716 else dprintf(("USER32: FindWindowExA (%x,%x)%x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
717
718 return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
719}
720/*****************************************************************************
721 * Name : HWND WIN32API FindWindowExW
722 * Purpose : The FindWindowEx function retrieves the handle of a window whose
723 * class name and window name match the specified strings. The
724 * function searches child windows, beginning with the one following
725 * the given child window.
726 * Parameters: HWND hwndParent handle of parent window
727 * HWND hwndChildAfter handle of a child window
728 * LPCTSTR lpszClass address of class name
729 * LPCTSTR lpszWindow address of window name
730 * Variables :
731 * Result : If the function succeeds, the return value is the handle of the
732 * window that has the specified class and window names.
733 * If the function fails, the return value is NULL. To get extended
734 * error information, call GetLastError.
735 * Remark :
736 * Status : UNTESTED STUB
737 *
738 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
739 *****************************************************************************/
740
741HWND WIN32API FindWindowExW(HWND hwndParent,
742 HWND hwndChildAfter,
743 LPCWSTR lpszClass,
744 LPCWSTR lpszWindow)
745{
746 if(!lpszClass) {
747 SetLastError(ERROR_INVALID_PARAMETER);
748 return 0;
749 }
750 dprintf(("USER32: FindWindowExW (%x,%x) %x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
751
752 return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
753}
754//******************************************************************************
755//******************************************************************************
756BOOL WIN32API FlashWindow(HWND hwnd, BOOL fFlash)
757{
758 dprintf(("FlashWindow %x %d\n", hwnd, fFlash));
759 return OSLibWinFlashWindow(Win32BaseWindow::Win32ToOS2Handle(hwnd), fFlash);
760}
761//******************************************************************************
762//******************************************************************************
763BOOL WIN32API MoveWindow( HWND hwnd, INT x, INT y, INT cx, INT cy,
764 BOOL repaint )
765{
766 int flags = SWP_NOZORDER | SWP_NOACTIVATE;
767
768 if (!repaint) flags |= SWP_NOREDRAW;
769 dprintf(("MoveWindow: %04x %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ));
770
771 return SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
772}
773//******************************************************************************
774//******************************************************************************
775BOOL WIN32API ClientToScreen( HWND arg1, PPOINT arg2)
776{
777#ifdef DEBUG
778//// WriteLog("USER32: ClientToScreen\n");
779#endif
780 return O32_ClientToScreen(arg1, arg2);
781}
782//******************************************************************************
783//******************************************************************************
784HDWP WIN32API BeginDeferWindowPos( int arg1)
785{
786#ifdef DEBUG
787 WriteLog("USER32: BeginDeferWindowPos\n");
788#endif
789 return O32_BeginDeferWindowPos(arg1);
790}
791//******************************************************************************
792//******************************************************************************
793HDWP WIN32API DeferWindowPos( HDWP arg1, HWND arg2, HWND arg3, int arg4, int arg5, int arg6, int arg7, UINT arg8)
794{
795#ifdef DEBUG
796 WriteLog("USER32: DeferWindowPos\n");
797#endif
798 return O32_DeferWindowPos(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
799}
800//******************************************************************************
801//******************************************************************************
802HWND WIN32API ChildWindowFromPoint( HWND arg1, POINT arg2)
803{
804#ifdef DEBUG
805 WriteLog("USER32: ChildWindowFromPoint\n");
806#endif
807 return O32_ChildWindowFromPoint(arg1, arg2);
808}
809//******************************************************************************
810//******************************************************************************
811/*****************************************************************************
812 * Name : HWND WIN32API ChildWindowFromPointEx
813 * Purpose : The GetWindowRect function retrieves the dimensions of the
814 * bounding rectangle of the specified window. The dimensions are
815 * given in screen coordinates that are relative to the upper-left
816 * corner of the screen.
817 * Parameters:
818 * Variables :
819 * Result : If the function succeeds, the return value is the window handle.
820 * If the function fails, the return value is zero
821 * Remark :
822 * Status : FULLY IMPLEMENTED AND TESTED
823 *
824 * Author : Rene Pronk [Sun, 1999/08/08 23:30]
825 *****************************************************************************/
826
827HWND WIN32API ChildWindowFromPointEx (HWND hwndParent, POINT pt, UINT uFlags)
828{
829 RECT rect;
830 HWND hWnd;
831 POINT absolutePt;
832
833 dprintf(("USER32: ChildWindowFromPointEx(%08xh,%08xh,%08xh).\n",
834 hwndParent, pt, uFlags));
835
836 if (GetWindowRect (hwndParent, &rect) == 0) {
837 // oops, invalid handle
838 return NULL;
839 }
840
841 // absolutePt has its top in the upper-left corner of the screen
842 absolutePt = pt;
843 ClientToScreen (hwndParent, &absolutePt);
844
845 // make rect the size of the parent window
846 GetWindowRect (hwndParent, &rect);
847 rect.right = rect.right - rect.left;
848 rect.bottom = rect.bottom - rect.top;
849 rect.left = 0;
850 rect.top = 0;
851
852 if (PtInRect (&rect, pt) == 0) {
853 // point is outside window
854 return NULL;
855 }
856
857 // get first child
858 hWnd = GetWindow (hwndParent, GW_CHILD);
859
860 while (hWnd != NULL) {
861
862 // do I need to skip this window?
863 if (((uFlags & CWP_SKIPINVISIBLE) &&
864 (IsWindowVisible (hWnd) == FALSE)) ||
865 ((uFlags & CWP_SKIPDISABLED) &&
866 (IsWindowEnabled (hWnd) == FALSE)) ||
867 ((uFlags & CWP_SKIPTRANSPARENT) &&
868 (GetWindowLongA (hWnd, GWL_EXSTYLE) & WS_EX_TRANSPARENT)))
869
870 {
871 hWnd = GetWindow (hWnd, GW_HWNDNEXT);
872 continue;
873 }
874
875 // is the point in this window's rect?
876 GetWindowRect (hWnd, &rect);
877 if (PtInRect (&rect, absolutePt) == FALSE) {
878 hWnd = GetWindow (hWnd, GW_HWNDNEXT);
879 continue;
880 }
881
882 // found it!
883 return hWnd;
884 }
885
886 // the point is in the parentwindow but the parentwindow has no child
887 // at this coordinate
888 return hwndParent;
889}
890//******************************************************************************
891//******************************************************************************
892BOOL WIN32API CloseWindow(HWND hwnd)
893{
894 Win32BaseWindow *window;
895
896 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
897 if(!window) {
898 dprintf(("CloseWindow, window %x not found", hwnd));
899 return 0;
900 }
901 dprintf(("CloseWindow %x\n", hwnd));
902 return window->CloseWindow();
903}
904//******************************************************************************
905//TODO: Does this return handles of hidden or disabled windows?
906//******************************************************************************
907HWND WIN32API WindowFromPoint( POINT point)
908{
909 HWND hwnd;
910
911 dprintf(("WindowFromPoint (%d,%d)\n", point.x, point.y));
912 hwnd = OSLibWinWindowFromPoint(OSLIB_HWND_DESKTOP, (PVOID)&point);
913 if(hwnd) {
914 return Win32BaseWindow::OS2ToWin32Handle(hwnd);
915 }
916 return 0;
917}
918//******************************************************************************
919//******************************************************************************
920BOOL WIN32API IsWindowUnicode(HWND hwnd)
921{
922 Win32BaseWindow *window;
923
924 window = Win32BaseWindow::GetWindowFromHandle(hwnd);
925 if(!window) {
926 dprintf(("IsWindowUnicode, window %x not found", hwnd));
927 return 0;
928 }
929 return window->IsUnicode();
930}
931/*****************************************************************************
932 * Name : WORD WIN32API CascadeWindows
933 * Purpose : The CascadeWindows function cascades the specified windows or
934 * the child windows of the specified parent window.
935 * Parameters: HWND hwndParent handle of parent window
936 * UINT wHow types of windows not to arrange
937 * CONST RECT * lpRect rectangle to arrange windows in
938 * UINT cKids number of windows to arrange
939 * const HWND FAR * lpKids array of window handles
940 * Variables :
941 * Result : If the function succeeds, the return value is the number of windows arranged.
942 * If the function fails, the return value is zero.
943 * Remark :
944 * Status : UNTESTED STUB
945 *
946 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
947 *****************************************************************************/
948
949WORD WIN32API CascadeWindows(HWND hwndParent,
950 UINT wHow,
951 CONST LPRECT lpRect,
952 UINT cKids,
953 const HWND *lpKids)
954{
955 dprintf(("USER32:CascadeWindows(%08xh,%u,%08xh,%u,%08x) not implemented.\n",
956 hwndParent,
957 wHow,
958 lpRect,
959 cKids,
960 lpKids));
961
962 return (0);
963}
964/*****************************************************************************
965 * Name : BOOL WIN32API SwitchToThisWindow
966 * Purpose : Unknown
967 * Parameters: Unknown
968 * Variables :
969 * Result :
970 * Remark :
971 * Status : UNTESTED UNKNOWN STUB
972 *
973 * Author : Patrick Haller [Wed, 1998/06/16 11:55]
974 *****************************************************************************/
975
976BOOL WIN32API SwitchToThisWindow(HWND hwnd,
977 BOOL x2)
978{
979 dprintf(("USER32: SwitchToThisWindow(%08xh,%08xh) not implemented.\n",
980 hwnd,
981 x2));
982
983 return (FALSE); /* default */
984}
985//******************************************************************************
986//******************************************************************************
987BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
988{
989 Win32BaseWindow *window;
990 BOOL rc;
991 ULONG henum;
992 HWND hwndNext;
993 ULONG tid;
994 ULONG pid, curpid;
995
996 dprintf(("EnumThreadWindows\n"));
997
998 curpid = GetCurrentProcessId();
999
1000 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
1001 while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
1002 {
1003 OSLibWinQueryWindowProcess(hwndNext, &pid, &tid);
1004 if(!(curpid == pid && dwThreadId == tid))
1005 continue;
1006
1007 window = Win32BaseWindow::GetWindowFromHandle(hwndNext);
1008 if(window == NULL) {
1009 //OS/2 window or non-frame window, so skip it
1010 continue;
1011 }
1012 if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE)
1013 break;
1014 }
1015 OSLibWinEndEnumWindows (henum);
1016 return TRUE;
1017}
1018//******************************************************************************
1019//******************************************************************************
1020BOOL WIN32API EnumChildWindows(HWND hwnd, WNDENUMPROC lpfn, LPARAM lParam)
1021{
1022 Win32BaseWindow *window, *parentwindow;
1023 BOOL rc = TRUE;
1024 ULONG henum;
1025 HWND hwndNext;
1026
1027 dprintf(("EnumChildWindows %x %x\n", hwnd, lParam));
1028
1029 parentwindow = Win32BaseWindow::GetWindowFromHandle(hwnd);
1030 if(!parentwindow) {
1031 dprintf(("EnumChildWindows, window %x not found", hwnd));
1032 return FALSE;
1033 }
1034
1035 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
1036 while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
1037 {
1038 window = Win32BaseWindow::GetWindowFromHandle(hwndNext);
1039 if(window == NULL) {
1040 //OS/2 window or non-frame window, so skip it
1041 continue;
1042 }
1043 if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE)
1044 {
1045 rc = FALSE;
1046 break;
1047 }
1048 }
1049 OSLibWinEndEnumWindows(henum);
1050 return rc;
1051}
1052//******************************************************************************
1053//******************************************************************************
1054BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
1055{
1056 Win32BaseWindow *window;
1057 BOOL rc;
1058 ULONG henum;
1059 HWND hwndNext, hwndParent = OSLIB_HWND_DESKTOP;
1060
1061 dprintf(("EnumThreadWindows\n"));
1062
1063 do {
1064 henum = OSLibWinBeginEnumWindows(hwndParent);
1065 while ((hwndNext = OSLibWinGetNextWindow(henum)) != 0)
1066 {
1067 window = Win32BaseWindow::GetWindowFromHandle(hwndNext);
1068 if(window == NULL) {
1069 //OS/2 window or non-frame window, so skip it
1070 continue;
1071 }
1072 if((rc = lpfn(window->getWindowHandle(), lParam)) == FALSE) {
1073 goto Abort;
1074 }
1075 }
1076 if(hwndParent == OSLIB_HWND_OBJECT)
1077 break;
1078 hwndParent = OSLIB_HWND_OBJECT;
1079 OSLibWinEndEnumWindows(henum);
1080 }
1081 while(TRUE);
1082
1083Abort:
1084 OSLibWinEndEnumWindows(henum);
1085 return TRUE;
1086}
1087//******************************************************************************
1088//******************************************************************************
1089#if 0
1090BOOL WIN32API GetUpdateRect( HWND hwnd, PRECT lpRect, BOOL bErase)
1091{
1092 dprintf(("GetUpdateRect %x %d\n", hwnd, bErase));
1093 if (!lpRect) return FALSE;
1094
1095 return OSLibWinQueryUpdateRect(Win32BaseWindow::Win32ToOS2Handle(hwnd), lpRect);
1096}
1097#endif
1098//******************************************************************************
1099//******************************************************************************
1100#if 0
1101BOOL WIN32API InvalidateRect(HWND hWnd, const RECT *lpRect, BOOL bErase)
1102{
1103#ifdef DEBUG
1104 if(lpRect)
1105 WriteLog("USER32: InvalidateRect for window %X (%d,%d)(%d,%d) %d\n", hWnd, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, bErase);
1106 else WriteLog("USER32: InvalidateRect for window %X NULL, %d\n", hWnd, bErase);
1107#endif
1108
1109 //CB: bErase no quite the same
1110 hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
1111 if (lpRect)
1112 {
1113 return OSLibWinInvalidateRect(hWnd, (PRECT)lpRect, bErase);
1114 }
1115 else return OSLibWinInvalidateRect(hWnd,NULL,bErase);
1116}
1117#endif
1118//******************************************************************************
1119//******************************************************************************
1120UINT WIN32API ArrangeIconicWindows( HWND arg1)
1121{
1122#ifdef DEBUG
1123 WriteLog("USER32: ArrangeIconicWindows\n");
1124#endif
1125 return O32_ArrangeIconicWindows(arg1);
1126}
1127//******************************************************************************
1128//restores iconized window to previous size/position
1129//******************************************************************************
1130BOOL WIN32API OpenIcon(HWND hwnd)
1131{
1132#ifdef DEBUG
1133 WriteLog("USER32: OpenIcon\n");
1134#endif
1135 if(!IsIconic(hwnd))
1136 return FALSE;
1137 ShowWindow(hwnd, SW_SHOWNORMAL);
1138 return TRUE;
1139}
1140//******************************************************************************
1141//******************************************************************************
1142BOOL WIN32API ShowOwnedPopups( HWND arg1, BOOL arg2)
1143{
1144 dprintf(("USER32: ShowOwnedPopups\n"));
1145 return O32_ShowOwnedPopups(arg1, arg2);
1146}
1147//******************************************************************************
1148//******************************************************************************
Note: See TracBrowser for help on using the repository browser.