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

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

Rene Pronk's WM_(SYS)KEYUP/DOWN changes + SvL's dialog changes

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