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

Last change on this file since 3462 was 3462, checked in by sandervl, 25 years ago

commented out x&y default code (no longer works), owner bugfix, level 2 debug logging

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