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

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

merged with Corel 20000317, small icon

File size: 103.8 KB
Line 
1/* $Id: win32wbase.cpp,v 1.174 2000-03-18 16:13:38 cbratschi Exp $ */
2/*
3 * Win32 Window Base Class for OS/2
4 *
5 * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
6 * Copyright 1999 Daniela Engert (dani@ngrt.de)
7 * Copyright 1999-2000 Christoph Bratschi (cbratschi@datacomm.ch)
8 *
9 * Parts based on Wine Windows code (windows\win.c)
10 * Corel version: corel20000212
11 *
12 * Copyright 1993, 1994, 1996 Alexandre Julliard
13 * 1995 Alex Korobka
14 *
15 * TODO: Not thread/process safe
16 *
17 * NOTE: Client rectangle always relative to frame window; window rectangle in screen coordinates
18 *
19 * Project Odin Software License can be found in LICENSE.TXT
20 *
21 */
22#include <os2win.h>
23#include <win.h>
24#include <stdlib.h>
25#include <string.h>
26#include <stdarg.h>
27#include <assert.h>
28#include <misc.h>
29#include <heapstring.h>
30#include <win32wbase.h>
31#include <winres.h>
32#include "wndmsg.h"
33#include "oslibwin.h"
34#include "oslibmsg.h"
35#include "oslibutil.h"
36#include "oslibgdi.h"
37#include "oslibres.h"
38#include "oslibdos.h"
39#include "syscolor.h"
40#include "win32wndhandle.h"
41#include "dc.h"
42#include "pmframe.h"
43#include "win32wdesktop.h"
44#include "pmwindow.h"
45#include "controls.h"
46#include <wprocess.h>
47#include <win\hook.h>
48#include <menu.h>
49#define INCL_TIMERWIN32
50#include "timer.h"
51
52#define DBG_LOCALLOG DBG_win32wbase
53#include "dbglocal.h"
54
55/* bits in the dwKeyData */
56#define KEYDATA_ALT 0x2000
57#define KEYDATA_PREVSTATE 0x4000
58
59void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle);
60
61static fDestroyAll = FALSE;
62//For quick lookup of current process id
63static ULONG currentProcessId = -1;
64
65//******************************************************************************
66//******************************************************************************
67Win32BaseWindow::Win32BaseWindow(DWORD objType) : GenericObject(&windows, objType)
68{
69 Init();
70}
71//******************************************************************************
72//******************************************************************************
73Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
74 : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
75{
76 Init();
77 this->isUnicode = isUnicode;
78 CreateWindowExA(lpCreateStructA, classAtom);
79}
80//******************************************************************************
81//******************************************************************************
82void Win32BaseWindow::Init()
83{
84 isUnicode = FALSE;
85 fFirstShow = TRUE;
86 fIsDialog = FALSE;
87 fIsModalDialogOwner = FALSE;
88 OS2HwndModalDialog = 0;
89 fInternalMsg = FALSE;
90 fNoSizeMsg = FALSE;
91 fIsDestroyed = FALSE;
92 fDestroyWindowCalled = FALSE;
93 fCreated = FALSE;
94 fTaskList = FALSE;
95 fParentDC = FALSE;
96
97 windowNameA = NULL;
98 windowNameW = NULL;
99 wndNameLength = 0;
100
101 userWindowLong = NULL;;
102 nrUserWindowLong = 0;
103
104 magic = WIN32PM_MAGIC;
105 OS2Hwnd = 0;
106 OS2HwndFrame = 0;
107 hSysMenu = 0;
108 Win32Hwnd = 0;
109
110 if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE)
111 {
112 dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
113 DebugInt3();
114 }
115
116 posx = posy = 0;
117 width = height = 0;
118
119 dwExStyle = 0;
120 dwStyle = 0;
121 win32wndproc = 0;
122 hInstance = 0;
123 dwIDMenu = 0; //0xFFFFFFFF; //default -1
124 userData = 0;
125 contextHelpId = 0;
126 hotkey = 0;
127
128 pOldFrameProc = NULL;
129
130 hwndLinkAfter = HWND_BOTTOM;
131 flags = 0;
132 lastHitTestVal = HTOS_NORMAL;
133 owner = NULL;
134 windowClass = 0;
135
136 hIcon = 0;
137 hIconSm = 0;
138
139 EraseBkgndFlag = TRUE;
140
141 horzScrollInfo = NULL;
142 vertScrollInfo = NULL;
143
144 ownDC = 0;
145 hWindowRegion = 0;
146 hClipRegion = 0;
147
148 if(currentProcessId == -1)
149 {
150 currentProcessId = GetCurrentProcessId();
151 }
152 dwThreadId = GetCurrentThreadId();
153 dwProcessId = currentProcessId;
154}
155//******************************************************************************
156//todo get rid of resources (menu, icon etc)
157//******************************************************************************
158Win32BaseWindow::~Win32BaseWindow()
159{
160 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
161 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
162
163 if(!fDestroyAll && getParent() && getParent()->getFirstChild() == this && getNextChild() == NULL)
164 {
165 //if we're the last child that's being destroyed and our
166 //parent window was also destroyed, then we delete the parent object
167 if(getParent()->IsWindowDestroyed())
168 {
169 dprintf(("Last Child (%x) destroyed, get rid of our parent window (%x)", getWindowHandle(), getParent()->getWindowHandle()));
170 delete getParent();
171 setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
172 }
173 }
174 else
175 if(fDestroyAll) {
176 dprintf(("Destroying window %x %s", getWindowHandle(), windowNameA));
177 setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
178 }
179
180 if(isOwnDC())
181 releaseOwnDC(ownDC);
182
183 if(Win32Hwnd)
184 HwFreeWindowHandle(Win32Hwnd);
185
186 if(userWindowLong)
187 free(userWindowLong);
188
189 if(windowNameA) {
190 free(windowNameA);
191 windowNameA = NULL;
192 }
193 if(windowNameW) {
194 free(windowNameW);
195 windowNameW = NULL;
196 }
197 if(vertScrollInfo) {
198 free(vertScrollInfo);
199 vertScrollInfo = NULL;
200 }
201 if(horzScrollInfo) {
202 free(horzScrollInfo);
203 horzScrollInfo = NULL;
204 }
205}
206//******************************************************************************
207//******************************************************************************
208void Win32BaseWindow::DestroyAll()
209{
210 fDestroyAll = TRUE;
211 GenericObject::DestroyAll(windows);
212}
213//******************************************************************************
214//******************************************************************************
215BOOL Win32BaseWindow::isChild()
216{
217 return ((dwStyle & WS_CHILD) != 0);
218}
219//******************************************************************************
220//******************************************************************************
221BOOL Win32BaseWindow::IsWindowUnicode()
222{
223 dprintf2(("IsWindowUnicode %x %d", getWindowHandle(), WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W));
224 return (WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W);
225}
226//******************************************************************************
227//******************************************************************************
228BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom)
229{
230 char buffer[256];
231
232#ifdef DEBUG
233 PrintWindowStyle(cs->style, cs->dwExStyle);
234#endif
235
236 sw = SW_SHOW;
237 SetLastError(0);
238
239 /* Find the parent window */
240 if (cs->hwndParent)
241 {
242 Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
243 if(!window) {
244 dprintf(("Bad parent %04x\n", cs->hwndParent ));
245 SetLastError(ERROR_INVALID_PARAMETER);
246 return FALSE;
247 }
248 /* Make sure parent is valid */
249 if (!window->IsWindow() )
250 {
251 dprintf(("Bad parent %04x\n", cs->hwndParent ));
252 SetLastError(ERROR_INVALID_PARAMETER);
253 return FALSE;
254 }
255 /* Windows does this for overlapped windows
256 * (I don't know about other styles.) */
257 if (cs->hwndParent == GetDesktopWindow() && (!(cs->style & WS_CHILD) || (cs->style & WS_POPUP)))
258 {
259 cs->hwndParent = 0;
260 }
261 }
262 else
263 if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
264 dprintf(("No parent for child window\n" ));
265 SetLastError(ERROR_INVALID_PARAMETER);
266 return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
267 }
268
269 /* Find the window class */
270 windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
271 if (!windowClass)
272 {
273 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
274 dprintf(("Bad class '%s'\n", buffer ));
275 SetLastError(ERROR_INVALID_PARAMETER);
276 return 0;
277 }
278#ifdef DEBUG
279 if(HIWORD(cs->lpszClass))
280 {
281 char *astring;
282
283 if(isUnicode) astring = UnicodeToAsciiString((LPWSTR)cs->lpszClass);
284 else astring = (char *)cs->lpszClass;
285
286 dprintf(("Window class %s", astring));
287 if(isUnicode) FreeAsciiString(astring);
288 }
289 else dprintf(("Window class %x", cs->lpszClass));
290#endif
291
292 /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
293 * with an atom as the class name, put some programs expect to have a *REAL* string in
294 * lpszClass when the CREATESTRUCT is sent with WM_CREATE
295 */
296 if (!HIWORD(cs->lpszClass) ) {
297 if (isUnicode) {
298 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
299 }
300 else {
301 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
302 }
303 cs->lpszClass = buffer;
304 }
305
306 /* Fix the coordinates */
307 fXDefault = FALSE;
308 fCXDefault = FALSE;
309 if ((cs->x == CW_USEDEFAULT) || (cs->x == CW_USEDEFAULT16))
310 {
311 /* Never believe Microsoft's documentation... CreateWindowEx doc says
312 * that if an overlapped window is created with WS_VISIBLE style bit
313 * set and the x parameter is set to CW_USEDEFAULT, the system ignores
314 * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
315 * reveals that
316 *
317 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
318 * 2) it does not ignore the y parameter as the docs claim; instead, it
319 * uses it as second parameter to ShowWindow() unless y is either
320 * CW_USEDEFAULT or CW_USEDEFAULT16.
321 *
322 * The fact that we didn't do 2) caused bogus windows pop up when wine
323 * was running apps that were using this obscure feature. Example -
324 * calc.exe that comes with Win98 (only Win98, it's different from
325 * the one that comes with Win95 and NT)
326 */
327 if ((cs->y != CW_USEDEFAULT) && (cs->y != CW_USEDEFAULT16)) sw = cs->y;
328
329 /* We have saved cs->y, now we can trash it */
330 cs->x = 0;
331 cs->y = 0;
332 fXDefault = TRUE;
333 }
334 if ((cs->cx == CW_USEDEFAULT) || (cs->cx == CW_USEDEFAULT16))
335 {
336 cs->cx = 600; /* FIXME */
337 cs->cy = 400;
338 fCXDefault = TRUE;
339 }
340 if (cs->style & (WS_POPUP | WS_CHILD))
341 {
342 fXDefault = FALSE;
343 if (fCXDefault)
344 {
345 fCXDefault = FALSE;
346 cs->cx = cs->cy = 0;
347 }
348 }
349 if (fXDefault && !fCXDefault) fXDefault = FALSE; //CB: only x positioning doesn't work (calc.exe,cdrlabel.exe)
350
351 if (cs->x < 0) cs->x = 0;
352 if (cs->y < 0) cs->y = 0;
353
354 //Allocate window words
355 nrUserWindowLong = windowClass->getExtraWndWords();
356 if(nrUserWindowLong) {
357 userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
358 memset(userWindowLong, 0, nrUserWindowLong);
359 }
360
361 if ((cs->style & WS_CHILD) && cs->hwndParent)
362 {
363 SetParent(cs->hwndParent);
364 owner = GetWindowFromHandle(cs->hwndParent);
365 if(owner == NULL)
366 {
367 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
368 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
369 return FALSE;
370 }
371 //SvL: Shell positioning shouldn't be done for child windows! (breaks Notes)
372 fXDefault = fCXDefault = FALSE;
373 }
374 else
375 {
376 SetParent(0);
377 if (!cs->hwndParent || (cs->hwndParent == windowDesktop->getWindowHandle())) {
378 owner = NULL;
379 }
380 else
381 {
382 owner = GetWindowFromHandle(cs->hwndParent)->GetTopParent();
383 if(owner == NULL)
384 {
385 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
386 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
387 return FALSE;
388 }
389 }
390 }
391
392 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc(), WINPROC_GetProcType(windowClass->getWindowProc()), WIN_PROC_WINDOW);
393 hInstance = cs->hInstance;
394 dwStyle = cs->style & ~WS_VISIBLE;
395 dwExStyle = cs->dwExStyle;
396
397 hwndLinkAfter = HWND_TOP;
398 if(CONTROLS_IsControl(this, BUTTON_CONTROL) && ((dwStyle & 0x0f) == BS_GROUPBOX))
399 {
400 hwndLinkAfter = HWND_BOTTOM;
401 dwStyle |= WS_CLIPSIBLINGS;
402 }
403 else
404 if(CONTROLS_IsControl(this, STATIC_CONTROL) && !(dwStyle & WS_GROUP)) {
405 dwStyle |= WS_CLIPSIBLINGS;
406 }
407
408 /* Increment class window counter */
409 windowClass->IncreaseWindowCount();
410
411 if (HOOK_IsHooked( WH_CBT ))
412 {
413 CBT_CREATEWNDA cbtc;
414 LRESULT ret;
415
416 cbtc.lpcs = cs;
417 cbtc.hwndInsertAfter = hwndLinkAfter;
418 ret = HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc);
419 if(ret)
420 {
421 dprintf(("CBT-hook returned 0!!"));
422 SetLastError(ERROR_CAN_NOT_COMPLETE); //todo: wrong error
423 return FALSE;
424 }
425 }
426
427 /* Correct the window style */
428 if (!(cs->style & WS_CHILD))
429 {
430 dwStyle |= WS_CLIPSIBLINGS;
431 if (!(cs->style & WS_POPUP))
432 {
433 dwStyle |= WS_CAPTION;
434 flags |= WIN_NEED_SIZE;
435 }
436 }
437 if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
438
439 if (cs->style & WS_HSCROLL)
440 {
441 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
442 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
443 horzScrollInfo->MaxVal = 100;
444 horzScrollInfo->flags = ESB_ENABLE_BOTH;
445 }
446
447 if (cs->style & WS_VSCROLL)
448 {
449 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
450 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
451 vertScrollInfo->MaxVal = 100;
452 vertScrollInfo->flags = ESB_ENABLE_BOTH;
453 }
454
455 if(HIWORD(cs->lpszName))
456 {
457 if (!isUnicode)
458 {
459 wndNameLength = strlen(cs->lpszName);
460 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
461 strcpy(windowNameA,cs->lpszName);
462 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
463 lstrcpyAtoW(windowNameW,windowNameA);
464 windowNameA[wndNameLength] = 0;
465 windowNameW[wndNameLength] = 0;
466 }
467 else
468 {
469 wndNameLength = lstrlenW((LPWSTR)cs->lpszName);
470 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
471 lstrcpyWtoA(windowNameA,(LPWSTR)cs->lpszName);
472 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
473 lstrcpyW(windowNameW,(LPWSTR)cs->lpszName);
474 windowNameA[wndNameLength] = 0;
475 windowNameW[wndNameLength] = 0;
476 }
477 }
478
479 //copy pointer of CREATESTRUCT for usage in MsgCreate method
480 tmpcs = cs;
481
482 //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it
483 THDB *thdb = GetThreadTHDB();
484
485 if(thdb == NULL) {
486 dprintf(("Window creation failed - thdb == NULL")); //this is VERY bad
487 ExitProcess(666);
488 return FALSE;
489 }
490
491 thdb->newWindow = (ULONG)this;
492
493 DWORD dwOSWinStyle;
494
495 OSLibWinConvertStyle(dwStyle,dwExStyle,&dwOSWinStyle);
496 if (((dwStyle & (WS_CAPTION | WS_SYSMENU | 0xC0000000)) == (WS_CAPTION | WS_SYSMENU))) fTaskList = TRUE;
497
498 OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
499 dwOSWinStyle,(char *)windowNameA,
500 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
501 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
502 &OS2HwndFrame, 0, fTaskList,fXDefault | fCXDefault,windowClass->getStyle() & CS_SAVEBITS);
503 if(OS2Hwnd == 0) {
504 dprintf(("Window creation failed!!"));
505 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
506 return FALSE;
507 }
508
509 SetLastError(0);
510 return TRUE;
511}
512//******************************************************************************
513//******************************************************************************
514BOOL Win32BaseWindow::MsgCreate(HWND hwndFrame, HWND hwndClient)
515{
516 CREATESTRUCTA *cs = tmpcs; //pointer to CREATESTRUCT used in CreateWindowExA method
517 POINT maxSize, maxPos, minTrack, maxTrack;
518
519 OS2Hwnd = hwndClient;
520 OS2HwndFrame = hwndFrame;
521
522 fNoSizeMsg = TRUE;
523
524 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
525 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
526 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
527 return FALSE;
528 }
529 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
530 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
531 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
532 return FALSE;
533 }
534
535 //adjust CW_USEDEFAULT position
536 if (fXDefault | fCXDefault)
537 {
538 RECT rect;
539
540 OSLibWinQueryWindowRect(OS2HwndFrame,&rect,RELATIVE_TO_SCREEN);
541 if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rect);
542 if (fXDefault)
543 {
544 cs->x = rect.left;
545 cs->y = rect.top;
546 if (!fCXDefault)
547 {
548 //CB: todo: adjust pos to screen rect
549 }
550 }
551 if (fCXDefault)
552 {
553 cs->cx = rect.right-rect.left;
554 cs->cy = rect.bottom-rect.top;
555 }
556 }
557
558 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
559 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
560 {
561 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
562 if (maxSize.x < cs->cx) cs->cx = maxSize.x;
563 if (maxSize.y < cs->cy) cs->cy = maxSize.y;
564 if (cs->cx < minTrack.x) cs->cx = minTrack.x;
565 if (cs->cy < minTrack.y) cs->cy = minTrack.y;
566 }
567
568 if(cs->style & WS_CHILD)
569 {
570 if(cs->cx < 0) cs->cx = 0;
571 if(cs->cy < 0) cs->cy = 0;
572 }
573 else
574 {
575 if (cs->cx <= 0) cs->cx = 1;
576 if (cs->cy <= 0) cs->cy = 1;
577 }
578
579 OSLibWinSetOwner(OS2Hwnd, OS2HwndFrame);
580
581 fakeWinBase.hwndThis = OS2Hwnd;
582 fakeWinBase.pWindowClass = windowClass;
583
584 //Set icon from window or class
585 if (hIcon)
586 OSLibWinSetIcon(OS2HwndFrame,hIcon);
587 else if (windowClass->getIcon())
588 OSLibWinSetIcon(OS2HwndFrame,windowClass->getIcon());
589
590 /* Get class or window DC if needed */
591 if(windowClass->getStyle() & CS_OWNDC) {
592 dprintf(("Class with CS_OWNDC style"));
593 ownDC = GetDC(getWindowHandle()); //TODO: or GetWindowDC???
594 }
595 else
596 if (windowClass->getStyle() & CS_PARENTDC) {
597 dprintf(("WARNING: Class with CS_PARENTDC style!"));
598 fParentDC = TRUE;
599 ownDC = 0;
600 }
601 else
602 if (windowClass->getStyle() & CS_CLASSDC) {
603 dprintf(("WARNING: Class with CS_CLASSDC style!"));
604 ownDC = 0;
605 }
606 /* Set the window menu */
607 if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
608 {
609 if (cs->hMenu) {
610 ::SetMenu(getWindowHandle(), cs->hMenu);
611 }
612 else {
613 if (windowClass->getMenuNameA()) {
614 cs->hMenu = LoadMenuA(windowClass->getInstance(),windowClass->getMenuNameA());
615#if 0 //CB: hack for treeview test cases bug
616if (!cs->hMenu) cs->hMenu = LoadMenuA(windowClass->getInstance(),"MYAPP");
617#endif
618 if (cs->hMenu) ::SetMenu(getWindowHandle(), cs->hMenu );
619 }
620 }
621 }
622 else
623 {
624 setWindowId((DWORD)cs->hMenu);
625 }
626 hSysMenu = (dwStyle & WS_SYSMENU) ? MENU_GetSysMenu(Win32Hwnd,0):0;
627
628 // Subclass frame
629 pOldFrameProc = FrameSubclassFrameWindow(this);
630
631 //preset rects
632 rectWindow.left = cs->x;
633 rectWindow.right = cs->x+cs->cx;
634 rectWindow.top = cs->y;
635 rectWindow.bottom = cs->y+cs->cy;
636 rectClient = rectWindow; //dummy client rect
637 OffsetRect(&rectClient, -rectClient.left, -rectClient.top);
638
639 if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow);
640 /* Send the WM_CREATE message
641 * Perhaps we shouldn't allow width/height changes as well.
642 * See p327 in "Internals".
643 */
644 maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
645
646 //Note: Solitaire crashes when receiving WM_SIZE messages before WM_CREATE
647 fCreated = TRUE;
648
649 if (SendInternalMessageA(WM_NCCREATE,0,(LPARAM)cs))
650 {
651 RECT tmpRect;
652
653 //CB: recheck flags
654 if (cs->style & (WS_POPUP | WS_CHILD))
655 {
656 fXDefault = FALSE;
657 if (fCXDefault)
658 {
659 fCXDefault = FALSE;
660 cs->cx = cs->cy = 0;
661 }
662 }
663 //update rect
664 rectWindow.left = cs->x;
665 rectWindow.right = cs->x+cs->cx;
666 rectWindow.top = cs->y;
667 rectWindow.bottom = cs->y+cs->cy;
668 tmpRect = rectWindow;
669 if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow);
670 OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
671
672 rectClient = rectWindow;
673 OffsetRect(&rectClient, -rectClient.left, -rectClient.top);
674
675 //set the window size and update the client
676 SetWindowPos(hwndLinkAfter, tmpRect.left, tmpRect.top, tmpRect.right-tmpRect.left, tmpRect.bottom-tmpRect.top,SWP_NOACTIVATE | SWP_NOREDRAW | SWP_FRAMECHANGED);
677 fNoSizeMsg = FALSE;
678 if (cs->style & WS_VISIBLE) dwStyle |= WS_VISIBLE; //program could change position in WM_CREATE
679 if( (SendInternalMessageA(WM_CREATE, 0, (LPARAM)cs )) != -1 )
680 {
681 if(!(flags & WIN_NEED_SIZE))
682 {
683 SendInternalMessageA(WM_SIZE, SIZE_RESTORED,
684 MAKELONG(rectClient.right-rectClient.left,
685 rectClient.bottom-rectClient.top));
686
687 SendInternalMessageA(WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top));
688 }
689
690 if( (getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
691 {
692 /* Notify the parent window only */
693 SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle());
694 if(!::IsWindow(getWindowHandle()))
695 {
696 dprintf(("Createwindow: WM_PARENTNOTIFY destroyed window"));
697 goto end;
698 }
699 }
700
701 if (cs->style & WS_VISIBLE) ShowWindow(sw);
702
703 /* Call WH_SHELL hook */
704 if (!(getStyle() & WS_CHILD) && !owner)
705 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWCREATED, getWindowHandle(), 0 );
706
707 SetLastError(0);
708 return TRUE;
709 }
710 }
711 dprintf(("Window creation FAILED (NCCREATE cancelled creation)"));
712 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
713end:
714 return FALSE;
715}
716//******************************************************************************
717//******************************************************************************
718ULONG Win32BaseWindow::MsgQuit()
719{
720 return SendInternalMessageA(WM_QUIT, 0, 0);
721}
722//******************************************************************************
723//******************************************************************************
724ULONG Win32BaseWindow::MsgClose()
725{
726 return SendInternalMessageA(WM_CLOSE,0,0);
727}
728//******************************************************************************
729//******************************************************************************
730ULONG Win32BaseWindow::MsgDestroy()
731{
732 ULONG rc;
733 Win32BaseWindow *child;
734 HWND hwnd = getWindowHandle();
735
736 fIsDestroyed = TRUE;
737
738 if(fDestroyWindowCalled == FALSE)
739 {//this window was destroyed because DestroyWindow was called for it's parent
740 //so: send a WM_PARENTNOTIFY now as that hasn't happened yet
741 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
742 {
743 if(getParent())
744 {
745 /* Notify the parent window only */
746 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
747 }
748 else DebugInt3();
749 }
750 }
751 SendInternalMessageA(WM_DESTROY, 0, 0);
752 if(::IsWindow(hwnd) == FALSE) {
753 //object already destroyed, so return immediately
754 return 1;
755 }
756 SendInternalMessageA(WM_NCDESTROY, 0, 0);
757
758 TIMER_KillTimerFromWindow(OS2Hwnd);
759
760 if(getFirstChild() == NULL) {
761 delete this;
762 }
763 return 1;
764}
765//******************************************************************************
766//******************************************************************************
767ULONG Win32BaseWindow::MsgEnable(BOOL fEnable)
768{
769 if(fEnable) {
770 dwStyle &= ~WS_DISABLED;
771 }
772 else dwStyle |= WS_DISABLED;
773
774 return SendInternalMessageA(WM_ENABLE, fEnable, 0);
775}
776//******************************************************************************
777//TODO: SW_PARENTCLOSING/OPENING flag (lParam)
778//******************************************************************************
779ULONG Win32BaseWindow::MsgShow(BOOL fShow)
780{
781 if(fNoSizeMsg) {
782 return 1;
783 }
784
785 if(fShow) {
786 setStyle(getStyle() | WS_VISIBLE);
787 }
788 else setStyle(getStyle() & ~WS_VISIBLE);
789
790 return SendInternalMessageA(WM_SHOWWINDOW, fShow, 0);
791}
792//******************************************************************************
793//******************************************************************************
794ULONG Win32BaseWindow::MsgPosChanging(LPARAM lp)
795{
796 //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
797 // a WM_WINDOWPOSCHANGED msg -> crash)
798 if(fNoSizeMsg || fDestroyWindowCalled)
799 return 0;
800
801 return SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, lp);
802}
803//******************************************************************************
804//******************************************************************************
805ULONG Win32BaseWindow::MsgPosChanged(LPARAM lp)
806{
807 //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
808 // a WM_WINDOWPOSCHANGED msg -> crash)
809 if(fNoSizeMsg || fDestroyWindowCalled)
810 return 1;
811
812 return SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, lp);
813}
814//******************************************************************************
815//******************************************************************************
816#if 0
817ULONG Win32BaseWindow::MsgMinMax()
818{
819
820}
821#endif
822//******************************************************************************
823//******************************************************************************
824ULONG Win32BaseWindow::MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos)
825{
826 //According to the SDK docs, the scrollbar handle (lParam) is 0 when the standard
827 //window scrollbars send these messages
828 return SendInternalMessageA(msg, MAKELONG(scrollCode, scrollPos), 0);
829}
830//******************************************************************************
831//******************************************************************************
832ULONG Win32BaseWindow::MsgHitTest(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
2258 if(getParent()) {
2259 oldhwnd = getParent()->getWindowHandle();
2260 getParent()->RemoveChild(this);
2261 }
2262 else oldhwnd = 0;
2263
2264 newparent = GetWindowFromHandle(hwndNewParent);
2265 if(newparent)
2266 {
2267 setParent(newparent);
2268 getParent()->AddChild(this);
2269 OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
2270 return oldhwnd;
2271 }
2272 else {
2273 setParent(windowDesktop);
2274 windowDesktop->AddChild(this);
2275 OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
2276 return oldhwnd;
2277 }
2278}
2279//******************************************************************************
2280//******************************************************************************
2281BOOL Win32BaseWindow::IsChild(HWND hwndParent)
2282{
2283 if(getParent()) {
2284 return getParent()->getWindowHandle() == hwndParent;
2285 }
2286 else return 0;
2287}
2288//******************************************************************************
2289//******************************************************************************
2290HWND Win32BaseWindow::GetTopWindow()
2291{
2292 return GetWindow(GW_CHILD);
2293}
2294//******************************************************************************
2295// Get the top-level parent for a child window.
2296//******************************************************************************
2297Win32BaseWindow *Win32BaseWindow::GetTopParent()
2298{
2299 Win32BaseWindow *window = this;
2300
2301 while(window && (window->getStyle() & WS_CHILD))
2302 {
2303 window = window->getParent();
2304 }
2305 return window;
2306}
2307//******************************************************************************
2308//TODO: Should not enumerate children that are created during the enumeration!
2309//******************************************************************************
2310BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
2311{
2312 BOOL rc = TRUE;
2313 HWND hwnd;
2314 Win32BaseWindow *prevchild = 0, *child = 0;
2315
2316 dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
2317 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2318 {
2319 dprintf(("EnumChildWindows: enumerating child %x", child->getWindowHandle()));
2320 hwnd = child->getWindowHandle();
2321 if(child->getOwner()) {
2322 continue; //shouldn't have an owner (Wine)
2323 }
2324 if(lpfn(hwnd, lParam) == FALSE)
2325 {
2326 rc = FALSE;
2327 break;
2328 }
2329 //check if the window still exists
2330 if(!::IsWindow(hwnd))
2331 {
2332 child = prevchild;
2333 continue;
2334 }
2335 if(child->getFirstChild() != NULL)
2336 {
2337 dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle()));
2338 if(child->EnumChildWindows(lpfn, lParam) == FALSE)
2339 {
2340 rc = FALSE;
2341 break;
2342 }
2343 }
2344 prevchild = child;
2345 }
2346 return rc;
2347}
2348//******************************************************************************
2349//Enumerate first-level children only and check thread id
2350//******************************************************************************
2351BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
2352{
2353 Win32BaseWindow *child = 0;
2354 ULONG tid, pid;
2355 BOOL rc;
2356 HWND hwnd;
2357
2358 dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam));
2359
2360 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2361 {
2362 OSLibWinQueryWindowProcess(child->getOS2WindowHandle(), &pid, &tid);
2363
2364 if(dwThreadId == tid) {
2365 dprintf2(("EnumThreadWindows: Found Window %x", child->getWindowHandle()));
2366 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
2367 break;
2368 }
2369 }
2370 }
2371 return TRUE;
2372}
2373//******************************************************************************
2374//Enumerate first-level children only
2375//******************************************************************************
2376BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
2377{
2378 Win32BaseWindow *child = 0;
2379 BOOL rc;
2380 HWND hwnd;
2381
2382 dprintf(("EnumWindows %x %x", lpfn, lParam));
2383
2384 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2385 {
2386 hwnd = child->getWindowHandle();
2387
2388 dprintf2(("EnumWindows: Found Window %x", child->getWindowHandle()));
2389 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
2390 break;
2391 }
2392 }
2393 return TRUE;
2394}
2395//******************************************************************************
2396//******************************************************************************
2397Win32BaseWindow *Win32BaseWindow::FindWindowById(int id)
2398{
2399 for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2400 {
2401 if (child->getWindowId() == id)
2402 {
2403 return child;
2404 }
2405 }
2406 return 0;
2407}
2408//******************************************************************************
2409//TODO:
2410//We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
2411//the current process owns them.
2412//******************************************************************************
2413HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, ATOM atom, LPSTR lpszWindow)
2414{
2415 Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
2416 Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
2417
2418 dprintf(("FindWindowEx %x %x %x %s", hwndParent, hwndChildAfter, atom, lpszWindow));
2419 if((hwndParent != 0 && !parent) ||
2420 (hwndChildAfter != 0 && !child) ||
2421 (hwndParent == 0 && hwndChildAfter != 0))
2422 {
2423 dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
2424 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
2425 return 0;
2426 }
2427 SetLastError(0);
2428 if(hwndParent != 0)
2429 {//if the current process owns the window, just do a quick search
2430 child = (Win32BaseWindow *)parent->getFirstChild();
2431 if(hwndChildAfter != 0)
2432 {
2433 while(child)
2434 {
2435 if(child->getWindowHandle() == hwndChildAfter)
2436 {
2437 child = (Win32BaseWindow *)child->getNextChild();
2438 break;
2439 }
2440 child = (Win32BaseWindow *)child->getNextChild();
2441 }
2442 }
2443 while(child)
2444 {
2445 //According to Wine, the class doesn't need to be specified
2446 if((!atom || child->getWindowClass()->getAtom() == atom) &&
2447 (!lpszWindow || child->hasWindowName(lpszWindow)))
2448 {
2449 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
2450 return child->getWindowHandle();
2451 }
2452 child = (Win32BaseWindow *)child->getNextChild();
2453 }
2454 }
2455 else {
2456 Win32BaseWindow *wnd;
2457 HWND henum, hwnd;
2458
2459 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
2460 hwnd = OSLibWinGetNextWindow(henum);
2461
2462 while(hwnd)
2463 {
2464 wnd = GetWindowFromOS2Handle(hwnd);
2465 if(wnd == NULL) {
2466 hwnd = OSLibWinQueryClientWindow(hwnd);
2467 if(hwnd) wnd = GetWindowFromOS2Handle(hwnd);
2468 if(!hwnd) wnd = GetWindowFromOS2FrameHandle(hwnd);
2469 }
2470
2471 if(wnd) {
2472 //According to Wine, the class doesn't need to be specified
2473 if((!atom || wnd->getWindowClass()->getAtom() == atom) &&
2474 (!lpszWindow || wnd->hasWindowName(lpszWindow)))
2475 {
2476 OSLibWinEndEnumWindows(henum);
2477 dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
2478 return wnd->getWindowHandle();
2479 }
2480 }
2481 hwnd = OSLibWinGetNextWindow(henum);
2482 }
2483 OSLibWinEndEnumWindows(henum);
2484 }
2485 SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
2486 return 0;
2487}
2488//******************************************************************************
2489//******************************************************************************
2490HWND Win32BaseWindow::GetWindow(UINT uCmd)
2491{
2492 HWND hwndRelated = 0;
2493 Win32BaseWindow *window;
2494
2495 switch(uCmd)
2496 {
2497 case GW_HWNDFIRST:
2498 if(getParent()) {
2499 window = (Win32BaseWindow *)getParent()->getFirstChild();
2500 hwndRelated = window->getWindowHandle();
2501 }
2502 break;
2503
2504 case GW_HWNDLAST:
2505 if(!getParent())
2506 {
2507 goto end;
2508 }
2509
2510 window = this;
2511 while(window->getNextChild())
2512 {
2513 window = (Win32BaseWindow *)window->getNextChild();
2514 }
2515 hwndRelated = window->getWindowHandle();
2516 break;
2517
2518 case GW_HWNDNEXT:
2519 window = (Win32BaseWindow *)getNextChild();
2520 if(window) {
2521 hwndRelated = window->getWindowHandle();
2522 }
2523 break;
2524
2525 case GW_HWNDPREV:
2526 if(!getParent())
2527 {
2528 goto end;
2529 }
2530 window = (Win32BaseWindow *)(getParent()->getFirstChild()); /* First sibling */
2531 if(window == this)
2532 {
2533 hwndRelated = 0; /* First in list */
2534 goto end;
2535 }
2536 while(window->getNextChild())
2537 {
2538 if (window->getNextChild() == this)
2539 {
2540 hwndRelated = window->getWindowHandle();
2541 goto end;
2542 }
2543 window = (Win32BaseWindow *)window->getNextChild();
2544 }
2545 break;
2546
2547 case GW_OWNER:
2548 if(getOwner()) {
2549 hwndRelated = getOwner()->getWindowHandle();
2550 }
2551 break;
2552
2553 case GW_CHILD:
2554 if(getFirstChild()) {
2555 hwndRelated = ((Win32BaseWindow *)getFirstChild())->getWindowHandle();
2556 }
2557 break;
2558 }
2559end:
2560 dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
2561 return hwndRelated;
2562}
2563//******************************************************************************
2564//******************************************************************************
2565HWND Win32BaseWindow::SetActiveWindow()
2566{
2567 HWND hwndActive;
2568
2569 dprintf(("SetActiveWindow %x", getWindowHandle()));
2570 if(OSLibWinSetActiveWindow(OS2HwndFrame) == FALSE) {
2571 dprintf(("OSLibWinSetActiveWindow %x returned FALSE!", OS2HwndFrame));
2572 }
2573 hwndActive = GetActiveWindow();
2574 return (hwndActive) ? hwndActive : windowDesktop->getWindowHandle(); //pretend the desktop was active
2575}
2576//******************************************************************************
2577//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
2578//******************************************************************************
2579BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
2580{
2581 return OSLibWinEnableWindow(OS2HwndFrame, fEnable);
2582}
2583//******************************************************************************
2584//******************************************************************************
2585BOOL Win32BaseWindow::CloseWindow()
2586{
2587 return OSLibWinMinimizeWindow(OS2HwndFrame);
2588}
2589//******************************************************************************
2590//******************************************************************************
2591HWND Win32BaseWindow::GetActiveWindow()
2592{
2593 HWND hwndActive;
2594 Win32BaseWindow *win32wnd;
2595 ULONG magic;
2596
2597 hwndActive = OSLibWinQueryActiveWindow();
2598
2599 return OS2ToWin32Handle(hwndActive);
2600}
2601//******************************************************************************
2602//******************************************************************************
2603BOOL Win32BaseWindow::IsWindowEnabled()
2604{
2605 return OSLibWinIsWindowEnabled(OS2HwndFrame);
2606}
2607//******************************************************************************
2608//******************************************************************************
2609BOOL Win32BaseWindow::IsWindowVisible()
2610{
2611#if 1
2612 return (dwStyle & WS_VISIBLE) == WS_VISIBLE;
2613#else
2614 return OSLibWinIsWindowVisible(OS2HwndFrame);
2615#endif
2616}
2617//******************************************************************************
2618//******************************************************************************
2619BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
2620{
2621 INT len = GetWindowTextLength();
2622 BOOL res;
2623
2624 if (wndname == NULL)
2625 return (len == 0);
2626
2627 len++;
2628 if (fUnicode)
2629 {
2630 WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR));
2631
2632 GetWindowTextW(text,len);
2633 res = (lstrcmpW(text,(LPWSTR)wndname) == 0);
2634 free(text);
2635 } else
2636 {
2637 CHAR *text = (CHAR*)malloc(len*sizeof(CHAR));
2638
2639 GetWindowTextA(text,len);
2640 res = (strcmp(text,wndname) == 0);
2641 free(text);
2642 }
2643
2644 return res;
2645}
2646//******************************************************************************
2647//******************************************************************************
2648CHAR *Win32BaseWindow::getWindowNamePtrA()
2649{
2650 INT len = GetWindowTextLength();
2651 CHAR *text;
2652
2653 if (len == 0) return NULL;
2654 len++;
2655 text = (CHAR*)malloc(len*sizeof(CHAR));
2656 GetWindowTextA(text,len);
2657
2658 return text;
2659}
2660//******************************************************************************
2661//******************************************************************************
2662WCHAR *Win32BaseWindow::getWindowNamePtrW()
2663{
2664 INT len = GetWindowTextLength();
2665 WCHAR *text;
2666
2667 if (len == 0) return NULL;
2668 len++;
2669 text = (WCHAR*)malloc(len*sizeof(WCHAR));
2670 GetWindowTextW(text,len);
2671
2672 return text;
2673}
2674//******************************************************************************
2675//******************************************************************************
2676VOID Win32BaseWindow::freeWindowNamePtr(PVOID namePtr)
2677{
2678 if (namePtr) free(namePtr);
2679}
2680//******************************************************************************
2681//******************************************************************************
2682int Win32BaseWindow::GetWindowTextLength()
2683{
2684 return SendInternalMessageA(WM_GETTEXTLENGTH,0,0);
2685}
2686//******************************************************************************
2687//******************************************************************************
2688int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
2689{
2690 return SendInternalMessageA(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
2691}
2692//******************************************************************************
2693//******************************************************************************
2694int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
2695{
2696 return SendInternalMessageW(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
2697}
2698//******************************************************************************
2699//******************************************************************************
2700BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
2701{
2702 return SendInternalMessageA(WM_SETTEXT,0,(LPARAM)lpsz);
2703}
2704//******************************************************************************
2705//******************************************************************************
2706BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
2707{
2708 return SendInternalMessageW(WM_SETTEXT,0,(LPARAM)lpsz);
2709}
2710//******************************************************************************
2711//******************************************************************************
2712LONG Win32BaseWindow::SetWindowLongA(int index, ULONG value, BOOL fUnicode)
2713{
2714 LONG oldval;
2715
2716 dprintf2(("SetWindowLong%c %x %d %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
2717 switch(index) {
2718 case GWL_EXSTYLE:
2719 {
2720 STYLESTRUCT ss;
2721
2722 if(dwExStyle == value)
2723 return value;
2724
2725 ss.styleOld = dwExStyle;
2726 ss.styleNew = value;
2727 dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
2728 SendInternalMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
2729 setExStyle(ss.styleNew);
2730 SendInternalMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
2731 return ss.styleOld;
2732 }
2733 case GWL_STYLE:
2734 {
2735 STYLESTRUCT ss;
2736
2737 //SvL: TODO: Can you change minimize or maximize status here too?
2738
2739 if(dwStyle == value)
2740 return value;
2741
2742 value &= ~WS_CHILD; /* Some bits can't be changed this way (WINE) */
2743 ss.styleOld = getStyle();
2744 ss.styleNew = value | (ss.styleOld & WS_CHILD);
2745 dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), ss.styleOld, ss.styleNew));
2746 SendInternalMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
2747 setStyle(ss.styleNew);
2748 SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
2749//// OSLibSetWindowStyle(getOS2FrameWindowHandle(), getStyle(), getExStyle(),
2750//// windowClass->getStyle() & CS_SAVEBITS);
2751#ifdef DEBUG
2752 PrintWindowStyle(ss.styleNew, 0);
2753#endif
2754 return ss.styleOld;
2755 }
2756 case GWL_WNDPROC:
2757 oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
2758 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, WINPROC_GetProcType(win32wndproc), WIN_PROC_WINDOW);
2759 return oldval;
2760
2761 case GWL_HINSTANCE:
2762 oldval = hInstance;
2763 hInstance = value;
2764 return oldval;
2765
2766 case GWL_HWNDPARENT:
2767 return SetParent((HWND)value);
2768
2769 case GWL_ID:
2770 oldval = getWindowId();
2771 setWindowId(value);
2772 return oldval;
2773
2774 case GWL_USERDATA:
2775 oldval = userData;
2776 userData = value;
2777 return oldval;
2778
2779 default:
2780 if(index >= 0 && index/4 < nrUserWindowLong)
2781 {
2782 oldval = userWindowLong[index/4];
2783 userWindowLong[index/4] = value;
2784 return oldval;
2785 }
2786 SetLastError(ERROR_INVALID_PARAMETER);
2787 return 0;
2788 }
2789}
2790//******************************************************************************
2791//******************************************************************************
2792ULONG Win32BaseWindow::GetWindowLongA(int index, BOOL fUnicode)
2793{
2794 ULONG value;
2795
2796 switch(index) {
2797 case GWL_EXSTYLE:
2798 value = dwExStyle;
2799 break;
2800 case GWL_STYLE:
2801 value = dwStyle;
2802 break;
2803 case GWL_WNDPROC:
2804 value = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
2805 break;
2806 case GWL_HINSTANCE:
2807 value = hInstance;
2808 break;
2809 case GWL_HWNDPARENT:
2810 if(getParent()) {
2811 value = getParent()->getWindowHandle();
2812 }
2813 else value = 0;
2814 break;
2815 case GWL_ID:
2816 value = getWindowId();
2817 break;
2818 case GWL_USERDATA:
2819 value = userData;
2820 break;
2821 default:
2822 if(index >= 0 && index/4 < nrUserWindowLong)
2823 {
2824 value = userWindowLong[index/4];
2825 break;
2826 }
2827 SetLastError(ERROR_INVALID_PARAMETER);
2828 return 0;
2829 }
2830 dprintf2(("GetWindowLongA %x %d %x", getWindowHandle(), index, value));
2831 return value;
2832}
2833//******************************************************************************
2834//******************************************************************************
2835WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
2836{
2837 WORD oldval;
2838
2839 if(index >= 0 && index/4 < nrUserWindowLong)
2840 {
2841 oldval = ((WORD *)userWindowLong)[index/2];
2842 ((WORD *)userWindowLong)[index/2] = value;
2843 return oldval;
2844 }
2845 SetLastError(ERROR_INVALID_PARAMETER);
2846 return 0;
2847}
2848//******************************************************************************
2849//******************************************************************************
2850WORD Win32BaseWindow::GetWindowWord(int index)
2851{
2852 if(index >= 0 && index/4 < nrUserWindowLong)
2853 {
2854 return ((WORD *)userWindowLong)[index/2];
2855 }
2856 SetLastError(ERROR_INVALID_PARAMETER);
2857 return 0;
2858}
2859//******************************************************************************
2860//******************************************************************************
2861void Win32BaseWindow::setWindowId(DWORD id)
2862{
2863 dwIDMenu = id;
2864}
2865//******************************************************************************
2866//******************************************************************************
2867Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
2868{
2869 Win32BaseWindow *window;
2870
2871 if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
2872 return window;
2873 }
2874// dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
2875 return NULL;
2876}
2877//******************************************************************************
2878//******************************************************************************
2879Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd)
2880{
2881 Win32BaseWindow *win32wnd;
2882 DWORD magic;
2883
2884 if(hwnd == OSLIB_HWND_DESKTOP)
2885 {
2886 return windowDesktop;
2887 }
2888
2889 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
2890 magic = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
2891
2892 if(win32wnd && CheckMagicDword(magic)) {
2893 return win32wnd;
2894 }
2895// dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwnd));
2896 return 0;
2897}
2898//******************************************************************************
2899//******************************************************************************
2900Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
2901{
2902 return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
2903}
2904//******************************************************************************
2905//******************************************************************************
2906HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd)
2907{
2908 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
2909
2910 if(window) {
2911 return window->getOS2WindowHandle();
2912 }
2913// dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
2914 return hwnd;
2915}
2916//******************************************************************************
2917//******************************************************************************
2918HWND Win32BaseWindow::Win32ToOS2FrameHandle(HWND hwnd)
2919{
2920 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
2921
2922 if(window) {
2923 return window->getOS2FrameWindowHandle();
2924 }
2925// dprintf2(("Win32BaseWindow::Win32ToOS2FrameHandle: not a win32 window %x", hwnd));
2926 return hwnd;
2927}
2928//******************************************************************************
2929//******************************************************************************
2930HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd)
2931{
2932 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
2933
2934 if(window) {
2935 return window->getWindowHandle();
2936 }
2937 window = GetWindowFromOS2FrameHandle(hwnd);
2938 if(window) {
2939 return window->getWindowHandle();
2940 }
2941// dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
2942 return 0;
2943// else return hwnd; //OS/2 window handle
2944}
2945//******************************************************************************
2946// GetNextDlgTabItem32 (USER32.276)
2947//******************************************************************************
2948HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
2949{
2950 Win32BaseWindow *child, *nextchild, *lastchild;
2951 HWND retvalue;
2952
2953 if (hwndCtrl)
2954 {
2955 child = GetWindowFromHandle(hwndCtrl);
2956 if (!child)
2957 {
2958 retvalue = 0;
2959 goto END;
2960 }
2961 /* Make sure hwndCtrl is a top-level child */
2962 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
2963 {
2964 child = child->getParent();
2965 if(child == NULL) break;
2966 }
2967
2968 if (!child || (child->getParent() != this))
2969 {
2970 retvalue = 0;
2971 goto END;
2972 }
2973 }
2974 else
2975 {
2976 /* No ctrl specified -> start from the beginning */
2977 child = (Win32BaseWindow *)getFirstChild();
2978 if (!child)
2979 {
2980 retvalue = 0;
2981 goto END;
2982 }
2983
2984 if (!fPrevious)
2985 {
2986 while (child->getNextChild())
2987 {
2988 child = (Win32BaseWindow *)child->getNextChild();
2989 }
2990 }
2991 }
2992
2993 lastchild = child;
2994 nextchild = (Win32BaseWindow *)child->getNextChild();
2995 while (TRUE)
2996 {
2997 if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild();
2998
2999 if (child == nextchild) break;
3000
3001 if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) &&
3002 !(nextchild->getStyle() & WS_DISABLED))
3003 {
3004 lastchild = nextchild;
3005 if (!fPrevious) break;
3006 }
3007 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
3008 }
3009 retvalue = lastchild->getWindowHandle();
3010
3011END:
3012 return retvalue;
3013}
3014//******************************************************************************
3015//******************************************************************************
3016HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
3017{
3018 Win32BaseWindow *child, *nextchild, *lastchild;
3019 HWND retvalue;
3020
3021 if (hwndCtrl)
3022 {
3023 child = GetWindowFromHandle(hwndCtrl);
3024 if (!child)
3025 {
3026 retvalue = 0;
3027 goto END;
3028 }
3029 /* Make sure hwndCtrl is a top-level child */
3030 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
3031 {
3032 child = child->getParent();
3033 if(child == NULL) break;
3034 }
3035
3036 if (!child || (child->getParent() != this))
3037 {
3038 retvalue = 0;
3039 goto END;
3040 }
3041 }
3042 else
3043 {
3044 /* No ctrl specified -> start from the beginning */
3045 child = (Win32BaseWindow *)getFirstChild();
3046 if (!child)
3047 {
3048 retvalue = 0;
3049 goto END;
3050 }
3051
3052 if (fPrevious)
3053 {
3054 while (child->getNextChild())
3055 {
3056 child = (Win32BaseWindow *)child->getNextChild();
3057 }
3058 }
3059 }
3060
3061 lastchild = child;
3062 nextchild = (Win32BaseWindow *)child->getNextChild();
3063 while (TRUE)
3064 {
3065 if (!nextchild || (nextchild->getStyle() & WS_GROUP))
3066 {
3067 /* Wrap-around to the beginning of the group */
3068 Win32BaseWindow *pWndTemp;
3069
3070 nextchild = (Win32BaseWindow *)getFirstChild();
3071
3072 for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild())
3073 {
3074 if (pWndTemp->getStyle() & WS_GROUP)
3075 nextchild = pWndTemp;
3076
3077 if (pWndTemp == child)
3078 break;
3079 }
3080
3081 }
3082 if (nextchild == child)
3083 break;
3084
3085 if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED))
3086 {
3087 lastchild = nextchild;
3088
3089 if (!fPrevious)
3090 break;
3091 }
3092
3093 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
3094 }
3095 retvalue = lastchild->getWindowHandle();
3096END:
3097 return retvalue;
3098}
3099//******************************************************************************
3100//******************************************************************************
3101#ifdef DEBUG
3102void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
3103{
3104 char style[256] = "";
3105 char exstyle[256] = "";
3106
3107 /* Window styles */
3108 if(dwStyle & WS_CHILD)
3109 strcat(style, "WS_CHILD ");
3110 if(dwStyle & WS_POPUP)
3111 strcat(style, "WS_POPUP ");
3112 if(dwStyle & WS_VISIBLE)
3113 strcat(style, "WS_VISIBLE ");
3114 if(dwStyle & WS_DISABLED)
3115 strcat(style, "WS_DISABLED ");
3116 if(dwStyle & WS_CLIPSIBLINGS)
3117 strcat(style, "WS_CLIPSIBLINGS ");
3118 if(dwStyle & WS_CLIPCHILDREN)
3119 strcat(style, "WS_CLIPCHILDREN ");
3120 if(dwStyle & WS_MAXIMIZE)
3121 strcat(style, "WS_MAXIMIZE ");
3122 if(dwStyle & WS_MINIMIZE)
3123 strcat(style, "WS_MINIMIZE ");
3124 if(dwStyle & WS_GROUP)
3125 strcat(style, "WS_GROUP ");
3126 if(dwStyle & WS_TABSTOP)
3127 strcat(style, "WS_TABSTOP ");
3128
3129 if((dwStyle & WS_CAPTION) == WS_CAPTION)
3130 strcat(style, "WS_CAPTION ");
3131 if(dwStyle & WS_DLGFRAME)
3132 strcat(style, "WS_DLGFRAME ");
3133 if(dwStyle & WS_BORDER)
3134 strcat(style, "WS_BORDER ");
3135
3136 if(dwStyle & WS_VSCROLL)
3137 strcat(style, "WS_VSCROLL ");
3138 if(dwStyle & WS_HSCROLL)
3139 strcat(style, "WS_HSCROLL ");
3140 if(dwStyle & WS_SYSMENU)
3141 strcat(style, "WS_SYSMENU ");
3142 if(dwStyle & WS_THICKFRAME)
3143 strcat(style, "WS_THICKFRAME ");
3144 if(dwStyle & WS_MINIMIZEBOX)
3145 strcat(style, "WS_MINIMIZEBOX ");
3146 if(dwStyle & WS_MAXIMIZEBOX)
3147 strcat(style, "WS_MAXIMIZEBOX ");
3148
3149 if(dwExStyle & WS_EX_DLGMODALFRAME)
3150 strcat(exstyle, "WS_EX_DLGMODALFRAME ");
3151 if(dwExStyle & WS_EX_ACCEPTFILES)
3152 strcat(exstyle, "WS_EX_ACCEPTFILES ");
3153 if(dwExStyle & WS_EX_NOPARENTNOTIFY)
3154 strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
3155 if(dwExStyle & WS_EX_TOPMOST)
3156 strcat(exstyle, "WS_EX_TOPMOST ");
3157 if(dwExStyle & WS_EX_TRANSPARENT)
3158 strcat(exstyle, "WS_EX_TRANSPARENT ");
3159
3160 if(dwExStyle & WS_EX_MDICHILD)
3161 strcat(exstyle, "WS_EX_MDICHILD ");
3162 if(dwExStyle & WS_EX_TOOLWINDOW)
3163 strcat(exstyle, "WS_EX_TOOLWINDOW ");
3164 if(dwExStyle & WS_EX_WINDOWEDGE)
3165 strcat(exstyle, "WS_EX_WINDOWEDGE ");
3166 if(dwExStyle & WS_EX_CLIENTEDGE)
3167 strcat(exstyle, "WS_EX_CLIENTEDGE ");
3168 if(dwExStyle & WS_EX_CONTEXTHELP)
3169 strcat(exstyle, "WS_EX_CONTEXTHELP ");
3170 if(dwExStyle & WS_EX_RIGHT)
3171 strcat(exstyle, "WS_EX_RIGHT ");
3172 if(dwExStyle & WS_EX_LEFT)
3173 strcat(exstyle, "WS_EX_LEFT ");
3174 if(dwExStyle & WS_EX_RTLREADING)
3175 strcat(exstyle, "WS_EX_RTLREADING ");
3176 if(dwExStyle & WS_EX_LTRREADING)
3177 strcat(exstyle, "WS_EX_LTRREADING ");
3178 if(dwExStyle & WS_EX_LEFTSCROLLBAR)
3179 strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
3180 if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
3181 strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
3182 if(dwExStyle & WS_EX_CONTROLPARENT)
3183 strcat(exstyle, "WS_EX_CONTROLPARENT ");
3184 if(dwExStyle & WS_EX_STATICEDGE)
3185 strcat(exstyle, "WS_EX_STATICEDGE ");
3186 if(dwExStyle & WS_EX_APPWINDOW)
3187 strcat(exstyle, "WS_EX_APPWINDOW ");
3188
3189 dprintf(("Window style: %x %s", dwStyle, style));
3190 dprintf(("Window exStyle: %x %s (FS = %x)", dwExStyle, exstyle, GetFS()));
3191}
3192#endif
3193//******************************************************************************
3194//******************************************************************************
3195
3196GenericObject *Win32BaseWindow::windows = NULL;
Note: See TracBrowser for help on using the repository browser.