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

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

fixed setwindowpos bug

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