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

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

SetParent bugfix

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