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

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

merged combobox with core 20000212

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