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

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

topmost window changes

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