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

Last change on this file since 3284 was 3284, checked in by cbratschi, 25 years ago

HTTRANSPARENT

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