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

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

VK_RETURN fix

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