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

Last change on this file since 2805 was 2805, checked in by cbratschi, 26 years ago

* empty log message *

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