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

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

SetWindowPos bugfix

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