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

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

focus fixes + changes for dinput

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