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

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

Dialog update

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