source: trunk/src/user32/win32wbase.cpp@ 2680

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

Shell positioning fix for Notes

File size: 103.2 KB
Line 
1/* $Id: win32wbase.cpp,v 1.159 2000-02-08 10:30:03 sandervl Exp $ */
2/*
3 * Win32 Window Base Class for OS/2
4 *
5 * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
6 * Copyright 1999 Daniela Engert (dani@ngrt.de)
7 * Copyright 1999-2000 Christoph Bratschi (cbratschi@datacomm.ch)
8 *
9 * Parts based on Wine Windows code (windows\win.c)
10 *
11 * Copyright 1993, 1994, 1996 Alexandre Julliard
12 * 1995 Alex Korobka
13 *
14 * TODO: Not thread/process safe
15 *
16 * NOTE: Client rectangle always relative to frame window; window rectangle in screen coordinates
17 *
18 * Project Odin Software License can be found in LICENSE.TXT
19 *
20 */
21#include <os2win.h>
22#include <win.h>
23#include <stdlib.h>
24#include <string.h>
25#include <stdarg.h>
26#include <assert.h>
27#include <misc.h>
28#include <heapstring.h>
29#include <win32wbase.h>
30#include <winres.h>
31#include "wndmsg.h"
32#include "oslibwin.h"
33#include "oslibmsg.h"
34#include "oslibutil.h"
35#include "oslibgdi.h"
36#include "oslibres.h"
37#include "oslibdos.h"
38#include "syscolor.h"
39#include "win32wndhandle.h"
40#include "dc.h"
41#include "pmframe.h"
42#include "win32wdesktop.h"
43#include "pmwindow.h"
44#include "controls.h"
45#include <wprocess.h>
46#include "winmouse.h"
47#include <win\hook.h>
48#include <menu.h>
49#define INCL_TIMERWIN32
50#include "timer.h"
51
52#define SC_ABOUTWINE (SC_SCREENSAVE+1)
53#define SC_PUTMARK (SC_SCREENSAVE+2)
54
55/* bits in the dwKeyData */
56#define KEYDATA_ALT 0x2000
57#define KEYDATA_PREVSTATE 0x4000
58
59void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle);
60
61static fDestroyAll = FALSE;
62//For quick lookup of current process id
63static ULONG currentProcessId = -1;
64
65//******************************************************************************
66//******************************************************************************
67Win32BaseWindow::Win32BaseWindow(DWORD objType) : GenericObject(&windows, objType)
68{
69 Init();
70}
71//******************************************************************************
72//******************************************************************************
73Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
74 : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
75{
76 Init();
77 this->isUnicode = isUnicode;
78 CreateWindowExA(lpCreateStructA, classAtom);
79}
80//******************************************************************************
81//******************************************************************************
82void Win32BaseWindow::Init()
83{
84 isUnicode = FALSE;
85 fFirstShow = TRUE;
86 fIsDialog = FALSE;
87 fIsModalDialogOwner = FALSE;
88 OS2HwndModalDialog = 0;
89 fInternalMsg = FALSE;
90 fNoSizeMsg = FALSE;
91 fIsDestroyed = FALSE;
92 fDestroyWindowCalled = FALSE;
93 fCreated = FALSE;
94 fTaskList = FALSE;
95 fParentDC = FALSE;
96
97 windowNameA = NULL;
98 windowNameW = NULL;
99 wndNameLength = 0;
100
101 userWindowLong = NULL;;
102 nrUserWindowLong = 0;
103
104 magic = WIN32PM_MAGIC;
105 OS2Hwnd = 0;
106 OS2HwndFrame = 0;
107 hSysMenu = 0;
108 Win32Hwnd = 0;
109
110 if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE)
111 {
112 dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
113 DebugInt3();
114 }
115
116 posx = posy = 0;
117 width = height = 0;
118
119 dwExStyle = 0;
120 dwStyle = 0;
121 win32wndproc = 0;
122 hInstance = 0;
123 dwIDMenu = 0; //0xFFFFFFFF; //default -1
124 userData = 0;
125 contextHelpId = 0;
126 hotkey = 0;
127
128 pOldFrameProc = NULL;
129
130 hwndLinkAfter = HWND_BOTTOM;
131 flags = 0;
132 isIcon = FALSE;
133 lastHitTestVal = HTOS_NORMAL;
134 owner = NULL;
135 windowClass = 0;
136
137 iconResource = NULL;
138
139 EraseBkgndFlag = TRUE;
140 PSEraseFlag = FALSE;
141 SuppressEraseFlag = FALSE;
142
143 horzScrollInfo = NULL;
144 vertScrollInfo = NULL;
145
146 ownDC = 0;
147 hWindowRegion = 0;
148 hClipRegion = 0;
149
150 if(currentProcessId == -1)
151 {
152 currentProcessId = GetCurrentProcessId();
153 }
154 dwThreadId = GetCurrentThreadId();
155 dwProcessId = currentProcessId;
156}
157//******************************************************************************
158//todo get rid of resources (menu, icon etc)
159//******************************************************************************
160Win32BaseWindow::~Win32BaseWindow()
161{
162 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
163 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
164
165 if(!fDestroyAll && getParent() && getParent()->getFirstChild() == this && getNextChild() == NULL)
166 {
167 //if we're the last child that's being destroyed and our
168 //parent window was also destroyed, then we delete the parent object
169 if(getParent()->IsWindowDestroyed())
170 {
171 dprintf(("Last Child (%x) destroyed, get rid of our parent window (%x)", getWindowHandle(), getParent()->getWindowHandle()));
172 delete getParent();
173 setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
174 }
175 }
176 else
177 if(fDestroyAll) {
178 dprintf(("Destroying window %x %s", getWindowHandle(), windowNameA));
179 setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
180 }
181
182 if(isOwnDC())
183 releaseOwnDC(ownDC);
184
185 if(Win32Hwnd)
186 HwFreeWindowHandle(Win32Hwnd);
187
188 if(userWindowLong)
189 free(userWindowLong);
190
191 if(windowNameA) {
192 free(windowNameA);
193 windowNameA = NULL;
194 }
195 if(windowNameW) {
196 free(windowNameW);
197 windowNameW = NULL;
198 }
199 if(vertScrollInfo) {
200 free(vertScrollInfo);
201 vertScrollInfo = NULL;
202 }
203 if(horzScrollInfo) {
204 free(horzScrollInfo);
205 horzScrollInfo = NULL;
206 }
207}
208//******************************************************************************
209//******************************************************************************
210void Win32BaseWindow::DestroyAll()
211{
212 fDestroyAll = TRUE;
213 GenericObject::DestroyAll(windows);
214}
215//******************************************************************************
216//******************************************************************************
217BOOL Win32BaseWindow::isChild()
218{
219 return ((dwStyle & WS_CHILD) != 0);
220}
221//******************************************************************************
222//******************************************************************************
223BOOL Win32BaseWindow::IsWindowUnicode()
224{
225 dprintf2(("IsWindowUnicode %x %d", getWindowHandle(), WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W));
226 return (WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W);
227}
228//******************************************************************************
229//******************************************************************************
230BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom)
231{
232 char buffer[256];
233
234#ifdef DEBUG
235 PrintWindowStyle(cs->style, cs->dwExStyle);
236#endif
237
238 sw = SW_SHOW;
239 SetLastError(0);
240
241 /* Find the parent window */
242 if (cs->hwndParent)
243 {
244 Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
245 if(!window) {
246 dprintf(("Bad parent %04x\n", cs->hwndParent ));
247 SetLastError(ERROR_INVALID_PARAMETER);
248 return FALSE;
249 }
250 /* Make sure parent is valid */
251 if (!window->IsWindow() )
252 {
253 dprintf(("Bad parent %04x\n", cs->hwndParent ));
254 SetLastError(ERROR_INVALID_PARAMETER);
255 return FALSE;
256 }
257 }
258 else
259 if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
260 dprintf(("No parent for child window\n" ));
261 SetLastError(ERROR_INVALID_PARAMETER);
262 return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
263 }
264
265 /* Find the window class */
266 windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
267 if (!windowClass)
268 {
269 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
270 dprintf(("Bad class '%s'\n", buffer ));
271 SetLastError(ERROR_INVALID_PARAMETER);
272 return 0;
273 }
274#ifdef DEBUG
275 if(HIWORD(cs->lpszClass))
276 {
277 char *astring;
278
279 if(isUnicode) astring = UnicodeToAsciiString((LPWSTR)cs->lpszClass);
280 else astring = (char *)cs->lpszClass;
281
282 dprintf(("Window class %s", astring));
283 if(isUnicode) FreeAsciiString(astring);
284 }
285 else dprintf(("Window class %x", cs->lpszClass));
286#endif
287
288 /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
289 * with an atom as the class name, put some programs expect to have a *REAL* string in
290 * lpszClass when the CREATESTRUCT is sent with WM_CREATE
291 */
292 if (!HIWORD(cs->lpszClass) ) {
293 if (isUnicode) {
294 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
295 }
296 else {
297 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
298 }
299 cs->lpszClass = buffer;
300 }
301
302 /* Fix the coordinates */
303 fXDefault = FALSE;
304 fCXDefault = FALSE;
305 if ((cs->x == CW_USEDEFAULT) || (cs->x == CW_USEDEFAULT16))
306 {
307 /* Never believe Microsoft's documentation... CreateWindowEx doc says
308 * that if an overlapped window is created with WS_VISIBLE style bit
309 * set and the x parameter is set to CW_USEDEFAULT, the system ignores
310 * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
311 * reveals that
312 *
313 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
314 * 2) it does not ignore the y parameter as the docs claim; instead, it
315 * uses it as second parameter to ShowWindow() unless y is either
316 * CW_USEDEFAULT or CW_USEDEFAULT16.
317 *
318 * The fact that we didn't do 2) caused bogus windows pop up when wine
319 * was running apps that were using this obscure feature. Example -
320 * calc.exe that comes with Win98 (only Win98, it's different from
321 * the one that comes with Win95 and NT)
322 */
323 if ((cs->y != CW_USEDEFAULT) && (cs->y != CW_USEDEFAULT16)) sw = cs->y;
324
325 /* We have saved cs->y, now we can trash it */
326 cs->x = 0;
327 cs->y = 0;
328 fXDefault = TRUE;
329 }
330 if ((cs->cx == CW_USEDEFAULT) || (cs->cx == CW_USEDEFAULT16))
331 {
332 cs->cx = 600; /* FIXME */
333 cs->cy = 400;
334 fCXDefault = TRUE;
335 }
336 if (fXDefault && !fCXDefault) fXDefault = FALSE; //CB: only x positioning doesn't work (calc.exe,cdrlabel.exe)
337
338 if (cs->x < 0) cs->x = 0;
339 if (cs->y < 0) cs->y = 0;
340
341 //Allocate window words
342 nrUserWindowLong = windowClass->getExtraWndWords();
343 if(nrUserWindowLong) {
344 userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
345 memset(userWindowLong, 0, nrUserWindowLong);
346 }
347
348 if ((cs->style & WS_CHILD) && cs->hwndParent)
349 {
350 SetParent(cs->hwndParent);
351 owner = GetWindowFromHandle(cs->hwndParent);
352 if(owner == NULL)
353 {
354 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
355 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
356 return FALSE;
357 }
358 //SvL: Shell positioning shouldn't be done for child windows! (breaks Notes)
359 fXDefault = fCXDefault = FALSE;
360 }
361 else
362 {
363 SetParent(0);
364 if (!cs->hwndParent || (cs->hwndParent == windowDesktop->getWindowHandle())) {
365 owner = NULL;
366 }
367 else
368 {
369 owner = GetWindowFromHandle(cs->hwndParent)->GetTopParent();
370 if(owner == NULL)
371 {
372 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
373 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
374 return FALSE;
375 }
376 }
377 }
378
379 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc(), WINPROC_GetProcType(windowClass->getWindowProc()), WIN_PROC_WINDOW);
380 hInstance = cs->hInstance;
381 dwStyle = cs->style & ~WS_VISIBLE;
382 dwExStyle = cs->dwExStyle;
383
384 hwndLinkAfter = HWND_TOP;
385 if(CONTROLS_IsControl(this, BUTTON_CONTROL) && ((dwStyle & 0x0f) == BS_GROUPBOX))
386 {
387 hwndLinkAfter = HWND_BOTTOM;
388 dwStyle |= WS_CLIPSIBLINGS;
389 }
390 else
391 if(CONTROLS_IsControl(this, STATIC_CONTROL) && !(dwStyle & WS_GROUP)) {
392 dwStyle |= WS_CLIPSIBLINGS;
393 }
394
395 /* Increment class window counter */
396 windowClass->IncreaseWindowCount();
397
398 if (HOOK_IsHooked( WH_CBT ))
399 {
400 CBT_CREATEWNDA cbtc;
401 LRESULT ret;
402
403 cbtc.lpcs = cs;
404 cbtc.hwndInsertAfter = hwndLinkAfter;
405 ret = HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc);
406 if(ret)
407 {
408 dprintf(("CBT-hook returned 0!!"));
409 SetLastError(ERROR_CAN_NOT_COMPLETE); //todo: wrong error
410 return FALSE;
411 }
412 }
413
414 /* Correct the window style */
415 if (!(cs->style & WS_CHILD))
416 {
417 dwStyle |= WS_CLIPSIBLINGS;
418 if (!(cs->style & WS_POPUP))
419 {
420 dwStyle |= WS_CAPTION;
421 flags |= WIN_NEED_SIZE;
422 }
423 }
424 if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
425
426 if (cs->style & WS_HSCROLL)
427 {
428 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
429 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
430 horzScrollInfo->MaxVal = 100;
431 horzScrollInfo->flags = ESB_ENABLE_BOTH;
432 }
433
434 if (cs->style & WS_VSCROLL)
435 {
436 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
437 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
438 vertScrollInfo->MaxVal = 100;
439 vertScrollInfo->flags = ESB_ENABLE_BOTH;
440 }
441
442 if(HIWORD(cs->lpszName))
443 {
444 if (!isUnicode)
445 {
446 wndNameLength = strlen(cs->lpszName);
447 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
448 strcpy(windowNameA,cs->lpszName);
449 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
450 lstrcpyAtoW(windowNameW,windowNameA);
451 windowNameA[wndNameLength] = 0;
452 windowNameW[wndNameLength] = 0;
453 }
454 else
455 {
456 wndNameLength = lstrlenW((LPWSTR)cs->lpszName);
457 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
458 lstrcpyWtoA(windowNameA,(LPWSTR)cs->lpszName);
459 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
460 lstrcpyW(windowNameW,(LPWSTR)cs->lpszName);
461 windowNameA[wndNameLength] = 0;
462 windowNameW[wndNameLength] = 0;
463 }
464 }
465
466 //copy pointer of CREATESTRUCT for usage in MsgCreate method
467 tmpcs = cs;
468
469 //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it
470 THDB *thdb = GetThreadTHDB();
471
472 if(thdb == NULL) {
473 dprintf(("Window creation failed - thdb == NULL")); //this is VERY bad
474 ExitProcess(666);
475 return FALSE;
476 }
477
478 thdb->newWindow = (ULONG)this;
479
480 DWORD dwOSWinStyle;
481
482 OSLibWinConvertStyle(dwStyle,dwExStyle,&dwOSWinStyle);
483 if (((dwStyle & (WS_CAPTION | WS_SYSMENU | 0xC0000000)) == (WS_CAPTION | WS_SYSMENU))) fTaskList = TRUE;
484
485 OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
486 dwOSWinStyle,(char *)windowNameA,
487 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
488 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
489 &OS2HwndFrame, 0, fTaskList,fXDefault | fCXDefault,windowClass->getStyle() & CS_SAVEBITS);
490 if(OS2Hwnd == 0) {
491 dprintf(("Window creation failed!!"));
492 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
493 return FALSE;
494 }
495
496 SetLastError(0);
497 return TRUE;
498}
499//******************************************************************************
500//******************************************************************************
501BOOL Win32BaseWindow::MsgCreate(HWND hwndFrame, HWND hwndClient)
502{
503 CREATESTRUCTA *cs = tmpcs; //pointer to CREATESTRUCT used in CreateWindowExA method
504 POINT maxSize, maxPos, minTrack, maxTrack;
505
506 OS2Hwnd = hwndClient;
507 OS2HwndFrame = hwndFrame;
508
509 fNoSizeMsg = TRUE;
510
511 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
512 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
513 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
514 return FALSE;
515 }
516 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
517 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
518 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
519 return FALSE;
520 }
521
522 //adjust CW_USEDEFAULT position
523 if (fXDefault | fCXDefault)
524 {
525 RECT rect;
526
527 OSLibWinQueryWindowRect(OS2HwndFrame,&rect,RELATIVE_TO_SCREEN);
528 if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rect);
529 if (fXDefault)
530 {
531 cs->x = rect.left;
532 cs->y = rect.top;
533 if (!fCXDefault)
534 {
535 //CB: todo: adjust pos to screen rect
536 }
537 }
538 if (fCXDefault)
539 {
540 cs->cx = rect.right-rect.left;
541 cs->cy = rect.bottom-rect.top;
542 }
543 }
544
545 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
546 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
547 {
548 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
549 if (maxSize.x < cs->cx) cs->cx = maxSize.x;
550 if (maxSize.y < cs->cy) cs->cy = maxSize.y;
551 if (cs->cx < minTrack.x) cs->cx = minTrack.x;
552 if (cs->cy < minTrack.y) cs->cy = minTrack.y;
553 }
554
555 if(cs->style & WS_CHILD)
556 {
557 if(cs->cx < 0) cs->cx = 0;
558 if(cs->cy < 0) cs->cy = 0;
559 }
560 else
561 {
562 if (cs->cx <= 0) cs->cx = 1;
563 if (cs->cy <= 0) cs->cy = 1;
564 }
565
566 OSLibWinSetOwner(OS2Hwnd, OS2HwndFrame);
567
568 fakeWinBase.hwndThis = OS2Hwnd;
569 fakeWinBase.pWindowClass = windowClass;
570
571 //Set icon from class
572 if(windowClass->getIcon())
573 SetIcon(windowClass->getIcon());
574 /* Get class or window DC if needed */
575 if(windowClass->getStyle() & CS_OWNDC) {
576 dprintf(("Class with CS_OWNDC style"));
577 ownDC = GetDC(getWindowHandle()); //TODO: or GetWindowDC???
578 }
579 else
580 if (windowClass->getStyle() & CS_PARENTDC) {
581 dprintf(("WARNING: Class with CS_PARENTDC style!"));
582 fParentDC = TRUE;
583 ownDC = 0;
584 }
585 else
586 if (windowClass->getStyle() & CS_CLASSDC) {
587 dprintf(("WARNING: Class with CS_CLASSDC style!"));
588 ownDC = 0;
589 }
590 /* Set the window menu */
591 if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
592 {
593 if (cs->hMenu) {
594 ::SetMenu(getWindowHandle(), cs->hMenu);
595 }
596 else {
597 if (windowClass->getMenuNameA()) {
598 cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
599 if (cs->hMenu) ::SetMenu(getWindowHandle(), cs->hMenu );
600 }
601 }
602 }
603 else
604 {
605 setWindowId((DWORD)cs->hMenu);
606 }
607 hSysMenu = (dwStyle & WS_SYSMENU) ? MENU_GetSysMenu(Win32Hwnd,0):0;
608
609 // Subclass frame
610 pOldFrameProc = FrameSubclassFrameWindow(this);
611
612 //preset rects
613 rectWindow.left = cs->x;
614 rectWindow.right = cs->x+cs->cx;
615 rectWindow.top = cs->y;
616 rectWindow.bottom = cs->y+cs->cy;
617 rectClient = rectWindow; //dummy client rect
618 OffsetRect(&rectClient, -rectClient.left, -rectClient.top);
619
620 if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow);
621 /* Send the WM_CREATE message
622 * Perhaps we shouldn't allow width/height changes as well.
623 * See p327 in "Internals".
624 */
625 maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
626
627 //Note: Solitaire crashes when receiving WM_SIZE messages before WM_CREATE
628 //fNoSizeMsg = FALSE;
629 fCreated = TRUE;
630
631 if (SendInternalMessageA(WM_NCCREATE,0,(LPARAM)cs))
632 {
633 RECT tmpRect;
634
635 //update rect
636 rectWindow.left = cs->x;
637 rectWindow.right = cs->x+cs->cx;
638 rectWindow.top = cs->y;
639 rectWindow.bottom = cs->y+cs->cy;
640 tmpRect = rectWindow;
641 if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow);
642 OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
643
644 rectClient = rectWindow;
645 OffsetRect(&rectClient, -rectClient.left, -rectClient.top);
646
647 //set the window size and update the client
648 SetWindowPos(hwndLinkAfter, tmpRect.left, tmpRect.top, tmpRect.right-tmpRect.left, tmpRect.bottom-tmpRect.top,SWP_NOACTIVATE | SWP_NOREDRAW | SWP_FRAMECHANGED);
649 fNoSizeMsg = FALSE;
650 if (cs->style & WS_VISIBLE) dwStyle |= WS_VISIBLE; //program could change position in WM_CREATE
651 if( (SendInternalMessageA(WM_CREATE, 0, (LPARAM)cs )) != -1 )
652 {
653 if(!(flags & WIN_NEED_SIZE))
654 {
655 SendInternalMessageA(WM_SIZE, SIZE_RESTORED,
656 MAKELONG(rectClient.right-rectClient.left,
657 rectClient.bottom-rectClient.top));
658
659 SendInternalMessageA(WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top));
660 }
661
662 if( (getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
663 {
664 /* Notify the parent window only */
665 SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle());
666 if(!::IsWindow(getWindowHandle()))
667 {
668 dprintf(("Createwindow: WM_PARENTNOTIFY destroyed window"));
669 goto end;
670 }
671 }
672
673 //CB: timew32.exe, blockcad.exe -> children not shown!!!
674 if (cs->style & WS_VISIBLE) ShowWindow(sw);
675
676 /* Call WH_SHELL hook */
677 if (!(getStyle() & WS_CHILD) && !owner)
678 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWCREATED, getWindowHandle(), 0 );
679
680 SetLastError(0);
681 return TRUE;
682 }
683 }
684 dprintf(("Window creation FAILED (NCCREATE cancelled creation)"));
685 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
686end:
687 return FALSE;
688}
689//******************************************************************************
690//******************************************************************************
691ULONG Win32BaseWindow::MsgQuit()
692{
693 return SendInternalMessageA(WM_QUIT, 0, 0);
694}
695//******************************************************************************
696//******************************************************************************
697ULONG Win32BaseWindow::MsgClose()
698{
699 return SendInternalMessageA(WM_CLOSE,0,0);
700}
701//******************************************************************************
702//******************************************************************************
703ULONG Win32BaseWindow::MsgDestroy()
704{
705 ULONG rc;
706 Win32BaseWindow *child;
707 HWND hwnd = getWindowHandle();
708
709 fIsDestroyed = TRUE;
710
711 if(fDestroyWindowCalled == FALSE)
712 {//this window was destroyed because DestroyWindow was called for it's parent
713 //so: send a WM_PARENTNOTIFY now as that hasn't happened yet
714 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
715 {
716 if(getParent())
717 {
718 /* Notify the parent window only */
719 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
720 }
721 else DebugInt3();
722 }
723 }
724 SendInternalMessageA(WM_DESTROY, 0, 0);
725 if(::IsWindow(hwnd) == FALSE) {
726 //object already destroyed, so return immediately
727 return 1;
728 }
729 SendInternalMessageA(WM_NCDESTROY, 0, 0);
730
731 TIMER_KillTimerFromWindow(OS2Hwnd);
732
733 if(getFirstChild() == NULL) {
734 delete this;
735 }
736 return 1;
737}
738//******************************************************************************
739//******************************************************************************
740ULONG Win32BaseWindow::MsgEnable(BOOL fEnable)
741{
742 if(fEnable) {
743 dwStyle &= ~WS_DISABLED;
744 }
745 else dwStyle |= WS_DISABLED;
746
747 return SendInternalMessageA(WM_ENABLE, fEnable, 0);
748}
749//******************************************************************************
750//TODO: SW_PARENTCLOSING/OPENING flag (lParam)
751//******************************************************************************
752ULONG Win32BaseWindow::MsgShow(BOOL fShow)
753{
754 if(fNoSizeMsg) {
755 return 1;
756 }
757
758 if(fShow) {
759 setStyle(getStyle() | WS_VISIBLE);
760 }
761 else setStyle(getStyle() & ~WS_VISIBLE);
762
763 return SendInternalMessageA(WM_SHOWWINDOW, fShow, 0);
764}
765//******************************************************************************
766//******************************************************************************
767ULONG Win32BaseWindow::MsgPosChanging(LPARAM lp)
768{
769 //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
770 // a WM_WINDOWPOSCHANGED msg -> crash)
771 if(fNoSizeMsg || fDestroyWindowCalled)
772 return 0;
773
774 return SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, lp);
775}
776//******************************************************************************
777//******************************************************************************
778ULONG Win32BaseWindow::MsgPosChanged(LPARAM lp)
779{
780 //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
781 // a WM_WINDOWPOSCHANGED msg -> crash)
782 if(fNoSizeMsg || fDestroyWindowCalled)
783 return 1;
784
785 return SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, lp);
786}
787//******************************************************************************
788//******************************************************************************
789#if 0
790ULONG Win32BaseWindow::MsgMinMax()
791{
792
793}
794#endif
795//******************************************************************************
796//******************************************************************************
797ULONG Win32BaseWindow::MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos)
798{
799 //According to the SDK docs, the scrollbar handle (lParam) is 0 when the standard
800 //window scrollbars send these messages
801 return SendInternalMessageA(msg, MAKELONG(scrollCode, scrollPos), 0);
802}
803//******************************************************************************
804//******************************************************************************
805ULONG Win32BaseWindow::MsgHitTest(ULONG x, ULONG y)
806{
807 lastHitTestVal = SendInternalMessageA(WM_NCHITTEST, 0, MAKELONG((USHORT)x, (USHORT)y));
808 dprintf2(("MsgHitTest (%d,%d) (%d,%d) (%d,%d) returned %x", x, y, rectWindow.left, rectWindow.right, rectWindow.top, rectWindow.bottom, lastHitTestVal));
809 return lastHitTestVal;
810}
811//******************************************************************************
812//******************************************************************************
813ULONG Win32BaseWindow::MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd, HWND hwndOS2Win)
814{
815 ULONG rc, procidhwnd = -1, threadidhwnd = 0;
816
817
818 //According to SDK docs, if app returns FALSE & window is being deactivated,
819 //default processing is cancelled
820 //TODO: According to Wine we should proceed anyway if window is sysmodal
821#if 0
822 if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
823 {
824 return 0;
825 }
826#endif
827 /* child windows get WM_CHILDACTIVATE message */
828 if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
829 {
830 SendInternalMessageA(WM_CHILDACTIVATE, 0, 0L);
831 return 0;
832 }
833
834 rc = SendInternalMessageA(WM_ACTIVATE, MAKELONG((fActivate) ? WA_ACTIVE : WA_INACTIVE, fMinimized), hwnd);
835
836 if(hwndOS2Win) {
837 threadidhwnd = O32_GetWindowThreadProcessId(hwndOS2Win, &procidhwnd);
838 }
839
840 if(fActivate) {
841 SendInternalMessageA(WM_ACTIVATEAPP, 1, dwThreadId); //activate; specify window thread id
842 }
843 else SendInternalMessageA(WM_ACTIVATEAPP, 0, threadidhwnd); //deactivate; specify thread id of other process
844 return rc;
845}
846//******************************************************************************
847//TODO: Is this correct and complete?
848//Add print screen, break & numlock
849//******************************************************************************
850void Win32BaseWindow::setExtendedKey(ULONG virtualkey, ULONG *lParam)
851{
852 switch(virtualkey) {
853 case VK_DOWN:
854 case VK_UP:
855 case VK_PRIOR:
856 case VK_NEXT:
857 case VK_END:
858 case VK_DIVIDE:
859 case VK_DELETE:
860 case VK_EXECUTE: //Numeric enter key?
861 case VK_HOME:
862 case VK_INSERT:
863 case VK_RCONTROL:
864 case VK_RMENU: //is this the right alt???
865 *lParam = *lParam | (1<<24);
866 }
867}
868//******************************************************************************
869//******************************************************************************
870ULONG Win32BaseWindow::DispatchMsgA(MSG *msg)
871{
872 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
873}
874//******************************************************************************
875//******************************************************************************
876ULONG Win32BaseWindow::DispatchMsgW(MSG *msg)
877{
878 return SendInternalMessageW(msg->message, msg->wParam, msg->lParam);
879}
880//******************************************************************************
881//******************************************************************************
882ULONG Win32BaseWindow::MsgSetFocus(HWND hwnd)
883{
884 return SendInternalMessageA(WM_SETFOCUS, hwnd, 0);
885}
886//******************************************************************************
887//******************************************************************************
888ULONG Win32BaseWindow::MsgKillFocus(HWND hwnd)
889{
890 return SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
891}
892//******************************************************************************
893//******************************************************************************
894ULONG Win32BaseWindow::MsgButton(MSG *msg)
895{
896 BOOL fClick = FALSE;
897
898// dprintf(("MsgButton at (%d,%d)", msg->pt.x, msg->pt.y));
899 switch(msg->message) {
900 case WM_LBUTTONDBLCLK:
901 case WM_RBUTTONDBLCLK:
902 case WM_MBUTTONDBLCLK:
903 case WM_NCLBUTTONDBLCLK:
904 case WM_NCRBUTTONDBLCLK:
905 case WM_NCMBUTTONDBLCLK:
906 if (!(windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS) && (msg->message != WM_NCLBUTTONDBLCLK))
907 {
908 msg->message = msg->message - (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); //dblclick -> down
909 MsgButton(msg);
910 msg->message++; //button-up
911 return MsgButton(msg);
912 }
913 break;
914 case WM_LBUTTONDOWN:
915 case WM_RBUTTONDOWN:
916 case WM_MBUTTONDOWN:
917 case WM_NCLBUTTONDOWN:
918 case WM_NCRBUTTONDOWN:
919 case WM_NCMBUTTONDOWN:
920 fClick = TRUE;
921 break;
922 }
923
924 if(ISMOUSE_CAPTURED())
925 {
926 if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_BUTTON, msg->pt.x, msg->pt.y))
927 return 0;
928 }
929
930 if(fClick)
931 {
932 HWND hwndTop;
933
934 /* Activate the window if needed */
935 hwndTop = (GetTopParent()) ? GetTopParent()->getWindowHandle() : 0;
936
937 HWND hwndActive = GetActiveWindow();
938 if (hwndTop && (getWindowHandle() != hwndActive))
939 {
940 LONG ret = SendInternalMessageA(WM_MOUSEACTIVATE, hwndTop,
941 MAKELONG( lastHitTestVal, msg->message) );
942
943#if 0
944 if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
945 eatMsg = TRUE;
946#endif
947 if(((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT))
948 && (hwndTop != GetForegroundWindow()) )
949 {
950 ::SetActiveWindow(hwndTop);
951 }
952 }
953 }
954
955 SendInternalMessageA(WM_SETCURSOR, getWindowHandle(), MAKELONG(lastHitTestVal, msg->message));
956
957 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
958}
959//******************************************************************************
960//******************************************************************************
961ULONG Win32BaseWindow::MsgPaint(ULONG tmp1, BOOL select)
962{
963 if (select && isIcon)
964 return SendInternalMessageA(WM_PAINTICON, 0, 0);
965 else
966 return SendInternalMessageA(WM_PAINT, 0, 0);
967}
968//******************************************************************************
969//TODO: Is the clipper region of the window DC equal to the invalidated rectangle?
970// (or are we simply erasing too much here)
971//******************************************************************************
972ULONG Win32BaseWindow::MsgEraseBackGround(HDC hdc)
973{
974 ULONG rc;
975 HDC hdcErase = hdc;
976
977 if (hdcErase == 0)
978 hdcErase = O32_GetDC(OS2Hwnd);
979
980 if(isIcon)
981 rc = SendInternalMessageA(WM_ICONERASEBKGND, hdcErase, 0);
982 else
983 rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0);
984 if (hdc == 0)
985 O32_ReleaseDC(OS2Hwnd, hdcErase);
986 return (rc);
987}
988//******************************************************************************
989//******************************************************************************
990ULONG Win32BaseWindow::MsgMouseMove(MSG *msg)
991{
992 if(ISMOUSE_CAPTURED()) {
993 if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_MOVE, msg->pt.x, msg->pt.y))
994 return 0;
995 }
996
997 //TODO: hiword should be 0 if window enters menu mode (SDK docs)
998 SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, msg->message));
999
1000 //translated message == WM_(NC)MOUSEMOVE
1001 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
1002}
1003//******************************************************************************
1004//******************************************************************************
1005ULONG Win32BaseWindow::MsgChar(MSG *msg)
1006{
1007 if(ISKDB_CAPTURED())
1008 {
1009 DInputKeyBoardHandler(msg);
1010 }
1011 return DispatchMsgA(msg);
1012}
1013//******************************************************************************
1014//******************************************************************************
1015ULONG Win32BaseWindow::MsgNCPaint()
1016{
1017 RECT rect;
1018
1019 if (GetOS2UpdateRect(OS2HwndFrame,&rect))
1020 {
1021 HRGN hrgn;
1022 ULONG rc;
1023 RECT client = rectClient;
1024
1025//// mapWin32Rect(getParent() ? getParent()->getOS2WindowHandle():OSLIB_HWND_DESKTOP,OS2HwndFrame,&client);
1026 if ((rect.left >= client.left) && (rect.left < client.right) &&
1027 (rect.right >= client.left) && (rect.right < client.right) &&
1028 (rect.top >= client.top) && (rect.top < client.bottom) &&
1029 (rect.bottom >= client.top) && (rect.bottom < client.bottom))
1030 return 0;
1031
1032 dprintf(("MsgNCPaint (%d,%d)(%d,%d)", rect.left, rect.top, rect.right, rect.bottom));
1033 hrgn = CreateRectRgnIndirect(&rect);
1034 if (!hrgn) return 0;
1035 rc = SendInternalMessageA(WM_NCPAINT,hrgn,0);
1036 DeleteObject(hrgn);
1037
1038 return rc;
1039 }
1040 else return 0;
1041}
1042//******************************************************************************
1043//Called when either the frame's size or position has changed (lpWndPos != NULL)
1044//or when the frame layout has changed (i.e. scrollbars added/removed) (lpWndPos == NULL)
1045//******************************************************************************
1046ULONG Win32BaseWindow::MsgFormatFrame(WINDOWPOS *lpWndPos)
1047{
1048 RECT oldWindowRect = rectWindow, client = rectClient, newWindowRect;
1049 WINDOWPOS wndPos;
1050 ULONG rc;
1051
1052 if(lpWndPos)
1053 {
1054 POINT point;
1055
1056 //set new window rectangle
1057 point.x = lpWndPos->x;
1058 point.y = lpWndPos->y;
1059 if (getParent()) ClientToScreen(getParent()->getWindowHandle(),&point);
1060
1061 setWindowRect(point.x,point.y,point.x+lpWndPos->cx,point.y+lpWndPos->cy);
1062 newWindowRect = rectWindow;
1063 }
1064 else {
1065 wndPos.hwnd = getWindowHandle();
1066 wndPos.hwndInsertAfter = 0;
1067 newWindowRect= rectWindow;
1068 if (getParent()) {
1069 mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&newWindowRect);
1070 }
1071 wndPos.x = newWindowRect.left;
1072 wndPos.y = newWindowRect.top;
1073 wndPos.cx = newWindowRect.right - newWindowRect.left;
1074 wndPos.cy = newWindowRect.bottom - newWindowRect.top;
1075 wndPos.flags = SWP_FRAMECHANGED;
1076 lpWndPos = &wndPos;
1077
1078 if (getParent()) {
1079 newWindowRect= rectWindow; //reset; was modified
1080 }
1081 }
1082
1083 rc = SendNCCalcSize(TRUE, &newWindowRect, &oldWindowRect, &client, lpWndPos, &rectClient);
1084
1085 dprintf(("MsgFormatFrame: old client rect (%d,%d)(%d,%d), new client (%d,%d)(%d,%d)", client.left, client.top, client.right, client.bottom, rectClient.left, rectClient.top, rectClient.right, rectClient.bottom));
1086 return rc;
1087}
1088//******************************************************************************
1089//******************************************************************************
1090ULONG Win32BaseWindow::MsgSetText(LPSTR lpsz, LONG cch)
1091{
1092 return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
1093}
1094//******************************************************************************
1095//******************************************************************************
1096ULONG Win32BaseWindow::MsgGetTextLength()
1097{
1098 return SendInternalMessageA(WM_GETTEXTLENGTH, 0, 0);
1099}
1100//******************************************************************************
1101//******************************************************************************
1102void Win32BaseWindow::MsgGetText(char *wndtext, ULONG textlength)
1103{
1104 SendInternalMessageA(WM_GETTEXT, textlength, (LPARAM)wndtext);
1105}
1106//******************************************************************************
1107//******************************************************************************
1108BOOL Win32BaseWindow::isMDIClient()
1109{
1110 return FALSE;
1111}
1112//******************************************************************************
1113//******************************************************************************
1114BOOL Win32BaseWindow::isMDIChild()
1115{
1116 return FALSE;
1117}
1118//******************************************************************************
1119//TODO: Not complete
1120//******************************************************************************
1121BOOL Win32BaseWindow::isFrameWindow()
1122{
1123// if(isMDIChild() || IsDialog() || (getParent() == NULL || getParent() == windowDesktop) && ((dwStyle & WS_CAPTION) == WS_CAPTION))
1124 if((dwStyle & WS_CAPTION) == WS_CAPTION || dwStyle & (WS_VSCROLL|WS_HSCROLL))
1125 return TRUE;
1126
1127 return FALSE;
1128}
1129//******************************************************************************
1130//******************************************************************************
1131SCROLLBAR_INFO *Win32BaseWindow::getScrollInfo(int nBar)
1132{
1133 switch(nBar)
1134 {
1135 case SB_HORZ:
1136 if (!horzScrollInfo)
1137 {
1138 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
1139 if (!horzScrollInfo) break;
1140 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
1141 horzScrollInfo->MaxVal = 100;
1142 horzScrollInfo->flags = ESB_ENABLE_BOTH;
1143 }
1144 return horzScrollInfo;
1145
1146 case SB_VERT:
1147 if (!vertScrollInfo)
1148 {
1149 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
1150 if (!vertScrollInfo) break;
1151 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
1152 vertScrollInfo->MaxVal = 100;
1153 vertScrollInfo->flags = ESB_ENABLE_BOTH;
1154 }
1155 return vertScrollInfo;
1156 }
1157
1158 return NULL;
1159}
1160//******************************************************************************
1161//******************************************************************************
1162LRESULT Win32BaseWindow::DefWndControlColor(UINT ctlType, HDC hdc)
1163{
1164 //SvL: Set background color to default button color (not window (white))
1165 if(ctlType == CTLCOLOR_BTN)
1166 {
1167 SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
1168 SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
1169 return GetSysColorBrush(COLOR_BTNFACE);
1170 }
1171 //SvL: Set background color to default dialog color if window is dialog
1172 if((ctlType == CTLCOLOR_DLG || ctlType == CTLCOLOR_STATIC) && IsDialog()) {
1173 SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
1174 SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
1175 return GetSysColorBrush(COLOR_BTNFACE);
1176 }
1177
1178 if( ctlType == CTLCOLOR_SCROLLBAR)
1179 {
1180 HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
1181 COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
1182 SetTextColor( hdc, GetSysColor(COLOR_3DFACE));
1183 SetBkColor( hdc, bk);
1184
1185//TODO?
1186#if 0
1187 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
1188 * we better use 0x55aa bitmap brush to make scrollbar's background
1189 * look different from the window background.
1190 */
1191 if (bk == GetSysColor(COLOR_WINDOW)) {
1192 return CACHE_GetPattern55AABrush();
1193 }
1194#endif
1195 UnrealizeObject( hb );
1196 return (LRESULT)hb;
1197 }
1198
1199 SetTextColor( hdc, GetSysColor(COLOR_WINDOWTEXT));
1200
1201 if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
1202 {
1203 SetBkColor( hdc, GetSysColor(COLOR_WINDOW) );
1204 }
1205 else
1206 {
1207 SetBkColor( hdc, GetSysColor(COLOR_3DFACE) );
1208 return (LRESULT)GetSysColorBrush(COLOR_3DFACE);
1209 }
1210 return (LRESULT)GetSysColorBrush(COLOR_WINDOW);
1211}
1212//******************************************************************************
1213//******************************************************************************
1214LRESULT Win32BaseWindow::DefWndPrint(HDC hdc,ULONG uFlags)
1215{
1216 /*
1217 * Visibility flag.
1218 */
1219 if ( (uFlags & PRF_CHECKVISIBLE) &&
1220 !IsWindowVisible() )
1221 return 0;
1222
1223 /*
1224 * Unimplemented flags.
1225 */
1226 if ( (uFlags & PRF_CHILDREN) ||
1227 (uFlags & PRF_OWNED) ||
1228 (uFlags & PRF_NONCLIENT) )
1229 {
1230 dprintf(("WM_PRINT message with unsupported flags\n"));
1231 }
1232
1233 /*
1234 * Background
1235 */
1236 if ( uFlags & PRF_ERASEBKGND)
1237 SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
1238
1239 /*
1240 * Client area
1241 */
1242 if ( uFlags & PRF_CLIENT)
1243 SendInternalMessageA(WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
1244
1245
1246 return 0;
1247}
1248//******************************************************************************
1249//******************************************************************************
1250LRESULT Win32BaseWindow::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam)
1251{
1252 switch(Msg)
1253 {
1254 case WM_CLOSE:
1255 dprintf(("DefWindowProcA: WM_CLOSE %x", getWindowHandle()));
1256 DestroyWindow();
1257 return 0;
1258
1259 case WM_GETTEXTLENGTH:
1260 return wndNameLength;
1261
1262 case WM_GETTEXT:
1263 if (!lParam || !wParam) return 0;
1264 if (!windowNameA) ((LPSTR)lParam)[0] = 0;
1265 else lstrcpynA((LPSTR)lParam, windowNameA, wParam);
1266 return min(wndNameLength, wParam);
1267
1268 case WM_SETTEXT:
1269 {
1270 LPCSTR lpsz = (LPCSTR)lParam;
1271
1272 if(windowNameA) free(windowNameA);
1273 if(windowNameW) free(windowNameW);
1274 if (lParam)
1275 {
1276 wndNameLength = strlen(lpsz);
1277 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
1278 strcpy(windowNameA, lpsz);
1279 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
1280 lstrcpyAtoW(windowNameW, windowNameA);
1281 }
1282 else
1283 {
1284 windowNameA = NULL;
1285 windowNameW = NULL;
1286 wndNameLength = 0;
1287 }
1288 dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, lParam));
1289 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
1290 {
1291 HandleNCPaint((HRGN)1);
1292 OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
1293 }
1294
1295 return TRUE;
1296 }
1297
1298 case WM_SETREDRAW:
1299 {
1300 if (wParam)
1301 {
1302 setStyle(getStyle() | WS_VISIBLE);
1303 OSLibWinEnableWindowUpdate(OS2HwndFrame,TRUE);
1304 }
1305 else
1306 {
1307 if (getStyle() & WS_VISIBLE)
1308 {
1309 setStyle(getStyle() & ~WS_VISIBLE);
1310 OSLibWinEnableWindowUpdate(OS2HwndFrame,FALSE);
1311 }
1312 }
1313 return 0;
1314 }
1315
1316 case WM_CTLCOLORMSGBOX:
1317 case WM_CTLCOLOREDIT:
1318 case WM_CTLCOLORLISTBOX:
1319 case WM_CTLCOLORBTN:
1320 case WM_CTLCOLORDLG:
1321 case WM_CTLCOLORSTATIC:
1322 case WM_CTLCOLORSCROLLBAR:
1323 return DefWndControlColor(Msg - WM_CTLCOLORMSGBOX, (HDC)wParam);
1324
1325 case WM_CTLCOLOR:
1326 return DefWndControlColor(HIWORD(lParam), (HDC)wParam);
1327
1328 case WM_VKEYTOITEM:
1329 case WM_CHARTOITEM:
1330 return -1;
1331
1332 case WM_PARENTNOTIFY:
1333 return 0;
1334
1335 case WM_MOUSEACTIVATE:
1336 {
1337 dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
1338 if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
1339 {
1340 if(getParent()) {
1341 LRESULT rc = getParent()->SendInternalMessageA(WM_MOUSEACTIVATE, wParam, lParam );
1342 if(rc) return rc;
1343 }
1344 }
1345 return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
1346 }
1347
1348 case WM_ACTIVATE:
1349 return 0;
1350
1351 case WM_SETCURSOR:
1352 {
1353 dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
1354 if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
1355 {
1356 if(getParent()) {
1357 LRESULT rc = getParent()->SendInternalMessageA(WM_SETCURSOR, wParam, lParam);
1358 if(rc) return rc;
1359 }
1360 }
1361 if (wParam == Win32Hwnd)
1362 {
1363 HCURSOR hCursor;
1364
1365 switch(LOWORD(lParam))
1366 {
1367 case HTCLIENT:
1368 hCursor = windowClass ? windowClass->getCursor():LoadCursorA(0,IDC_ARROWA);
1369 break;
1370
1371 case HTLEFT:
1372 case HTRIGHT:
1373 hCursor = LoadCursorA(0,IDC_SIZEWEA);
1374 break;
1375
1376 case HTTOP:
1377 case HTBOTTOM:
1378 hCursor = LoadCursorA(0,IDC_SIZENSA);
1379 break;
1380
1381 case HTTOPLEFT:
1382 case HTBOTTOMRIGHT:
1383 hCursor = LoadCursorA(0,IDC_SIZENWSEA);
1384 break;
1385
1386 case HTTOPRIGHT:
1387 case HTBOTTOMLEFT:
1388 hCursor = LoadCursorA(0,IDC_SIZENESWA);
1389 break;
1390
1391 default:
1392 hCursor = LoadCursorA(0,IDC_ARROWA);
1393 break;
1394 }
1395
1396 if (hCursor)
1397 {
1398 SetCursor(hCursor);
1399 return 1;
1400 }
1401 else return 0;
1402 }
1403 else return 0;
1404 }
1405
1406 case WM_MOUSEMOVE:
1407 return 0;
1408
1409 case WM_WINDOWPOSCHANGED:
1410 {
1411 PWINDOWPOS wpos = (PWINDOWPOS)lParam;
1412 WPARAM wp = SIZE_RESTORED;
1413
1414 if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE))
1415 {
1416 SendInternalMessageA(WM_MOVE, 0, MAKELONG(rectClient.left,rectClient.top));
1417 }
1418 if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE))
1419 {
1420 if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
1421 else
1422 if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
1423
1424 SendInternalMessageA(WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left,
1425 rectClient.bottom - rectClient.top));
1426 }
1427 return 0;
1428 }
1429 case WM_WINDOWPOSCHANGING:
1430 return HandleWindowPosChanging((WINDOWPOS *)lParam);
1431
1432 case WM_ERASEBKGND:
1433 case WM_ICONERASEBKGND:
1434 {
1435 RECT rect;
1436 int rc;
1437
1438 if (!windowClass || !windowClass->getBackgroundBrush()) return 0;
1439
1440 rc = GetClipBox( (HDC)wParam, &rect );
1441 if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
1442 {
1443 HBRUSH hBrush = windowClass->getBackgroundBrush();
1444
1445 if (hBrush <= (HBRUSH)(SYSCOLOR_GetLastColor()+1))
1446 hBrush = GetSysColorBrush(hBrush-1);
1447
1448 FillRect( (HDC)wParam, &rect, hBrush);
1449 }
1450 return 1;
1451 }
1452
1453 case WM_PRINT:
1454 return DefWndPrint(wParam,lParam);
1455
1456 case WM_PAINTICON:
1457 case WM_PAINT:
1458 {
1459 PAINTSTRUCT ps;
1460 HDC hdc = BeginPaint(getWindowHandle(), &ps );
1461 if( hdc )
1462 {
1463 if( (getStyle() & WS_MINIMIZE) && getWindowClass()->getIcon())
1464 {
1465 int x = (rectWindow.right - rectWindow.left - GetSystemMetrics(SM_CXICON))/2;
1466 int y = (rectWindow.bottom - rectWindow.top - GetSystemMetrics(SM_CYICON))/2;
1467 dprintf(("Painting class icon: vis rect=(%i,%i - %i,%i)\n", ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ));
1468 DrawIcon(hdc, x, y, getWindowClass()->getIcon() );
1469 }
1470 EndPaint(getWindowHandle(), &ps );
1471 }
1472 return 0;
1473 }
1474
1475 case WM_GETDLGCODE:
1476 return 0;
1477
1478 case WM_NCPAINT:
1479 return HandleNCPaint((HRGN)wParam);
1480
1481 case WM_NCACTIVATE:
1482 return HandleNCActivate(wParam);
1483
1484 case WM_NCCREATE:
1485 return(TRUE);
1486
1487 case WM_NCDESTROY:
1488 return 0;
1489
1490 case WM_NCCALCSIZE:
1491 return HandleNCCalcSize((BOOL)wParam,(RECT*)lParam);
1492
1493 case WM_NCLBUTTONDOWN:
1494 return HandleNCLButtonDown(wParam,lParam);
1495
1496 case WM_LBUTTONDBLCLK:
1497 case WM_NCLBUTTONDBLCLK:
1498 return HandleNCLButtonDblClk(wParam,lParam);
1499
1500 case WM_NCRBUTTONDOWN:
1501 case WM_NCRBUTTONDBLCLK:
1502 case WM_NCMBUTTONDOWN:
1503 case WM_NCMBUTTONDBLCLK:
1504 if (lastHitTestVal == HTERROR) MessageBeep(MB_ICONEXCLAMATION);
1505 return 0;
1506
1507 case WM_NCRBUTTONUP:
1508 return HandleNCRButtonUp(wParam,lParam);
1509
1510 case WM_NCMBUTTONUP:
1511 return 0;
1512
1513 case WM_NCHITTEST:
1514 {
1515 POINT point;
1516
1517 point.x = (SHORT)LOWORD(lParam);
1518 point.y = (SHORT)HIWORD(lParam);
1519
1520 return HandleNCHitTest(point);
1521 }
1522
1523 case WM_SYSCOMMAND:
1524 {
1525 POINT point;
1526
1527 point.x = LOWORD(lParam);
1528 point.y = HIWORD(lParam);
1529 return HandleSysCommand(wParam,&point);
1530 }
1531
1532 case WM_SYSKEYDOWN:
1533 if(wParam == VK_F4) /* try to close the window */
1534 {
1535 Win32BaseWindow *window = GetTopParent();
1536 if(window && !(window->getClass()->getStyle() & CS_NOCLOSE))
1537 PostMessageA(getWindowHandle(), WM_SYSCOMMAND, SC_CLOSE, 0);
1538 }
1539
1540 Win32BaseWindow *siblingWindow;
1541 HWND sibling;
1542 char nameBuffer [40], mnemonic;
1543 int nameLength;
1544
1545 GetWindowTextA (nameBuffer, 40);
1546
1547 // search all sibling to see it this key is their mnemonic
1548 sibling = GetWindow (GW_HWNDFIRST);
1549 while (sibling != 0) {
1550 siblingWindow = GetWindowFromHandle (sibling);
1551 nameLength = siblingWindow->GetWindowTextA (nameBuffer, 40);
1552
1553 // find the siblings mnemonic
1554 mnemonic = '\0';
1555 for (int i=0 ; i<nameLength ; i++) {
1556 if (nameBuffer [i] == '&') {
1557 mnemonic = nameBuffer [i+1];
1558 if ((mnemonic >= 'a') && (mnemonic <= 'z'))
1559 mnemonic -= 32; // make it uppercase
1560 break; // stop searching
1561 }
1562 }
1563
1564 // key matches siblings mnemonic, send mouseclick
1565 if (mnemonic == (char) wParam) {
1566 siblingWindow->SendInternalMessageA (BM_CLICK, 0, 0);
1567 }
1568
1569 sibling = siblingWindow->GetNextWindow (GW_HWNDNEXT);
1570 }
1571
1572 return 0;
1573
1574 case WM_SYSCHAR:
1575 {
1576 int iMenuSysKey = 0;
1577 if (wParam == VK_RETURN && (getStyle() & WS_MINIMIZE))
1578 {
1579 PostMessageA(getWindowHandle(), WM_SYSCOMMAND,
1580 (WPARAM)SC_RESTORE, 0L );
1581 break;
1582 }
1583 if ((HIWORD(lParam) & KEYDATA_ALT) && wParam)
1584 {
1585 if (wParam == VK_TAB || wParam == VK_ESCAPE) break;
1586 if (wParam == VK_SPACE && (getStyle() & WS_CHILD))
1587 getParent()->SendMessageA(Msg, wParam, lParam );
1588 else
1589 SendMessageA(WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)wParam );
1590 }
1591 else /* check for Ctrl-Esc */
1592 if (wParam != VK_ESCAPE) MessageBeep(0);
1593 break;
1594 }
1595 case WM_SETHOTKEY:
1596 hotkey = wParam;
1597 return 1; //CB: always successful
1598
1599 case WM_GETHOTKEY:
1600 return hotkey;
1601
1602 case WM_CONTEXTMENU:
1603 if ((dwStyle & WS_CHILD) && getParent())
1604 getParent()->SendInternalMessageA(WM_CONTEXTMENU,wParam,lParam);
1605 return 0;
1606
1607 case WM_SHOWWINDOW:
1608 if (!lParam) return 0; /* sent from ShowWindow */
1609 if (!(dwStyle & WS_POPUP) || !owner) return 0;
1610 if ((dwStyle & WS_VISIBLE) && wParam) return 0;
1611 else if (!(dwStyle & WS_VISIBLE) && !wParam) return 0;
1612 ShowWindow(wParam ? SW_SHOWNOACTIVATE : SW_HIDE);
1613 return 0;
1614
1615 case WM_CANCELMODE:
1616 if (getParent() == windowDesktop) EndMenu();
1617 if (GetCapture() == Win32Hwnd) ReleaseCapture();
1618 return 0;
1619
1620 case WM_DROPOBJECT:
1621 return DRAG_FILE;
1622
1623 case WM_QUERYDROPOBJECT:
1624 return (dwExStyle & WS_EX_ACCEPTFILES) ? 1:0;
1625
1626 case WM_QUERYDRAGICON:
1627 {
1628 HICON hIcon = windowClass->getCursor();
1629 UINT len;
1630
1631 if(hIcon) return (LRESULT)hIcon;
1632 for(len = 1; len < 64; len++)
1633 {
1634 hIcon = LoadIconA(hInstance,MAKEINTRESOURCEA(len));
1635 if(hIcon)
1636 return (LRESULT)hIcon;
1637 }
1638 return (LRESULT)LoadIconA(0,IDI_APPLICATIONA);
1639 }
1640
1641 case WM_QUERYOPEN:
1642 case WM_QUERYENDSESSION:
1643 return 1;
1644
1645 case WM_NOTIFYFORMAT:
1646 return IsWindowUnicode() ? NFR_UNICODE:NFR_ANSI;
1647
1648 case WM_SETICON:
1649 case WM_GETICON:
1650 {
1651 LRESULT result = 0;
1652 if (!windowClass) return result;
1653 int index = GCL_HICON;
1654
1655 if (wParam == ICON_SMALL)
1656 index = GCL_HICONSM;
1657
1658 result = windowClass->getClassLongA(index);
1659
1660 if (Msg == WM_SETICON)
1661 windowClass->setClassLongA(index, lParam);
1662
1663 return result;
1664 }
1665
1666 case WM_NOTIFY:
1667 return 0; //comctl32 controls expect this
1668
1669 default:
1670 return 0;
1671 }
1672 return 0;
1673}
1674//******************************************************************************
1675//******************************************************************************
1676LRESULT Win32BaseWindow::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam)
1677{
1678 switch(Msg)
1679 {
1680 case WM_GETTEXTLENGTH:
1681 return wndNameLength;
1682
1683 case WM_GETTEXT:
1684 if (!lParam || !wParam) return 0;
1685 if (!windowNameW) ((LPWSTR)lParam)[0] = 0;
1686 else lstrcpynW((LPWSTR)lParam,windowNameW,wParam);
1687 return min(wndNameLength,wParam);
1688
1689 case WM_SETTEXT:
1690 {
1691 LPWSTR lpsz = (LPWSTR)lParam;
1692
1693 if(windowNameA) free(windowNameA);
1694 if(windowNameW) free(windowNameW);
1695 if (lParam)
1696 {
1697 wndNameLength = lstrlenW(lpsz);
1698 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
1699 lstrcpyWtoA(windowNameA,lpsz);
1700 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
1701 lstrcpyW(windowNameW,lpsz);
1702 }
1703 else
1704 {
1705 windowNameA = NULL;
1706 windowNameW = NULL;
1707 wndNameLength = 0;
1708 }
1709 dprintf(("WM_SETTEXT of %x\n",Win32Hwnd));
1710 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
1711 {
1712 HandleNCPaint((HRGN)1);
1713 OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
1714 }
1715
1716 return TRUE;
1717 }
1718
1719 default:
1720 return DefWindowProcA(Msg, wParam, lParam);
1721 }
1722}
1723//******************************************************************************
1724//******************************************************************************
1725LRESULT Win32BaseWindow::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
1726{
1727 //if the destination window is created by this process & thread, call window proc directly
1728 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
1729 return SendInternalMessageA(Msg, wParam, lParam);
1730 }
1731 //otherwise use WinSendMsg to send it to the right process/thread
1732 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, FALSE);
1733}
1734//******************************************************************************
1735//******************************************************************************
1736LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
1737{
1738 //if the destination window is created by this process & thread, call window proc directly
1739 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
1740 return SendInternalMessageW(Msg, wParam, lParam);
1741 }
1742 //otherwise use WinSendMsg to send it to the right process/thread
1743 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, TRUE);
1744}
1745//******************************************************************************
1746//Called as a result of an OS/2 message or called from a class method
1747//******************************************************************************
1748LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
1749{
1750 LRESULT rc;
1751 BOOL fInternalMsgBackup = fInternalMsg;
1752
1753 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE);
1754
1755 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, FALSE);
1756
1757 fInternalMsg = TRUE;
1758 switch(Msg)
1759 {
1760 case WM_CREATE:
1761 {
1762 if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1763 dprintf(("WM_CREATE returned -1\n"));
1764 rc = -1; //don't create window
1765 break;
1766 }
1767 rc = 0;
1768 break;
1769 }
1770 case WM_LBUTTONDOWN:
1771 case WM_MBUTTONDOWN:
1772 case WM_RBUTTONDOWN:
1773 {
1774 if (getParent())
1775 {
1776 POINTS pt = MAKEPOINTS(lParam);
1777 POINT point;
1778
1779 point.x = pt.x;
1780 point.y = pt.y;
1781 mapWin32Point(OS2Hwnd,getParent()->getOS2WindowHandle(),(OSLIBPOINT*)&point);
1782 NotifyParent(Msg,wParam,MAKELPARAM(point.x,point.y));
1783 }
1784 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1785 break;
1786 }
1787
1788 case WM_DESTROY:
1789 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1790 break;
1791
1792 default:
1793 rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
1794 break;
1795 }
1796 fInternalMsg = fInternalMsgBackup;
1797 return rc;
1798}
1799//******************************************************************************
1800//Called as a result of an OS/2 message or called from a class method
1801//******************************************************************************
1802LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
1803{
1804 LRESULT rc;
1805 BOOL fInternalMsgBackup = fInternalMsg;
1806
1807 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE);
1808
1809 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, TRUE);
1810
1811 fInternalMsg = TRUE;
1812 switch(Msg)
1813 {
1814 case WM_CREATE:
1815 {
1816 if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1817 dprintf(("WM_CREATE returned -1\n"));
1818 rc = -1; //don't create window
1819 break;
1820 }
1821 rc = 0;
1822 break;
1823 }
1824 case WM_LBUTTONDOWN:
1825 case WM_MBUTTONDOWN:
1826 case WM_RBUTTONDOWN:
1827 NotifyParent(Msg, wParam, lParam);
1828 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1829 break;
1830
1831 case WM_DESTROY:
1832 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1833 break;
1834 default:
1835 rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
1836 break;
1837 }
1838 fInternalMsg = fInternalMsgBackup;
1839 return rc;
1840}
1841//******************************************************************************
1842//******************************************************************************
1843void Win32BaseWindow::CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
1844{
1845 CWPSTRUCT cwp;
1846
1847 cwp.lParam = lParam;
1848 cwp.wParam = wParam;
1849 cwp.message = Msg;
1850 cwp.hwnd = getWindowHandle();
1851
1852 switch(hooktype) {
1853 case WH_CALLWNDPROC:
1854 if(fUnicode) {
1855 HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
1856 }
1857 else HOOK_CallHooksA(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
1858 break;
1859 }
1860}
1861//******************************************************************************
1862//TODO: Do this more efficiently
1863//******************************************************************************
1864LRESULT Win32BaseWindow::BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam)
1865{
1866 Win32BaseWindow *window;
1867 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
1868
1869 dprintf(("BroadCastMessageA %x %x %x", msg, wParam, lParam, GetFS()));
1870
1871 for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
1872 window = GetWindowFromHandle(hwnd++);
1873 if(window) {
1874 if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
1875 {
1876
1877 if(type == BROADCAST_SEND) {
1878 window->SendInternalMessageA(msg, wParam, lParam);
1879 }
1880 else PostMessageA(window->getWindowHandle(), msg, wParam, lParam);
1881 }
1882 }
1883 }
1884 return 0;
1885}
1886//******************************************************************************
1887//TODO: Do this more efficiently
1888//******************************************************************************
1889LRESULT Win32BaseWindow::BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam)
1890{
1891 Win32BaseWindow *window;
1892 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
1893
1894 dprintf(("BroadCastMessageW %x %x %x", msg, wParam, lParam));
1895
1896 for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
1897 window = GetWindowFromHandle(hwnd++);
1898 if(window) {
1899 if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
1900 {
1901
1902 if(type == BROADCAST_SEND) {
1903 window->SendInternalMessageW(msg, wParam, lParam);
1904 }
1905 else PostMessageW(window->getWindowHandle(), msg, wParam, lParam);
1906 }
1907 }
1908 }
1909 return 0;
1910}
1911//******************************************************************************
1912//******************************************************************************
1913void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
1914{
1915 Win32BaseWindow *window = this;
1916 Win32BaseWindow *parentwindow;
1917
1918 while(window)
1919 {
1920 if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
1921 {
1922 /* Notify the parent window only */
1923 parentwindow = window->getParent();
1924 if(parentwindow) {
1925 parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam );
1926 }
1927 }
1928 else break;
1929
1930 window = parentwindow;
1931 }
1932}
1933//******************************************************************************
1934//******************************************************************************
1935BOOL Win32BaseWindow::SetIcon(HICON hIcon)
1936{
1937 dprintf(("Win32BaseWindow::SetIcon %x", hIcon));
1938 if(OSLibWinSetIcon(OS2HwndFrame, hIcon) == TRUE) {
1939//TODO: Wine does't send these. Correct?
1940// SendInternalMessageA(WM_SETICON, ICON_BIG, hIcon);
1941 return TRUE;
1942 }
1943 return FALSE;
1944}
1945//******************************************************************************
1946//******************************************************************************
1947BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow)
1948{
1949 ULONG showstate = 0;
1950 HWND hWinAfter;
1951
1952 dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
1953
1954 if (flags & WIN_NEED_SIZE)
1955 {
1956 /* should happen only in CreateWindowEx() */
1957 int wParam = SIZE_RESTORED;
1958
1959 flags &= ~WIN_NEED_SIZE;
1960 if (dwStyle & WS_MAXIMIZE)
1961 wParam = SIZE_MAXIMIZED;
1962 else
1963 if (dwStyle & WS_MINIMIZE)
1964 wParam = SIZE_MINIMIZED;
1965
1966 SendInternalMessageA(WM_SIZE, wParam,
1967 MAKELONG(rectClient.right-rectClient.left,
1968 rectClient.bottom-rectClient.top));
1969 SendInternalMessageA(WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top));
1970 }
1971 switch(nCmdShow)
1972 {
1973 case SW_SHOW:
1974 case SW_SHOWDEFAULT: //todo
1975 showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
1976 break;
1977 case SW_HIDE:
1978 showstate = SWPOS_HIDE;
1979 break;
1980 case SW_RESTORE:
1981 showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
1982 break;
1983 case SW_MINIMIZE:
1984 showstate = SWPOS_MINIMIZE;
1985 break;
1986 case SW_SHOWMAXIMIZED:
1987 showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
1988 break;
1989 case SW_SHOWMINIMIZED:
1990 showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
1991 break;
1992 case SW_SHOWMINNOACTIVE:
1993 showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
1994 break;
1995 case SW_SHOWNA:
1996 showstate = SWPOS_SHOW;
1997 break;
1998 case SW_SHOWNOACTIVATE:
1999 showstate = SWPOS_SHOW;
2000 break;
2001 case SW_SHOWNORMAL:
2002 showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
2003 break;
2004 }
2005
2006 /* We can't activate a child window (WINE) */
2007 if(getStyle() & WS_CHILD)
2008 showstate &= ~SWPOS_ACTIVATE;
2009
2010 if(showstate & SWPOS_SHOW) {
2011 setStyle(getStyle() | WS_VISIBLE);
2012 }
2013 else setStyle(getStyle() & ~WS_VISIBLE);
2014
2015 BOOL rc = OSLibWinShowWindow(OS2HwndFrame, showstate);
2016
2017 return rc;
2018}
2019//******************************************************************************
2020//******************************************************************************
2021BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
2022{
2023 BOOL rc = FALSE;
2024 Win32BaseWindow *window;
2025 HWND hParent = 0;
2026 BOOL fShow = FALSE, fHide = FALSE;
2027
2028 if (fuFlags &
2029 ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
2030 SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED |
2031 SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS |
2032 SWP_NOOWNERZORDER))
2033 {
2034 return FALSE;
2035 }
2036
2037 if(IsWindowDestroyed()) {
2038 //changing the position of a window that's being destroyed can cause crashes in PMMERGE
2039 dprintf(("SetWindowPos; window already destroyed"));
2040 return TRUE;
2041 }
2042 WINDOWPOS wpos;
2043 SWP swp, swpOld;
2044
2045#if 0 //CB: test: MSIE 2.0 displays the tool-/addressbar this way -> to check
2046 //CB: -> comctl32: toolbar (WM_SIZE), same bug: statusbar height
2047 //CB: cx or cy are 0
2048
2049if (cx == 0)
2050{
2051 dprintf(("CB: cx is 0! %d",fuFlags));
2052 if (fuFlags & SWP_NOSIZE) dprintf(("CB: nosize"));
2053 cx = 50;
2054}
2055if (cy == 0)
2056{
2057 dprintf(("CB: cy is 0! %d",fuFlags));
2058 if (fuFlags & SWP_NOSIZE) dprintf(("CB: nosize"));
2059 cy = 50;
2060}
2061
2062#endif
2063
2064 if(fuFlags & SWP_SHOWWINDOW) {
2065 fShow = TRUE;
2066 fuFlags &= ~SWP_SHOWWINDOW;
2067 }
2068 else
2069 if(fuFlags & SWP_HIDEWINDOW) {
2070 fHide = TRUE;
2071 fuFlags &= ~SWP_HIDEWINDOW;
2072 }
2073 wpos.flags = fuFlags;
2074 wpos.cy = cy;
2075 wpos.cx = cx;
2076 wpos.x = x;
2077 wpos.y = y;
2078 wpos.hwndInsertAfter = hwndInsertAfter;
2079 wpos.hwnd = getWindowHandle();
2080
2081 if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
2082 {
2083 if (isChild())
2084 {
2085 Win32BaseWindow *windowParent = getParent();
2086 if(windowParent) {
2087 hParent = getParent()->getOS2WindowHandle();
2088 }
2089 else dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
2090 }
2091 OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
2092 }
2093
2094 OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame);
2095 if (swp.fl == 0) {
2096 if (fuFlags & SWP_FRAMECHANGED)
2097 {
2098 FrameUpdateClient(this);
2099 }
2100 return TRUE;
2101 }
2102
2103// if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
2104 if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
2105 {
2106 Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
2107 if(wndBehind) {
2108 swp.hwndInsertBehind = wndBehind->getOS2FrameWindowHandle();
2109 }
2110 else {
2111 dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
2112 swp.hwndInsertBehind = 0;
2113 }
2114 }
2115 swp.hwnd = OS2HwndFrame;
2116
2117 dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
2118
2119 //SvL: For some reason WinSetMultWindowPos doesn't work for showing windows when they are hidden..
2120 if(fHide) {
2121 ShowWindow(SW_HIDE);
2122 }
2123 rc = OSLibWinSetMultWindowPos(&swp, 1);
2124 if(fShow) {
2125 ShowWindow(SW_SHOWNA);
2126 }
2127
2128 if (rc == FALSE)
2129 {
2130 dprintf(("OSLibWinSetMultWindowPos failed! Error %x",OSLibWinGetLastError()));
2131 }
2132
2133 if(fuFlags & SWP_FRAMECHANGED && (fuFlags & (SWP_NOMOVE | SWP_NOSIZE) == (SWP_NOMOVE | SWP_NOSIZE)))
2134 {
2135 FrameUpdateClient(this);
2136 }
2137
2138 return (rc);
2139}
2140//******************************************************************************
2141//TODO: WPF_RESTOREMAXIMIZED
2142//******************************************************************************
2143BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *winpos)
2144{
2145 if(isFrameWindow())
2146 {
2147 // Set the minimized position
2148 if (winpos->flags & WPF_SETMINPOSITION)
2149 {
2150 OSLibSetWindowMinPos(OS2HwndFrame, winpos->ptMinPosition.x, winpos->ptMinPosition.y);
2151 }
2152
2153 //TODO: Max position
2154
2155 // Set the new restore position.
2156 OSLibSetWindowRestoreRect(OS2HwndFrame, &winpos->rcNormalPosition);
2157 }
2158
2159 return ShowWindow(winpos->showCmd);
2160}
2161//******************************************************************************
2162//Also destroys all the child windows (destroy children first, parent last)
2163//******************************************************************************
2164BOOL Win32BaseWindow::DestroyWindow()
2165{
2166 /* Call hooks */
2167 if(HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, getWindowHandle(), 0L))
2168 {
2169 return FALSE;
2170 }
2171
2172 if(!(getStyle() & WS_CHILD) && getOwner() == NULL)
2173 {
2174 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWDESTROYED, getWindowHandle(), 0L);
2175 /* FIXME: clean up palette - see "Internals" p.352 */
2176 }
2177
2178 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
2179 {
2180 if(getParent())
2181 {
2182 /* Notify the parent window only */
2183 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
2184 if( !::IsWindow(getWindowHandle()) )
2185 {
2186 return TRUE;
2187 }
2188 }
2189 else DebugInt3();
2190 }
2191 fDestroyWindowCalled = TRUE;
2192 return OSLibWinDestroyWindow(OS2HwndFrame);
2193}
2194//******************************************************************************
2195//******************************************************************************
2196Win32BaseWindow *Win32BaseWindow::getParent()
2197{
2198 Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::GetParent();
2199 return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
2200}
2201//******************************************************************************
2202//******************************************************************************
2203HWND Win32BaseWindow::GetParent()
2204{
2205 Win32BaseWindow *wndparent;
2206
2207 if ((!(getStyle() & (WS_POPUP|WS_CHILD))))
2208 {
2209 return 0;
2210 }
2211 wndparent = ((getStyle() & WS_CHILD) ? getParent() : getOwner());
2212
2213 return (wndparent) ? wndparent->getWindowHandle() : 0;
2214}
2215//******************************************************************************
2216//******************************************************************************
2217HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
2218{
2219 HWND oldhwnd;
2220 Win32BaseWindow *newparent;
2221
2222 if(getParent()) {
2223 oldhwnd = getParent()->getWindowHandle();
2224 getParent()->RemoveChild(this);
2225 }
2226 else oldhwnd = 0;
2227
2228 newparent = GetWindowFromHandle(hwndNewParent);
2229 if(newparent)
2230 {
2231 setParent(newparent);
2232 getParent()->AddChild(this);
2233 OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
2234 return oldhwnd;
2235 }
2236 else {
2237 setParent(windowDesktop);
2238 windowDesktop->AddChild(this);
2239 OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
2240 return oldhwnd;
2241 }
2242}
2243//******************************************************************************
2244//******************************************************************************
2245BOOL Win32BaseWindow::IsChild(HWND hwndParent)
2246{
2247 if(getParent()) {
2248 return getParent()->getWindowHandle() == hwndParent;
2249 }
2250 else return 0;
2251}
2252//******************************************************************************
2253//******************************************************************************
2254HWND Win32BaseWindow::GetTopWindow()
2255{
2256 return GetWindow(GW_CHILD);
2257}
2258//******************************************************************************
2259// Get the top-level parent for a child window.
2260//******************************************************************************
2261Win32BaseWindow *Win32BaseWindow::GetTopParent()
2262{
2263 Win32BaseWindow *window = this;
2264
2265 while(window && (window->getStyle() & WS_CHILD))
2266 {
2267 window = window->getParent();
2268 }
2269 return window;
2270}
2271//******************************************************************************
2272//Don't call WinUpdateWindow as that one also updates the child windows
2273//Also need to send WM_PAINT directly to the window procedure, which doesn't
2274//always happen with WinUpdateWindow (could be posted if thread doesn't own window)
2275//******************************************************************************
2276BOOL Win32BaseWindow::UpdateWindow()
2277{
2278 RECT rect;
2279
2280 if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect))
2281 {//update region not empty
2282 HDC hdc;
2283
2284 hdc = O32_GetDC(OS2Hwnd);
2285 if (isIcon)
2286 {
2287 SendInternalMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
2288 SendInternalMessageA(WM_PAINTICON, 0, 0);
2289 }
2290 else
2291 {
2292 SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
2293 SendInternalMessageA(WM_PAINT, 0, 0);
2294 }
2295 O32_ReleaseDC(OS2Hwnd, hdc);
2296 }
2297 return TRUE;
2298}
2299//******************************************************************************
2300//******************************************************************************
2301BOOL Win32BaseWindow::IsIconic()
2302{
2303 return OSLibWinIsIconic(OS2Hwnd);
2304}
2305//******************************************************************************
2306//TODO: Should not enumerate children that are created during the enumeration!
2307//******************************************************************************
2308BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
2309{
2310 BOOL rc = TRUE;
2311 HWND hwnd;
2312 Win32BaseWindow *prevchild = 0, *child = 0;
2313
2314 dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
2315 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2316 {
2317 dprintf(("EnumChildWindows: enumerating child %x", child->getWindowHandle()));
2318 hwnd = child->getWindowHandle();
2319 if(child->getOwner()) {
2320 continue; //shouldn't have an owner (Wine)
2321 }
2322 if(lpfn(hwnd, lParam) == FALSE)
2323 {
2324 rc = FALSE;
2325 break;
2326 }
2327 //check if the window still exists
2328 if(!::IsWindow(hwnd))
2329 {
2330 child = prevchild;
2331 continue;
2332 }
2333 if(child->getFirstChild() != NULL)
2334 {
2335 dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle()));
2336 if(child->EnumChildWindows(lpfn, lParam) == FALSE)
2337 {
2338 rc = FALSE;
2339 break;
2340 }
2341 }
2342 prevchild = child;
2343 }
2344 return rc;
2345}
2346//******************************************************************************
2347//Enumerate first-level children only and check thread id
2348//******************************************************************************
2349BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
2350{
2351 Win32BaseWindow *child = 0;
2352 ULONG tid, pid;
2353 BOOL rc;
2354 HWND hwnd;
2355
2356 dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam));
2357
2358 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2359 {
2360 OSLibWinQueryWindowProcess(child->getOS2WindowHandle(), &pid, &tid);
2361
2362 if(dwThreadId == tid) {
2363 dprintf2(("EnumThreadWindows: Found Window %x", child->getWindowHandle()));
2364 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
2365 break;
2366 }
2367 }
2368 }
2369 return TRUE;
2370}
2371//******************************************************************************
2372//Enumerate first-level children only
2373//******************************************************************************
2374BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
2375{
2376 Win32BaseWindow *child = 0;
2377 BOOL rc;
2378 HWND hwnd;
2379
2380 dprintf(("EnumWindows %x %x", lpfn, lParam));
2381
2382 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2383 {
2384 hwnd = child->getWindowHandle();
2385
2386 dprintf2(("EnumWindows: Found Window %x", child->getWindowHandle()));
2387 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
2388 break;
2389 }
2390 }
2391 return TRUE;
2392}
2393//******************************************************************************
2394//******************************************************************************
2395Win32BaseWindow *Win32BaseWindow::FindWindowById(int id)
2396{
2397 for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2398 {
2399 if (child->getWindowId() == id)
2400 {
2401 return child;
2402 }
2403 }
2404 return 0;
2405}
2406//******************************************************************************
2407//TODO:
2408//We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
2409//the current process owns them.
2410//******************************************************************************
2411HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
2412 BOOL fUnicode)
2413{
2414 Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
2415 Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
2416
2417 if((hwndParent != OSLIB_HWND_DESKTOP && !parent) ||
2418 (hwndChildAfter != 0 && !child) ||
2419 (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0))
2420 {
2421 dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
2422 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
2423 return 0;
2424 }
2425 if(hwndParent != OSLIB_HWND_DESKTOP)
2426 {//if the current process owns the window, just do a quick search
2427 child = (Win32BaseWindow *)parent->getFirstChild();
2428 if(hwndChildAfter != 0)
2429 {
2430 while(child)
2431 {
2432 if(child->getWindowHandle() == hwndChildAfter)
2433 {
2434 child = (Win32BaseWindow *)child->getNextChild();
2435 break;
2436 }
2437 child = (Win32BaseWindow *)child->getNextChild();
2438 }
2439 }
2440 while(child)
2441 {
2442 if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
2443 (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
2444 {
2445 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
2446 return child->getWindowHandle();
2447 }
2448 child = (Win32BaseWindow *)child->getNextChild();
2449 }
2450 }
2451 else {
2452 Win32BaseWindow *wnd;
2453 HWND henum, hwnd;
2454
2455 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
2456 hwnd = OSLibWinGetNextWindow(henum);
2457
2458 while(hwnd)
2459 {
2460 wnd = GetWindowFromOS2Handle(hwnd);
2461 if(wnd == NULL) {
2462 hwnd = OSLibWinQueryClientWindow(hwnd);
2463 if(hwnd) wnd = GetWindowFromOS2Handle(hwnd);
2464 if(!hwnd) wnd = GetWindowFromOS2FrameHandle(hwnd);
2465 }
2466
2467 if(wnd) {
2468 if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
2469 (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
2470 {
2471 OSLibWinEndEnumWindows(henum);
2472 dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
2473 return wnd->getWindowHandle();
2474 }
2475 }
2476 hwnd = OSLibWinGetNextWindow(henum);
2477 }
2478 OSLibWinEndEnumWindows(henum);
2479 }
2480 SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
2481 return 0;
2482}
2483//******************************************************************************
2484//******************************************************************************
2485HWND Win32BaseWindow::GetWindow(UINT uCmd)
2486{
2487 HWND hwndRelated = 0;
2488 Win32BaseWindow *window;
2489
2490 switch(uCmd)
2491 {
2492 case GW_HWNDFIRST:
2493 if(getParent()) {
2494 window = (Win32BaseWindow *)getParent()->getFirstChild();
2495 hwndRelated = window->getWindowHandle();
2496 }
2497 break;
2498
2499 case GW_HWNDLAST:
2500 if(!getParent())
2501 {
2502 goto end;
2503 }
2504
2505 window = this;
2506 while(window->getNextChild())
2507 {
2508 window = (Win32BaseWindow *)window->getNextChild();
2509 }
2510 hwndRelated = window->getWindowHandle();
2511 break;
2512
2513 case GW_HWNDNEXT:
2514 window = (Win32BaseWindow *)getNextChild();
2515 if(window) {
2516 hwndRelated = window->getWindowHandle();
2517 }
2518 break;
2519
2520 case GW_HWNDPREV:
2521 if(!getParent())
2522 {
2523 goto end;
2524 }
2525 window = (Win32BaseWindow *)(getParent()->getFirstChild()); /* First sibling */
2526 if(window == this)
2527 {
2528 hwndRelated = 0; /* First in list */
2529 goto end;
2530 }
2531 while(window->getNextChild())
2532 {
2533 if (window->getNextChild() == this)
2534 {
2535 hwndRelated = window->getWindowHandle();
2536 goto end;
2537 }
2538 window = (Win32BaseWindow *)window->getNextChild();
2539 }
2540 break;
2541
2542 case GW_OWNER:
2543 if(getOwner()) {
2544 hwndRelated = getOwner()->getWindowHandle();
2545 }
2546 break;
2547
2548 case GW_CHILD:
2549 if(getFirstChild()) {
2550 hwndRelated = ((Win32BaseWindow *)getFirstChild())->getWindowHandle();
2551 }
2552 break;
2553 }
2554end:
2555 dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
2556 return hwndRelated;
2557}
2558//******************************************************************************
2559//******************************************************************************
2560HWND Win32BaseWindow::SetActiveWindow()
2561{
2562 HWND hwndActive;
2563 Win32BaseWindow *win32wnd;
2564 ULONG magic;
2565
2566 dprintf(("SetActiveWindow %x", getWindowHandle()));
2567 hwndActive = OSLibWinSetActiveWindow(OS2HwndFrame);
2568 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32WNDPTR);
2569 magic = OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32PM_MAGIC);
2570 if(CheckMagicDword(magic) && win32wnd)
2571 {
2572 return win32wnd->getWindowHandle();
2573 }
2574 return windowDesktop->getWindowHandle(); //pretend the desktop was active
2575}
2576//******************************************************************************
2577//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
2578//******************************************************************************
2579BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
2580{
2581 return OSLibWinEnableWindow(OS2HwndFrame, fEnable);
2582}
2583//******************************************************************************
2584//******************************************************************************
2585BOOL Win32BaseWindow::CloseWindow()
2586{
2587 return OSLibWinMinimizeWindow(OS2HwndFrame);
2588}
2589//******************************************************************************
2590//******************************************************************************
2591HWND Win32BaseWindow::GetActiveWindow()
2592{
2593 HWND hwndActive;
2594 Win32BaseWindow *win32wnd;
2595 ULONG magic;
2596
2597 hwndActive = OSLibWinQueryActiveWindow();
2598
2599 return OS2ToWin32Handle(hwndActive);
2600}
2601//******************************************************************************
2602//******************************************************************************
2603BOOL Win32BaseWindow::IsWindowEnabled()
2604{
2605 return OSLibWinIsWindowEnabled(OS2HwndFrame);
2606}
2607//******************************************************************************
2608//******************************************************************************
2609BOOL Win32BaseWindow::IsWindowVisible()
2610{
2611#if 1
2612 return (dwStyle & WS_VISIBLE) == WS_VISIBLE;
2613#else
2614 return OSLibWinIsWindowVisible(OS2HwndFrame);
2615#endif
2616}
2617//******************************************************************************
2618//******************************************************************************
2619BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
2620{
2621 INT len = GetWindowTextLength();
2622 BOOL res;
2623
2624 if (wndname == NULL)
2625 return (len == 0);
2626
2627 len++;
2628 if (fUnicode)
2629 {
2630 WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR));
2631
2632 GetWindowTextW(text,len);
2633 res = (lstrcmpW(text,(LPWSTR)wndname) == 0);
2634 free(text);
2635 } else
2636 {
2637 CHAR *text = (CHAR*)malloc(len*sizeof(CHAR));
2638
2639 GetWindowTextA(text,len);
2640 res = (strcmp(text,wndname) == 0);
2641 free(text);
2642 }
2643
2644 return res;
2645}
2646//******************************************************************************
2647//******************************************************************************
2648CHAR *Win32BaseWindow::getWindowNamePtrA()
2649{
2650 INT len = GetWindowTextLength();
2651 CHAR *text;
2652
2653 if (len == 0) return NULL;
2654 len++;
2655 text = (CHAR*)malloc(len*sizeof(CHAR));
2656 GetWindowTextA(text,len);
2657
2658 return text;
2659}
2660//******************************************************************************
2661//******************************************************************************
2662WCHAR *Win32BaseWindow::getWindowNamePtrW()
2663{
2664 INT len = GetWindowTextLength();
2665 WCHAR *text;
2666
2667 if (len == 0) return NULL;
2668 len++;
2669 text = (WCHAR*)malloc(len*sizeof(WCHAR));
2670 GetWindowTextW(text,len);
2671
2672 return text;
2673}
2674//******************************************************************************
2675//******************************************************************************
2676VOID Win32BaseWindow::freeWindowNamePtr(PVOID namePtr)
2677{
2678 if (namePtr) free(namePtr);
2679}
2680//******************************************************************************
2681//******************************************************************************
2682int Win32BaseWindow::GetWindowTextLength()
2683{
2684 return SendInternalMessageA(WM_GETTEXTLENGTH,0,0);
2685}
2686//******************************************************************************
2687//******************************************************************************
2688int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
2689{
2690 return SendInternalMessageA(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
2691}
2692//******************************************************************************
2693//******************************************************************************
2694int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
2695{
2696 return SendInternalMessageW(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
2697}
2698//******************************************************************************
2699//******************************************************************************
2700BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
2701{
2702 return SendInternalMessageA(WM_SETTEXT,0,(LPARAM)lpsz);
2703}
2704//******************************************************************************
2705//******************************************************************************
2706BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
2707{
2708 return SendInternalMessageW(WM_SETTEXT,0,(LPARAM)lpsz);
2709}
2710//******************************************************************************
2711//******************************************************************************
2712LONG Win32BaseWindow::SetWindowLongA(int index, ULONG value, BOOL fUnicode)
2713{
2714 LONG oldval;
2715
2716 dprintf2(("SetWindowLong%c %x %d %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
2717 switch(index) {
2718 case GWL_EXSTYLE:
2719 {
2720 STYLESTRUCT ss;
2721
2722 if(dwExStyle == value)
2723 return value;
2724
2725 ss.styleOld = dwExStyle;
2726 ss.styleNew = value;
2727 dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
2728 SendInternalMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
2729 setExStyle(ss.styleNew);
2730 SendInternalMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
2731 return ss.styleOld;
2732 }
2733 case GWL_STYLE:
2734 {
2735 STYLESTRUCT ss;
2736
2737 if(dwStyle == value)
2738 return value;
2739
2740 value &= ~(WS_VISIBLE | WS_CHILD); /* Some bits can't be changed this way (WINE) */
2741 ss.styleOld = getStyle();
2742 ss.styleNew = value | (ss.styleOld & (WS_VISIBLE | WS_CHILD));
2743 dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), ss.styleOld, ss.styleNew));
2744 SendInternalMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
2745 setStyle(ss.styleNew);
2746 SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
2747//// OSLibSetWindowStyle(getOS2FrameWindowHandle(), getStyle(), getExStyle(),
2748//// windowClass->getStyle() & CS_SAVEBITS);
2749#ifdef DEBUG
2750 PrintWindowStyle(ss.styleNew, 0);
2751#endif
2752 return ss.styleOld;
2753 }
2754 case GWL_WNDPROC:
2755 oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
2756 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, WINPROC_GetProcType(win32wndproc), WIN_PROC_WINDOW);
2757 return oldval;
2758
2759 case GWL_HINSTANCE:
2760 oldval = hInstance;
2761 hInstance = value;
2762 return oldval;
2763
2764 case GWL_HWNDPARENT:
2765 return SetParent((HWND)value);
2766
2767 case GWL_ID:
2768 oldval = getWindowId();
2769 setWindowId(value);
2770 return oldval;
2771
2772 case GWL_USERDATA:
2773 oldval = userData;
2774 userData = value;
2775 return oldval;
2776
2777 default:
2778 if(index >= 0 && index/4 < nrUserWindowLong)
2779 {
2780 oldval = userWindowLong[index/4];
2781 userWindowLong[index/4] = value;
2782 return oldval;
2783 }
2784 SetLastError(ERROR_INVALID_PARAMETER);
2785 return 0;
2786 }
2787}
2788//******************************************************************************
2789//******************************************************************************
2790ULONG Win32BaseWindow::GetWindowLongA(int index, BOOL fUnicode)
2791{
2792 ULONG value;
2793
2794 switch(index) {
2795 case GWL_EXSTYLE:
2796 value = dwExStyle;
2797 break;
2798 case GWL_STYLE:
2799 value = dwStyle;
2800 break;
2801 case GWL_WNDPROC:
2802 value = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
2803 break;
2804 case GWL_HINSTANCE:
2805 value = hInstance;
2806 break;
2807 case GWL_HWNDPARENT:
2808 if(getParent()) {
2809 value = getParent()->getWindowHandle();
2810 }
2811 else value = 0;
2812 break;
2813 case GWL_ID:
2814 value = getWindowId();
2815 break;
2816 case GWL_USERDATA:
2817 value = userData;
2818 break;
2819 default:
2820 if(index >= 0 && index/4 < nrUserWindowLong)
2821 {
2822 value = userWindowLong[index/4];
2823 break;
2824 }
2825 SetLastError(ERROR_INVALID_PARAMETER);
2826 return 0;
2827 }
2828 dprintf2(("GetWindowLongA %x %d %x", getWindowHandle(), index, value));
2829 return value;
2830}
2831//******************************************************************************
2832//******************************************************************************
2833WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
2834{
2835 WORD oldval;
2836
2837 if(index >= 0 && index/4 < nrUserWindowLong)
2838 {
2839 oldval = ((WORD *)userWindowLong)[index/2];
2840 ((WORD *)userWindowLong)[index/2] = value;
2841 return oldval;
2842 }
2843 SetLastError(ERROR_INVALID_PARAMETER);
2844 return 0;
2845}
2846//******************************************************************************
2847//******************************************************************************
2848WORD Win32BaseWindow::GetWindowWord(int index)
2849{
2850 if(index >= 0 && index/4 < nrUserWindowLong)
2851 {
2852 return ((WORD *)userWindowLong)[index/2];
2853 }
2854 SetLastError(ERROR_INVALID_PARAMETER);
2855 return 0;
2856}
2857//******************************************************************************
2858//******************************************************************************
2859void Win32BaseWindow::setWindowId(DWORD id)
2860{
2861 dwIDMenu = id;
2862}
2863//******************************************************************************
2864//******************************************************************************
2865Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
2866{
2867 Win32BaseWindow *window;
2868
2869 if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
2870 return window;
2871 }
2872// dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
2873 return NULL;
2874}
2875//******************************************************************************
2876//******************************************************************************
2877Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd)
2878{
2879 Win32BaseWindow *win32wnd;
2880 DWORD magic;
2881
2882 if(hwnd == OSLIB_HWND_DESKTOP)
2883 {
2884 return windowDesktop;
2885 }
2886
2887 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
2888 magic = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
2889
2890 if(win32wnd && CheckMagicDword(magic)) {
2891 return win32wnd;
2892 }
2893// dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwnd));
2894 return 0;
2895}
2896//******************************************************************************
2897//******************************************************************************
2898Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
2899{
2900 return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
2901}
2902//******************************************************************************
2903//******************************************************************************
2904HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd)
2905{
2906 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
2907
2908 if(window) {
2909 return window->getOS2WindowHandle();
2910 }
2911// dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
2912 return hwnd;
2913}
2914//******************************************************************************
2915//******************************************************************************
2916HWND Win32BaseWindow::Win32ToOS2FrameHandle(HWND hwnd)
2917{
2918 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
2919
2920 if(window) {
2921 return window->getOS2FrameWindowHandle();
2922 }
2923// dprintf2(("Win32BaseWindow::Win32ToOS2FrameHandle: not a win32 window %x", hwnd));
2924 return hwnd;
2925}
2926//******************************************************************************
2927//******************************************************************************
2928HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd)
2929{
2930 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
2931
2932 if(window) {
2933 return window->getWindowHandle();
2934 }
2935 window = GetWindowFromOS2FrameHandle(hwnd);
2936 if(window) {
2937 return window->getWindowHandle();
2938 }
2939// dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
2940 return 0;
2941// else return hwnd; //OS/2 window handle
2942}
2943//******************************************************************************
2944// GetNextDlgTabItem32 (USER32.276)
2945//******************************************************************************
2946HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
2947{
2948 Win32BaseWindow *child, *nextchild, *lastchild;
2949 HWND retvalue;
2950
2951 if (hwndCtrl)
2952 {
2953 child = GetWindowFromHandle(hwndCtrl);
2954 if (!child)
2955 {
2956 retvalue = 0;
2957 goto END;
2958 }
2959 /* Make sure hwndCtrl is a top-level child */
2960 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
2961 {
2962 child = child->getParent();
2963 if(child == NULL) break;
2964 }
2965
2966 if (!child || (child->getParent() != this))
2967 {
2968 retvalue = 0;
2969 goto END;
2970 }
2971 }
2972 else
2973 {
2974 /* No ctrl specified -> start from the beginning */
2975 child = (Win32BaseWindow *)getFirstChild();
2976 if (!child)
2977 {
2978 retvalue = 0;
2979 goto END;
2980 }
2981
2982 if (!fPrevious)
2983 {
2984 while (child->getNextChild())
2985 {
2986 child = (Win32BaseWindow *)child->getNextChild();
2987 }
2988 }
2989 }
2990
2991 lastchild = child;
2992 nextchild = (Win32BaseWindow *)child->getNextChild();
2993 while (TRUE)
2994 {
2995 if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild();
2996
2997 if (child == nextchild) break;
2998
2999 if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) &&
3000 !(nextchild->getStyle() & WS_DISABLED))
3001 {
3002 lastchild = nextchild;
3003 if (!fPrevious) break;
3004 }
3005 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
3006 }
3007 retvalue = lastchild->getWindowHandle();
3008
3009END:
3010 return retvalue;
3011}
3012//******************************************************************************
3013//******************************************************************************
3014HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
3015{
3016 Win32BaseWindow *child, *nextchild, *lastchild;
3017 HWND retvalue;
3018
3019 if (hwndCtrl)
3020 {
3021 child = GetWindowFromHandle(hwndCtrl);
3022 if (!child)
3023 {
3024 retvalue = 0;
3025 goto END;
3026 }
3027 /* Make sure hwndCtrl is a top-level child */
3028 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
3029 {
3030 child = child->getParent();
3031 if(child == NULL) break;
3032 }
3033
3034 if (!child || (child->getParent() != this))
3035 {
3036 retvalue = 0;
3037 goto END;
3038 }
3039 }
3040 else
3041 {
3042 /* No ctrl specified -> start from the beginning */
3043 child = (Win32BaseWindow *)getFirstChild();
3044 if (!child)
3045 {
3046 retvalue = 0;
3047 goto END;
3048 }
3049
3050 if (fPrevious)
3051 {
3052 while (child->getNextChild())
3053 {
3054 child = (Win32BaseWindow *)child->getNextChild();
3055 }
3056 }
3057 }
3058
3059 lastchild = child;
3060 nextchild = (Win32BaseWindow *)child->getNextChild();
3061 while (TRUE)
3062 {
3063 if (!nextchild || (nextchild->getStyle() & WS_GROUP))
3064 {
3065 /* Wrap-around to the beginning of the group */
3066 Win32BaseWindow *pWndTemp;
3067
3068 nextchild = (Win32BaseWindow *)getFirstChild();
3069
3070 for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild())
3071 {
3072 if (pWndTemp->getStyle() & WS_GROUP)
3073 nextchild = pWndTemp;
3074
3075 if (pWndTemp == child)
3076 break;
3077 }
3078
3079 }
3080 if (nextchild == child)
3081 break;
3082
3083 if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED))
3084 {
3085 lastchild = nextchild;
3086
3087 if (!fPrevious)
3088 break;
3089 }
3090
3091 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
3092 }
3093 retvalue = lastchild->getWindowHandle();
3094END:
3095 return retvalue;
3096}
3097//******************************************************************************
3098//******************************************************************************
3099#ifdef DEBUG
3100void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
3101{
3102 char style[256] = "";
3103 char exstyle[256] = "";
3104
3105 /* Window styles */
3106 if(dwStyle & WS_CHILD)
3107 strcat(style, "WS_CHILD ");
3108 if(dwStyle & WS_POPUP)
3109 strcat(style, "WS_POPUP ");
3110 if(dwStyle & WS_VISIBLE)
3111 strcat(style, "WS_VISIBLE ");
3112 if(dwStyle & WS_DISABLED)
3113 strcat(style, "WS_DISABLED ");
3114 if(dwStyle & WS_CLIPSIBLINGS)
3115 strcat(style, "WS_CLIPSIBLINGS ");
3116 if(dwStyle & WS_CLIPCHILDREN)
3117 strcat(style, "WS_CLIPCHILDREN ");
3118 if(dwStyle & WS_MAXIMIZE)
3119 strcat(style, "WS_MAXIMIZE ");
3120 if(dwStyle & WS_MINIMIZE)
3121 strcat(style, "WS_MINIMIZE ");
3122 if(dwStyle & WS_GROUP)
3123 strcat(style, "WS_GROUP ");
3124 if(dwStyle & WS_TABSTOP)
3125 strcat(style, "WS_TABSTOP ");
3126
3127 if((dwStyle & WS_CAPTION) == WS_CAPTION)
3128 strcat(style, "WS_CAPTION ");
3129 if(dwStyle & WS_DLGFRAME)
3130 strcat(style, "WS_DLGFRAME ");
3131 if(dwStyle & WS_BORDER)
3132 strcat(style, "WS_BORDER ");
3133
3134 if(dwStyle & WS_VSCROLL)
3135 strcat(style, "WS_VSCROLL ");
3136 if(dwStyle & WS_HSCROLL)
3137 strcat(style, "WS_HSCROLL ");
3138 if(dwStyle & WS_SYSMENU)
3139 strcat(style, "WS_SYSMENU ");
3140 if(dwStyle & WS_THICKFRAME)
3141 strcat(style, "WS_THICKFRAME ");
3142 if(dwStyle & WS_MINIMIZEBOX)
3143 strcat(style, "WS_MINIMIZEBOX ");
3144 if(dwStyle & WS_MAXIMIZEBOX)
3145 strcat(style, "WS_MAXIMIZEBOX ");
3146
3147 if(dwExStyle & WS_EX_DLGMODALFRAME)
3148 strcat(exstyle, "WS_EX_DLGMODALFRAME ");
3149 if(dwExStyle & WS_EX_ACCEPTFILES)
3150 strcat(exstyle, "WS_EX_ACCEPTFILES ");
3151 if(dwExStyle & WS_EX_NOPARENTNOTIFY)
3152 strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
3153 if(dwExStyle & WS_EX_TOPMOST)
3154 strcat(exstyle, "WS_EX_TOPMOST ");
3155 if(dwExStyle & WS_EX_TRANSPARENT)
3156 strcat(exstyle, "WS_EX_TRANSPARENT ");
3157
3158 if(dwExStyle & WS_EX_MDICHILD)
3159 strcat(exstyle, "WS_EX_MDICHILD ");
3160 if(dwExStyle & WS_EX_TOOLWINDOW)
3161 strcat(exstyle, "WS_EX_TOOLWINDOW ");
3162 if(dwExStyle & WS_EX_WINDOWEDGE)
3163 strcat(exstyle, "WS_EX_WINDOWEDGE ");
3164 if(dwExStyle & WS_EX_CLIENTEDGE)
3165 strcat(exstyle, "WS_EX_CLIENTEDGE ");
3166 if(dwExStyle & WS_EX_CONTEXTHELP)
3167 strcat(exstyle, "WS_EX_CONTEXTHELP ");
3168 if(dwExStyle & WS_EX_RIGHT)
3169 strcat(exstyle, "WS_EX_RIGHT ");
3170 if(dwExStyle & WS_EX_LEFT)
3171 strcat(exstyle, "WS_EX_LEFT ");
3172 if(dwExStyle & WS_EX_RTLREADING)
3173 strcat(exstyle, "WS_EX_RTLREADING ");
3174 if(dwExStyle & WS_EX_LTRREADING)
3175 strcat(exstyle, "WS_EX_LTRREADING ");
3176 if(dwExStyle & WS_EX_LEFTSCROLLBAR)
3177 strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
3178 if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
3179 strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
3180 if(dwExStyle & WS_EX_CONTROLPARENT)
3181 strcat(exstyle, "WS_EX_CONTROLPARENT ");
3182 if(dwExStyle & WS_EX_STATICEDGE)
3183 strcat(exstyle, "WS_EX_STATICEDGE ");
3184 if(dwExStyle & WS_EX_APPWINDOW)
3185 strcat(exstyle, "WS_EX_APPWINDOW ");
3186
3187 dprintf(("Window style: %x %s", dwStyle, style));
3188 dprintf(("Window exStyle: %x %s (FS = %x)", dwExStyle, exstyle, GetFS()));
3189}
3190#endif
3191//******************************************************************************
3192//******************************************************************************
3193
3194GenericObject *Win32BaseWindow::windows = NULL;
Note: See TracBrowser for help on using the repository browser.