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

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

Cursor fixes + minor change to RedrawWindow

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