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

Last change on this file since 7780 was 7780, checked in by sandervl, 24 years ago

VP: fix for position of fake window

File size: 142.3 KB
Line 
1/* $Id: win32wbase.cpp,v 1.312 2002-01-20 15:26:21 sandervl Exp $ */
2/*
3 * Win32 Window Base Class for OS/2
4 *
5 * Copyright 1998-2002 Sander van Leeuwen (sandervl@xs4all.nl)
6 * Copyright 1999 Daniela Engert (dani@ngrt.de)
7 * Copyright 1999-2000 Christoph Bratschi (cbratschi@datacomm.ch)
8 *
9 * Parts based on Wine Windows code (windows\win.c)
10 * Corel version: corel20000212
11 *
12 * Copyright 1993, 1994, 1996 Alexandre Julliard
13 * 1995 Alex Korobka
14 *
15 * TODO: Not thread/process safe
16 *
17 * NOTE: To access a window object, you must call GetWindowFromOS2Handle or
18 * GetWindowFromHandle. Both these methods increase the reference count
19 * of the object. When you're done with the object, you MUST call
20 * the release method!
21 * This mechanism prevents premature destruction of objects when there
22 * are still clients using it.
23 *
24 * NOTE: Client rectangle always relative to frame window
25 * Window rectangle in parent coordinates (relative to parent's client window)
26 * (screen coord. if no parent)
27 *
28 * NOTE: Status of window:
29 * Before a window has processed WM_NCCREATE:
30 * - GetTopWindow can't return that window handle
31 * - GetWindow(parent, GW_CHILD) can't return that window handle
32 * - IsChild works
33 * TODO: Does this affect more functions?? (other GetWindow ops)
34 * (verified in NT4, SP6)
35 *
36 * Project Odin Software License can be found in LICENSE.TXT
37 *
38 */
39#include <os2win.h>
40#include <win.h>
41#include <stdlib.h>
42#include <string.h>
43#include <stdarg.h>
44#include <assert.h>
45#include <misc.h>
46#include <heapstring.h>
47#include <winuser32.h>
48#include "win32wbase.h"
49#include "wndmsg.h"
50#include "oslibwin.h"
51#include "oslibmsg.h"
52#include "oslibutil.h"
53#include "oslibgdi.h"
54#include "oslibres.h"
55#include "oslibdos.h"
56#include "syscolor.h"
57#include "win32wndhandle.h"
58#include "dc.h"
59#include "win32wdesktop.h"
60#include "pmwindow.h"
61#include "controls.h"
62#include <wprocess.h>
63#include <win\hook.h>
64#include <menu.h>
65#define INCL_TIMERWIN32
66#include "timer.h"
67
68#define DBG_LOCALLOG DBG_win32wbase
69#include "dbglocal.h"
70
71/* bits in the dwKeyData */
72#define KEYDATA_ALT 0x2000
73#define KEYDATA_PREVSTATE 0x4000
74
75void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle);
76
77static fDestroyAll = FALSE;
78//For quick lookup of current process id
79static ULONG currentProcessId = -1;
80static int iF10Key = 0;
81static int iMenuSysKey = 0;
82
83
84
85/***
86 * Performance Optimization:
87 * we're directly inlining this micro function from win32wndhandle.cpp.
88 * Changes there must be reflected here.
89 ***/
90extern ULONG WindowHandleTable[MAX_WINDOW_HANDLES];
91
92BOOL INLINE i_HwGetWindowHandleData(HWND hwnd, DWORD *pdwUserData)
93{
94 if((hwnd & 0xFFFF0000) != WNDHANDLE_MAGIC_HIGHWORD) {
95 return FALSE; //unknown window (PM?)
96 }
97 hwnd &= WNDHANDLE_MAGIC_MASK;
98 if(hwnd < MAX_WINDOW_HANDLES) {
99 *pdwUserData = WindowHandleTable[hwnd];
100 return TRUE;
101 }
102 *pdwUserData = 0;
103 return FALSE;
104}
105#define HwGetWindowHandleData(a,b) i_HwGetWindowHandleData(a,b)
106
107
108//******************************************************************************
109//******************************************************************************
110Win32BaseWindow::Win32BaseWindow()
111 : GenericObject(&windows, &critsect), ChildWindow(&critsect)
112{
113 Init();
114}
115//******************************************************************************
116//******************************************************************************
117Win32BaseWindow::Win32BaseWindow(HWND hwndOS2, ATOM classAtom)
118 : GenericObject(&windows, &critsect), ChildWindow(&critsect)
119{
120 Init();
121 OS2Hwnd = OS2HwndFrame = hwndOS2;
122
123 /* Find the window class */
124 windowClass = Win32WndClass::FindClass(NULL, (LPSTR)classAtom);
125 if (!windowClass)
126 {
127 char buffer[32];
128 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
129 dprintf(("Bad class '%s'", buffer ));
130 DebugInt3();
131 }
132
133 //Allocate window words
134 nrUserWindowBytes = windowClass->getExtraWndBytes();
135 if(nrUserWindowBytes) {
136 userWindowBytes = (char *)_smalloc(nrUserWindowBytes);
137 memset(userWindowBytes, 0, nrUserWindowBytes);
138 }
139
140 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc(), WINPROC_GetProcType(windowClass->getWindowProc()), WIN_PROC_WINDOW);
141 hInstance = NULL;
142 dwStyle = WS_VISIBLE;
143 dwOldStyle = dwStyle;
144 dwExStyle = 0;
145
146 //We pretend this window has no parent and won't change size
147 //(dangerous assumption!!)
148 OSLibWinQueryWindowClientRect(OS2Hwnd, &rectClient);
149 OSLibQueryWindowRectAbsolute (OS2Hwnd, &rectWindow);
150
151 fFakeWindow = TRUE;
152}
153//******************************************************************************
154//******************************************************************************
155Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
156 : GenericObject(&windows, &critsect), ChildWindow(&critsect)
157{
158 Init();
159 this->isUnicode = isUnicode;
160 CreateWindowExA(lpCreateStructA, classAtom);
161}
162//******************************************************************************
163//******************************************************************************
164void Win32BaseWindow::Init()
165{
166 isUnicode = FALSE;
167 fFirstShow = TRUE;
168 fIsDialog = FALSE;
169 fIsModalDialogOwner = FALSE;
170 OS2HwndModalDialog = 0;
171 fInternalMsg = FALSE;
172 fParentChange = FALSE;
173 fDestroyWindowCalled = FALSE;
174 fTaskList = FALSE;
175 fParentDC = FALSE;
176 fComingToTop = FALSE;
177 fMinMaxChange = FALSE;
178 fVisibleRegionChanged = FALSE;
179 fEraseBkgndFlag = TRUE;
180 fFakeWindow = FALSE;
181
182 state = STATE_INIT;
183 windowNameA = NULL;
184 windowNameW = NULL;
185 windowNameLength = 0;
186
187 userWindowBytes = NULL;;
188 nrUserWindowBytes= 0;
189
190 OS2Hwnd = 0;
191 OS2HwndFrame = 0;
192 hSysMenu = 0;
193 Win32Hwnd = 0;
194
195 if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE)
196 {
197 dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
198 DebugInt3();
199 }
200
201 posx = posy = 0;
202 width = height = 0;
203
204 dwExStyle = 0;
205 dwStyle = 0;
206 dwOldStyle = 0;
207 win32wndproc = 0;
208 hInstance = 0;
209 dwIDMenu = 0; //0xFFFFFFFF; //default -1
210 userData = 0;
211 contextHelpId = 0;
212 hotkey = 0;
213
214
215 hwndLinkAfter = HWND_BOTTOM;
216 flags = 0;
217 lastHitTestVal = HTOS_NORMAL;
218 owner = NULL;
219 windowClass = 0;
220
221 hIcon = 0;
222 hIconSm = 0;
223
224 horzScrollInfo = NULL;
225 vertScrollInfo = NULL;
226
227 propertyList = NULL;
228
229 cbExtra = 0;
230 pExtra = NULL;
231
232 ownDC = 0;
233 hWindowRegion = 0;
234 hClipRegion = 0;
235
236 hTaskList = 0;
237
238 if(currentProcessId == -1)
239 {
240 currentProcessId = GetCurrentProcessId();
241 }
242 dwThreadId = GetCurrentThreadId();
243 dwProcessId = currentProcessId;
244
245 memset(&windowpos, 0, sizeof(windowpos));
246 //min and max position are initially -1 (verified in NT4, SP6)
247 windowpos.ptMinPosition.x = -1;
248 windowpos.ptMinPosition.y = -1;
249 windowpos.ptMaxPosition.x = -1;
250 windowpos.ptMaxPosition.y = -1;
251
252 lpVisRgnNotifyProc = NULL;
253 dwVisRgnNotifyParam = NULL;
254}
255//******************************************************************************
256//todo get rid of resources (menu, icon etc)
257//******************************************************************************
258Win32BaseWindow::~Win32BaseWindow()
259{
260 if(getRefCount() < 0) {
261 DebugInt3();
262 }
263
264 if(hTaskList) {
265 OSLibWinRemoveFromTasklist(hTaskList);
266 }
267
268 OSLibWinSetVisibleRegionNotify(OS2Hwnd, FALSE);
269 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
270 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
271
272 if(fDestroyAll) {
273 dprintf(("Destroying window %x %s", getWindowHandle(), windowNameA));
274 setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
275 }
276 else
277 if(getParent() && getParent()->getFirstChild() == this && getNextChild() == NULL)
278 {
279 //if we're the last child that's being destroyed and our
280 //parent window was also destroyed, then we
281 if(getParent()->IsWindowDestroyed())
282 {
283 setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
284 }
285 }
286 /* Decrement class window counter */
287 if(windowClass) {
288 RELEASE_CLASSOBJ(windowClass);
289 }
290
291 if(isOwnDC())
292 releaseOwnDC(ownDC);
293
294 if(Win32Hwnd)
295 HwFreeWindowHandle(Win32Hwnd);
296
297 if(userWindowBytes)
298 free(userWindowBytes);
299
300 if(windowNameA) {
301 free(windowNameA);
302 windowNameA = NULL;
303 }
304 if(windowNameW) {
305 free(windowNameW);
306 windowNameW = NULL;
307 }
308 if(vertScrollInfo) {
309 free(vertScrollInfo);
310 vertScrollInfo = NULL;
311 }
312 if(horzScrollInfo) {
313 free(horzScrollInfo);
314 horzScrollInfo = NULL;
315 }
316 if(propertyList) {
317 removeWindowProps();
318 }
319 Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
320 if(wndparent && !fDestroyAll) {
321 RELEASE_WNDOBJ(wndparent);
322 }
323 if(owner && !fDestroyAll) {
324 RELEASE_WNDOBJ(owner);
325 }
326}
327//******************************************************************************
328//******************************************************************************
329void Win32BaseWindow::DestroyAll()
330{
331 fDestroyAll = TRUE;
332 GenericObject::DestroyAll(windows);
333}
334//******************************************************************************
335//******************************************************************************
336BOOL Win32BaseWindow::isChild()
337{
338 return ((dwStyle & WS_CHILD) != 0);
339}
340//******************************************************************************
341//******************************************************************************
342BOOL Win32BaseWindow::IsWindowUnicode()
343{
344 dprintf2(("IsWindowUnicode %x %d", getWindowHandle(), WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W));
345 return (WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W);
346}
347//******************************************************************************
348//******************************************************************************
349BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom)
350{
351 char buffer[256];
352
353#ifdef DEBUG
354 PrintWindowStyle(cs->style, cs->dwExStyle);
355#endif
356
357 //If window has no owner/parent window, then it will be added to the tasklist
358 //(depending on visibility state)
359 if (!cs->hwndParent) fTaskList = TRUE;
360
361 sw = SW_SHOW;
362 SetLastError(0);
363
364 /* Find the parent window */
365 if (cs->hwndParent)
366 {
367 Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
368 if(!window) {
369 dprintf(("Bad parent %04x\n", cs->hwndParent ));
370 SetLastError(ERROR_INVALID_PARAMETER);
371 return FALSE;
372 }
373 /* Make sure parent is valid */
374 if (!window->IsWindow() )
375 {
376 RELEASE_WNDOBJ(window);
377 dprintf(("Bad parent %04x\n", cs->hwndParent ));
378 SetLastError(ERROR_INVALID_PARAMETER);
379 return FALSE;
380 }
381 RELEASE_WNDOBJ(window);
382 /* Windows does this for overlapped windows
383 * (I don't know about other styles.) */
384 if (cs->hwndParent == GetDesktopWindow() && (!(cs->style & WS_CHILD) || (cs->style & WS_POPUP)))
385 {
386 cs->hwndParent = 0;
387 }
388 }
389 else
390 if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
391 dprintf(("No parent for child window" ));
392 SetLastError(ERROR_INVALID_PARAMETER);
393 return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
394 }
395
396 /* Find the window class */
397 windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
398 if (!windowClass)
399 {
400 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
401 dprintf(("Bad class '%s'", buffer ));
402 SetLastError(ERROR_INVALID_PARAMETER);
403 return 0;
404 }
405
406#ifdef DEBUG
407 if(HIWORD(cs->lpszClass))
408 {
409 if(isUnicode) dprintf(("Window class %ls", cs->lpszClass));
410 else dprintf(("Window class %s", cs->lpszClass));
411 }
412 else dprintf(("Window class %x", cs->lpszClass));
413#endif
414
415 /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
416 * with an atom as the class name, put some programs expect to have a *REAL* string in
417 * lpszClass when the CREATESTRUCT is sent with WM_CREATE
418 */
419 if (!HIWORD(cs->lpszClass) ) {
420 if (isUnicode) {
421 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
422 }
423 else {
424 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
425 }
426 cs->lpszClass = buffer;
427 }
428
429 /* Fix the coordinates */
430 fXDefault = FALSE;
431 fCXDefault = FALSE;
432 if ((cs->x == CW_USEDEFAULT) || (cs->x == CW_USEDEFAULT16))
433 {
434 /* Never believe Microsoft's documentation... CreateWindowEx doc says
435 * that if an overlapped window is created with WS_VISIBLE style bit
436 * set and the x parameter is set to CW_USEDEFAULT, the system ignores
437 * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
438 * reveals that
439 *
440 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
441 * 2) it does not ignore the y parameter as the docs claim; instead, it
442 * uses it as second parameter to ShowWindow() unless y is either
443 * CW_USEDEFAULT or CW_USEDEFAULT16.
444 *
445 * The fact that we didn't do 2) caused bogus windows pop up when wine
446 * was running apps that were using this obscure feature. Example -
447 * calc.exe that comes with Win98 (only Win98, it's different from
448 * the one that comes with Win95 and NT)
449 */
450 if ((cs->y != CW_USEDEFAULT) && (cs->y != CW_USEDEFAULT16)) sw = cs->y;
451
452 /* We have saved cs->y, now we can trash it */
453 cs->x = 0;
454 cs->y = 0;
455 fXDefault = TRUE;
456 }
457 if ((cs->cx == CW_USEDEFAULT) || (cs->cx == CW_USEDEFAULT16))
458 {
459 cs->cx = 600; /* FIXME */
460 cs->cy = 400;
461 fCXDefault = TRUE;
462 }
463 if (cs->style & (WS_POPUP | WS_CHILD))
464 {
465 fXDefault = FALSE;
466 if (fCXDefault)
467 {
468 fCXDefault = FALSE;
469 cs->cx = cs->cy = 0;
470 }
471 }
472 if (fXDefault && !fCXDefault) fXDefault = FALSE; //CB: only x positioning doesn't work (calc.exe,cdrlabel.exe)
473
474
475 /* Correct the window style - stage 1
476 *
477 * These are patches that appear to affect both the style loaded into the
478 * WIN structure and passed in the CreateStruct to the WM_CREATE etc.
479 *
480 * WS_EX_WINDOWEDGE appears to be enforced based on the other styles, so
481 * why does the user get to set it?
482 */
483
484 /* This has been tested for WS_CHILD | WS_VISIBLE. It has not been
485 * tested for WS_POPUP
486 */
487 if ((cs->dwExStyle & WS_EX_DLGMODALFRAME) ||
488 ((!(cs->dwExStyle & WS_EX_STATICEDGE)) &&
489 (cs->style & (WS_DLGFRAME | WS_THICKFRAME))))
490 cs->dwExStyle |= WS_EX_WINDOWEDGE;
491 else
492 cs->dwExStyle &= ~WS_EX_WINDOWEDGE;
493
494 //Allocate window words
495 nrUserWindowBytes = windowClass->getExtraWndBytes();
496 if(nrUserWindowBytes) {
497 userWindowBytes = (char *)_smalloc(nrUserWindowBytes);
498 memset(userWindowBytes, 0, nrUserWindowBytes);
499 }
500
501 if ((cs->style & WS_CHILD) && cs->hwndParent)
502 {
503 SetParent(cs->hwndParent);
504// owner = GetWindowFromHandle(cs->hwndParent);
505 owner = 0;
506/* if(owner == NULL)
507 {
508 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
509 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
510 return FALSE;
511 }*/
512 //SvL: Shell positioning shouldn't be done for child windows! (breaks Notes)
513 fXDefault = fCXDefault = FALSE;
514 }
515 else
516 {
517 SetParent(0);
518 if (!cs->hwndParent || (cs->hwndParent == windowDesktop->getWindowHandle())) {
519 owner = NULL;
520 }
521 else
522 {
523 Win32BaseWindow *wndparent = GetWindowFromHandle(cs->hwndParent);
524 if(wndparent) {
525 owner = GetWindowFromHandle(wndparent->GetTopParent());
526 RELEASE_WNDOBJ(wndparent);
527 }
528 else owner = NULL;
529
530 if(owner == NULL)
531 {
532 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
533 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
534 return FALSE;
535 }
536 }
537 }
538
539 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc(), WINPROC_GetProcType(windowClass->getWindowProc()), WIN_PROC_WINDOW);
540 hInstance = cs->hInstance;
541 dwStyle = cs->style & ~WS_VISIBLE;
542 dwOldStyle = dwStyle;
543 dwExStyle = cs->dwExStyle;
544
545 hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD) ? HWND_BOTTOM : HWND_TOP;
546
547 /* Correct the window style phase 2 */
548 if (!(cs->style & WS_CHILD))
549 {
550 dwStyle |= WS_CLIPSIBLINGS;
551 if (!(cs->style & WS_POPUP))
552 {
553 dwStyle |= WS_CAPTION;
554 flags |= WIN_NEED_SIZE;
555 }
556 }
557 if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
558
559 //WinZip 8.0 crashes when a dialog created after opening a zipfile receives
560 //the WM_SIZE message (before WM_INITDIALOG)
561 //Opera doesn't like this either.
562 if(IsDialog()) {
563 flags |= WIN_NEED_SIZE;
564 }
565
566 //copy pointer of CREATESTRUCT for usage in MsgCreate method
567 tmpcs = cs;
568
569 //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it
570 TEB *teb = GetThreadTEB();
571 if(teb == NULL) {
572 dprintf(("Window creation failed - teb == NULL")); //this is VERY bad
573 ExitProcess(666);
574 return FALSE;
575 }
576
577 teb->o.odin.newWindow = (ULONG)this;
578
579 DWORD dwOSWinStyle, dwOSFrameStyle;
580
581 OSLibWinConvertStyle(dwStyle,dwExStyle,&dwOSWinStyle, &dwOSFrameStyle);
582
583 OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
584 dwOSWinStyle, dwOSFrameStyle, (char *)windowNameA,
585 (owner) ? owner->getOS2WindowHandle() : ((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP),
586 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
587 0, fTaskList,fXDefault | fCXDefault,windowClass->getStyle(), &OS2HwndFrame);
588 if(OS2Hwnd == 0) {
589 dprintf(("Window creation failed!! OS LastError %0x", OSLibWinGetLastError()));
590 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
591 return FALSE;
592 }
593 OSLibWinSetVisibleRegionNotify(OS2Hwnd, TRUE);
594 state = STATE_CREATED;
595 SetLastError(0);
596 return TRUE;
597}
598//******************************************************************************
599//******************************************************************************
600BOOL Win32BaseWindow::MsgCreate(HWND hwndOS2)
601{
602 CREATESTRUCTA *cs = tmpcs; //pointer to CREATESTRUCT used in CreateWindowExA method
603 POINT maxSize, maxPos, minTrack, maxTrack;
604 HWND hwnd = getWindowHandle();
605 LRESULT (* CALLBACK localSend32)(HWND, UINT, WPARAM, LPARAM);
606
607 OS2Hwnd = hwndOS2;
608
609 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, getWindowHandle()) == FALSE) {
610 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
611 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
612 return FALSE;
613 }
614 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
615 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
616 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
617 return FALSE;
618 }
619 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32FLAGS, 0) == FALSE) {
620 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
621 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
622 return FALSE;
623 }
624
625 if (HOOK_IsHooked( WH_CBT ))
626 {
627 CBT_CREATEWNDA cbtc;
628 LRESULT ret;
629
630 cbtc.lpcs = cs;
631 cbtc.hwndInsertAfter = hwndLinkAfter;
632 ret = (isUnicode) ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc)
633 : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc);
634 if(ret)
635 {
636 dprintf(("CBT-hook returned 0!!"));
637 SetLastError(ERROR_CAN_NOT_COMPLETE); //todo: wrong error
638 return FALSE;
639 }
640 //todo: if hook changes parent, we need to do so too!!!!!!!!!!
641 }
642
643 if (cs->style & WS_HSCROLL)
644 {
645 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
646 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
647 horzScrollInfo->MaxVal = 100;
648 horzScrollInfo->flags = ESB_ENABLE_BOTH;
649 }
650
651 if (cs->style & WS_VSCROLL)
652 {
653 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
654 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
655 vertScrollInfo->MaxVal = 100;
656 vertScrollInfo->flags = ESB_ENABLE_BOTH;
657 }
658
659 // initially allocate the window name fields
660 if(HIWORD(cs->lpszName))
661 {
662 if (!isUnicode)
663 {
664 windowNameLength = strlen(cs->lpszName);
665 windowNameA = (LPSTR)_smalloc(windowNameLength+1);
666 memcpy(windowNameA,cs->lpszName,windowNameLength+1);
667 windowNameW = (LPWSTR)_smalloc((windowNameLength+1)*sizeof(WCHAR));
668 lstrcpynAtoW(windowNameW,windowNameA,windowNameLength+1);
669 windowNameA[windowNameLength] = 0;
670 windowNameW[windowNameLength] = 0;
671 }
672 else
673 {
674 // Wide
675 windowNameLength = lstrlenW((LPWSTR)cs->lpszName);
676 windowNameW = (LPWSTR)_smalloc( (windowNameLength+1)*sizeof(WCHAR) );
677 memcpy(windowNameW,(LPWSTR)cs->lpszName, (windowNameLength+1)*sizeof(WCHAR) );
678
679 // windowNameW[lstrlenW((LPWSTR)cs->lpszName)] = 0; // need ?
680
681 // Ascii
682 windowNameA = (LPSTR)_smalloc(windowNameLength+1);
683 WideCharToMultiByte(CP_ACP,
684 0,
685 windowNameW,
686 windowNameLength,
687 windowNameA,
688 windowNameLength + 1,
689 0,
690 NULL);
691 windowNameA[windowNameLength] = 0;
692 }
693
694 if(fOS2Look) {
695 OSLibWinSetTitleBarText(OS2HwndFrame, windowNameA);
696 }
697 }
698
699//SvL: This completely messes up MS Word 97 (no button bar, no menu)
700#if 0
701 //adjust CW_USEDEFAULT position
702 if (fXDefault | fCXDefault)
703 {
704 RECT rect;
705
706 //SvL: Returns invalid rectangle (not the expected shell default size)
707 OSLibWinQueryWindowRect(OS2Hwnd,&rect,RELATIVE_TO_SCREEN);
708 if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rect);
709 if (fXDefault)
710 {
711 cs->x = rect.left;
712 cs->y = rect.top;
713 if (!fCXDefault)
714 {
715 //CB: todo: adjust pos to screen rect
716 }
717 }
718 if (fCXDefault)
719 {
720 cs->cx = rect.right-rect.left;
721 cs->cy = rect.bottom-rect.top;
722 }
723 }
724#endif
725
726 fakeWinBase.hwndThis = OS2Hwnd;
727 fakeWinBase.pWindowClass = windowClass;
728
729 //Set icon from window or class
730 if (hIcon)
731 OSLibWinSetIcon(OS2HwndFrame,hIcon);
732 else
733 if (windowClass->getIcon())
734 OSLibWinSetIcon(OS2HwndFrame,windowClass->getIcon());
735
736 /* Get class or window DC if needed */
737 if(windowClass->getStyle() & CS_OWNDC) {
738 dprintf(("Class with CS_OWNDC style"));
739 ownDC = GetDCEx(getWindowHandle(), NULL, DCX_USESTYLE);
740 }
741 else
742 if (windowClass->getStyle() & CS_PARENTDC) {
743 fParentDC = TRUE;
744 ownDC = 0;
745 }
746 else
747 if (windowClass->getStyle() & CS_CLASSDC) {
748 dprintf(("WARNING: Class with CS_CLASSDC style!"));
749 //not a good solution, but it's a bit difficult to share a single
750 //DC among different windows... DevOpenDC apparently can't be used
751 //for window DCs and WinOpenWindowDC must be associated with a window
752 ownDC = GetDCEx(getWindowHandle(), NULL, DCX_USESTYLE);
753 }
754 /* Set the window menu */
755 if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
756 {
757 if (cs->hMenu) {
758 ::SetMenu(getWindowHandle(), cs->hMenu);
759 }
760 else {
761 if (windowClass->getMenuNameA()) {
762 cs->hMenu = LoadMenuA(windowClass->getInstance(),windowClass->getMenuNameA());
763#if 0 //CB: hack for treeview test cases bug
764if (!cs->hMenu) cs->hMenu = LoadMenuA(windowClass->getInstance(),"MYAPP");
765#endif
766 if (cs->hMenu) ::SetMenu(getWindowHandle(), cs->hMenu );
767 }
768 }
769 }
770 else
771 {
772 setWindowId((DWORD)cs->hMenu);
773 }
774 hSysMenu = (dwStyle & WS_SYSMENU) ? MENU_GetSysMenu(Win32Hwnd,0):0;
775
776 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
777 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
778 {
779 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
780 if (maxSize.x < cs->cx) cs->cx = maxSize.x;
781 if (maxSize.y < cs->cy) cs->cy = maxSize.y;
782 if (cs->cx < minTrack.x) cs->cx = minTrack.x;
783 if (cs->cy < minTrack.y) cs->cy = minTrack.y;
784 }
785
786 if(cs->style & WS_CHILD)
787 {
788 if(cs->cx < 0) cs->cx = 0;
789 if(cs->cy < 0) cs->cy = 0;
790 }
791 else
792 {
793 if (cs->cx <= 0) cs->cx = 1;
794 if (cs->cy <= 0) cs->cy = 1;
795 }
796
797 //set client & window rectangles from CreateWindowEx CREATESTRUCT
798 rectWindow.left = cs->x;
799 rectWindow.right = cs->x+cs->cx;
800 rectWindow.top = cs->y;
801 rectWindow.bottom = cs->y+cs->cy;
802 rectClient = rectWindow;
803 OffsetRect(&rectClient, -rectClient.left, -rectClient.top);
804
805 /* Send the WM_CREATE message
806 * Perhaps we shouldn't allow width/height changes as well.
807 * See p327 in "Internals".
808 */
809 maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
810
811 if(fTaskList) {
812 hTaskList = OSLibWinAddToTaskList(OS2HwndFrame, windowNameA, (cs->style & WS_VISIBLE) ? 1 : 0);
813 }
814
815 localSend32 = (isUnicode) ? ::SendMessageW : ::SendMessageA;
816
817 state = STATE_PRE_WMNCCREATE;
818 if(localSend32(getWindowHandle(), WM_NCCREATE,0,(LPARAM)cs))
819 {
820 RECT tmpRect;
821
822 //CB: recheck flags
823 if (cs->style & (WS_POPUP | WS_CHILD))
824 {
825 fXDefault = FALSE;
826 if (fCXDefault)
827 {
828 fCXDefault = FALSE;
829 cs->cx = cs->cy = 0;
830 rectWindow.right = rectWindow.left;
831 rectWindow.bottom = rectWindow.top;
832 }
833 }
834 tmpRect = rectWindow;
835 state = STATE_POST_WMNCCREATE;
836
837 //set the window size and update the client
838 SetWindowPos(hwndLinkAfter, tmpRect.left, tmpRect.top, tmpRect.right-tmpRect.left, tmpRect.bottom-tmpRect.top,SWP_NOACTIVATE | SWP_NOREDRAW | SWP_FRAMECHANGED);
839
840 state = STATE_PRE_WMCREATE;
841 if (cs->style & WS_VISIBLE) dwStyle |= WS_VISIBLE; //program could change position in WM_CREATE
842 if( (localSend32(getWindowHandle(), WM_CREATE, 0, (LPARAM)cs )) != -1 )
843 {
844 state = STATE_POST_WMCREATE;
845
846 if(!(flags & WIN_NEED_SIZE))
847 {
848 SendInternalMessageA(WM_SIZE, SIZE_RESTORED,
849 MAKELONG(rectClient.right-rectClient.left,
850 rectClient.bottom-rectClient.top));
851
852 if(!::IsWindow(hwnd))
853 {
854 dprintf(("Createwindow: WM_SIZE destroyed window"));
855 goto end;
856 }
857 SendInternalMessageA(WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top));
858 if(!::IsWindow(hwnd))
859 {
860 dprintf(("Createwindow: WM_MOVE destroyed window"));
861 goto end;
862 }
863 }
864 if (getStyle() & (WS_MINIMIZE | WS_MAXIMIZE))
865 {
866 RECT newPos;
867 UINT swFlag = (getStyle() & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
868 setStyle(getStyle() & ~(WS_MAXIMIZE | WS_MINIMIZE));
869 MinMaximize(swFlag, &newPos);
870 swFlag = ((getStyle() & WS_CHILD) || GetActiveWindow()) ? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED
871 : SWP_NOZORDER | SWP_FRAMECHANGED;
872 SetWindowPos(0, newPos.left, newPos.top, newPos.right, newPos.bottom, swFlag);
873 if(!::IsWindow(hwnd))
874 {
875 dprintf(("Createwindow: min/max destroyed window"));
876 goto end;
877 }
878 }
879
880 if( (getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
881 {
882 /* Notify the parent window only */
883 if(getParent() && getParent()->IsWindowDestroyed() == FALSE)
884 {
885 getParent()->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle());
886 }
887 if(!::IsWindow(hwnd))
888 {
889 dprintf(("Createwindow: WM_PARENTNOTIFY destroyed window"));
890 goto end;
891 }
892 }
893
894 if(cs->style & WS_VISIBLE) {
895 dwStyle &= ~WS_VISIBLE;
896 ShowWindow(sw);
897 }
898
899 /* Call WH_SHELL hook */
900 if (!(getStyle() & WS_CHILD) && !owner)
901 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWCREATED, getWindowHandle(), 0);
902
903 SetLastError(0);
904 return TRUE;
905 }
906 }
907 dprintf(("Window creation FAILED (NCCREATE cancelled creation)"));
908 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
909end:
910 return FALSE;
911}
912//******************************************************************************
913//******************************************************************************
914ULONG Win32BaseWindow::MsgQuit()
915{
916 return SendInternalMessageA(WM_QUIT, 0, 0);
917}
918//******************************************************************************
919//******************************************************************************
920ULONG Win32BaseWindow::MsgClose()
921{
922 return SendInternalMessageA(WM_CLOSE,0,0);
923}
924//******************************************************************************
925//******************************************************************************
926ULONG Win32BaseWindow::MsgDestroy()
927{
928 ULONG rc;
929 Win32BaseWindow *child;
930 HWND hwnd = getWindowHandle();
931
932 state = STATE_DESTROYED;
933
934 if(fDestroyWindowCalled == FALSE)
935 {//this window was destroyed because DestroyWindow was called for it's parent
936 //so: send a WM_PARENTNOTIFY now as that hasn't happened yet
937 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
938 {
939 if(getParent() && getParent()->IsWindowDestroyed() == FALSE)
940 {
941 /* Notify the parent window only */
942 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
943 }
944//// else DebugInt3();
945 }
946 }
947 SendInternalMessageA(WM_DESTROY, 0, 0);
948 if(::IsWindow(hwnd) == FALSE) {
949 //object already destroyed, so return immediately
950 return 1;
951 }
952 SendInternalMessageA(WM_NCDESTROY, 0, 0);
953
954 TIMER_KillTimerFromWindow(getWindowHandle());
955
956 if(getRefCount() == 0 && getFirstChild() == NULL && state == STATE_CREATED) {
957 delete this;
958 }
959 else {
960 //make sure no message can ever arrive for this window again (PM or from other win32 windows)
961 dprintf(("Mark window %x (%x) as deleted", getWindowHandle(), this));
962 markDeleted();
963 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
964 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
965 if(Win32Hwnd) {
966 HwFreeWindowHandle(Win32Hwnd);
967 Win32Hwnd = 0;
968 }
969 }
970 return 1;
971}
972//******************************************************************************
973//******************************************************************************
974ULONG Win32BaseWindow::MsgEnable(BOOL fEnable)
975{
976 if(fEnable) {
977 dwStyle &= ~WS_DISABLED;
978 }
979 else dwStyle |= WS_DISABLED;
980
981 return SendInternalMessageA(WM_ENABLE, fEnable, 0);
982}
983//******************************************************************************
984//TODO: SW_PARENTCLOSING/OPENING flag (lParam)
985//******************************************************************************
986ULONG Win32BaseWindow::MsgShow(BOOL fShow)
987{
988 if(!CanReceiveSizeMsgs() || fDestroyWindowCalled) {
989 return 1;
990 }
991
992 if(fShow) {
993 setStyle(getStyle() | WS_VISIBLE);
994 if(getStyle() & WS_MINIMIZE) {
995 return ShowWindow(SW_RESTORE);
996 }
997 }
998 else setStyle(getStyle() & ~WS_VISIBLE);
999
1000 //already sent from ShowWindow
1001//// return SendInternalMessageA(WM_SHOWWINDOW, fShow, 0);
1002 return 0;
1003}
1004//******************************************************************************
1005//******************************************************************************
1006ULONG Win32BaseWindow::MsgPosChanging(LPARAM lp)
1007{
1008 //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
1009 // a WM_WINDOWPOSCHANGED msg -> crash)
1010 if(!CanReceiveSizeMsgs() || fDestroyWindowCalled)
1011 return 0;
1012
1013 return SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, lp);
1014}
1015//******************************************************************************
1016//******************************************************************************
1017ULONG Win32BaseWindow::MsgPosChanged(LPARAM lp)
1018{
1019 //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
1020 // a WM_WINDOWPOSCHANGED msg -> crash)
1021 if(!CanReceiveSizeMsgs() || fDestroyWindowCalled)
1022 return 1;
1023
1024 return SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, lp);
1025}
1026//******************************************************************************
1027//******************************************************************************
1028ULONG Win32BaseWindow::MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos)
1029{
1030 //According to the SDK docs, the scrollbar handle (lParam) is 0 when the standard
1031 //window scrollbars send these messages
1032 return SendInternalMessageA(msg, MAKELONG(scrollCode, scrollPos), 0);
1033}
1034//******************************************************************************
1035//******************************************************************************
1036ULONG Win32BaseWindow::MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd, HWND hwndOS2Win)
1037{
1038 ULONG rc, procidhwnd = -1, threadidhwnd = 0;
1039
1040 //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
1041 if(fDestroyWindowCalled) {
1042 return 0;
1043 }
1044
1045 //According to SDK docs, if app returns FALSE & window is being deactivated,
1046 //default processing is cancelled
1047 //TODO: According to Wine we should proceed anyway if window is sysmodal
1048 if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
1049 {
1050 dprintf(("WARNING: WM_NCACTIVATE return code = FALSE -> cancel processing"));
1051 return 0;
1052 }
1053 /* child windows get a WM_CHILDACTIVATE message */
1054 if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
1055 {
1056 if(fActivate) {//WM_CHILDACTIVE is for activation only
1057 SendInternalMessageA(WM_CHILDACTIVATE, 0, 0L);
1058 }
1059 return 0;
1060 }
1061
1062 return SendInternalMessageA(WM_ACTIVATE, MAKELONG((fActivate) ? WA_ACTIVE : WA_INACTIVE, fMinimized), hwnd);
1063}
1064//******************************************************************************
1065//******************************************************************************
1066ULONG Win32BaseWindow::MsgChildActivate(BOOL fActivate)
1067{
1068 //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
1069 if(fDestroyWindowCalled) {
1070 return 0;
1071 }
1072
1073 //According to SDK docs, if app returns FALSE & window is being deactivated,
1074 //default processing is cancelled
1075 //TODO: According to Wine we should proceed anyway if window is sysmodal
1076 if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
1077 {
1078 dprintf(("WARNING: WM_NCACTIVATE return code = FALSE -> cancel processing"));
1079 return 0;
1080 }
1081 /* child windows get a WM_CHILDACTIVATE message */
1082 if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
1083 {
1084 if(fActivate) {//WM_CHILDACTIVE is for activation only
1085 SendInternalMessageA(WM_CHILDACTIVATE, 0, 0L);
1086 }
1087 return 0;
1088 }
1089 DebugInt3();
1090 return 0;
1091}
1092//******************************************************************************
1093//******************************************************************************
1094ULONG Win32BaseWindow::DispatchMsgA(MSG *msg)
1095{
1096 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
1097}
1098//******************************************************************************
1099//******************************************************************************
1100ULONG Win32BaseWindow::DispatchMsgW(MSG *msg)
1101{
1102 return SendInternalMessageW(msg->message, msg->wParam, msg->lParam);
1103}
1104//******************************************************************************
1105//******************************************************************************
1106ULONG Win32BaseWindow::MsgSetFocus(HWND hwnd)
1107{
1108 //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
1109 if(fDestroyWindowCalled) {
1110 return 0;
1111 }
1112
1113 return SendInternalMessageA(WM_SETFOCUS, hwnd, 0);
1114}
1115//******************************************************************************
1116//******************************************************************************
1117ULONG Win32BaseWindow::MsgKillFocus(HWND hwnd)
1118{
1119 //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
1120 if(fDestroyWindowCalled) {
1121 return 0;
1122 }
1123 return SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
1124}
1125//******************************************************************************
1126//******************************************************************************
1127ULONG Win32BaseWindow::MsgButton(MSG *msg)
1128{
1129 BOOL fClick = FALSE;
1130
1131 dprintf(("MsgButton %d at (%d,%d)", msg->message, msg->pt.x, msg->pt.y));
1132 switch(msg->message) {
1133 case WM_LBUTTONDBLCLK:
1134 case WM_RBUTTONDBLCLK:
1135 case WM_MBUTTONDBLCLK:
1136 if (!(windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS))
1137 {
1138 msg->message = msg->message - (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); //dblclick -> down
1139 return MsgButton(msg);
1140 }
1141 break;
1142 case WM_NCLBUTTONDBLCLK:
1143 case WM_NCRBUTTONDBLCLK:
1144 case WM_NCMBUTTONDBLCLK:
1145 //Docs say CS_DBLCLKS style doesn't matter for non-client double clicks
1146 fClick = TRUE;
1147 break;
1148
1149 case WM_LBUTTONDOWN:
1150 case WM_RBUTTONDOWN:
1151 case WM_MBUTTONDOWN:
1152 case WM_NCLBUTTONDOWN:
1153 case WM_NCRBUTTONDOWN:
1154 case WM_NCMBUTTONDOWN:
1155 fClick = TRUE;
1156 break;
1157 }
1158
1159 if(fClick)
1160 {
1161 HWND hwndTop;
1162
1163 /* Activate the window if needed */
1164 hwndTop = GetTopParent();
1165
1166 HWND hwndActive = GetActiveWindow();
1167 if (hwndTop && (getWindowHandle() != hwndActive))
1168 {
1169 LONG ret = SendInternalMessageA(WM_MOUSEACTIVATE, hwndTop,
1170 MAKELONG( lastHitTestVal, msg->message) );
1171
1172 dprintf2(("WM_MOUSEACTIVATE returned %d", ret));
1173#if 0
1174 if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
1175 eatMsg = TRUE;
1176#endif
1177 //SvL: 0 is not documented, but experiments in NT4 show that
1178 // the window will get activated when it returns this.
1179 // (FreeCell is an example)
1180 if(((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT) || (ret == 0))
1181 && (hwndTop != GetForegroundWindow()) )
1182 {
1183 Win32BaseWindow *win32top = Win32BaseWindow::GetWindowFromHandle(hwndTop);
1184
1185 //SvL: Calling OSLibSetActiveWindow(hwndTop); causes focus problems
1186 if (win32top) {
1187 OSLibWinSetFocus(win32top->getOS2FrameWindowHandle());
1188 RELEASE_WNDOBJ(win32top);
1189 }
1190 }
1191 }
1192 }
1193
1194 SendInternalMessageA(WM_SETCURSOR, getWindowHandle(), MAKELONG(lastHitTestVal, msg->message));
1195
1196 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
1197}
1198//******************************************************************************
1199//******************************************************************************
1200ULONG Win32BaseWindow::MsgPaint(ULONG tmp, ULONG select)
1201{
1202 if (select && IsWindowIconic())
1203 return SendInternalMessageA(WM_PAINTICON, 1, 0);
1204 else
1205 return SendInternalMessageA(WM_PAINT, 0, 0);
1206}
1207//******************************************************************************
1208//TODO: Is the clipper region of the window DC equal to the invalidated rectangle?
1209// (or are we simply erasing too much here)
1210//******************************************************************************
1211ULONG Win32BaseWindow::MsgEraseBackGround(HDC hdc)
1212{
1213 ULONG rc;
1214 HDC hdcErase = hdc;
1215
1216 if (hdcErase == 0)
1217 hdcErase = GetDC(getWindowHandle());
1218
1219 if(IsWindowIconic())
1220 rc = SendInternalMessageA(WM_ICONERASEBKGND, hdcErase, 0);
1221 else
1222 rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0);
1223 if (hdc == 0)
1224 ReleaseDC(getWindowHandle(), hdcErase);
1225 return (rc);
1226}
1227//******************************************************************************
1228//******************************************************************************
1229ULONG Win32BaseWindow::MsgMouseMove(MSG *msg)
1230{
1231 //TODO: hiword should be 0 if window enters menu mode (SDK docs)
1232 //SDK: WM_SETCURSOR is not sent if the mouse is captured
1233 if(GetCapture() == 0) {
1234 SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, msg->message));
1235 }
1236
1237 //translated message == WM_(NC)MOUSEMOVE
1238 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
1239}
1240//******************************************************************************
1241//******************************************************************************
1242ULONG Win32BaseWindow::MsgChar(MSG *msg)
1243{
1244 return DispatchMsgA(msg);
1245}
1246//******************************************************************************
1247//TODO: Should use update region, not rectangle
1248//******************************************************************************
1249ULONG Win32BaseWindow::MsgNCPaint(PRECT pUpdateRect)
1250{
1251 HRGN hrgn;
1252 ULONG rc;
1253 RECT client = rectClient;
1254
1255 if ((pUpdateRect->left >= client.left) && (pUpdateRect->left < client.right) &&
1256 (pUpdateRect->right >= client.left) && (pUpdateRect->right < client.right) &&
1257 (pUpdateRect->top >= client.top) && (pUpdateRect->top < client.bottom) &&
1258 (pUpdateRect->bottom >= client.top) && (pUpdateRect->bottom < client.bottom))
1259 {
1260 return 0;
1261 }
1262
1263 dprintf(("MsgNCPaint (%d,%d)(%d,%d)", pUpdateRect->left, pUpdateRect->top, pUpdateRect->right, pUpdateRect->bottom));
1264 hrgn = CreateRectRgnIndirect(pUpdateRect);
1265
1266 rc = SendInternalMessageA(WM_NCPAINT, hrgn, 0);
1267
1268 DeleteObject(hrgn);
1269
1270 return rc;
1271}
1272//******************************************************************************
1273//Called when either the frame's size or position has changed (lpWndPos != NULL)
1274//or when the frame layout has changed (i.e. scrollbars added/removed) (lpWndPos == NULL)
1275//******************************************************************************
1276ULONG Win32BaseWindow::MsgFormatFrame(WINDOWPOS *lpWndPos)
1277{
1278 RECT oldWindowRect = rectWindow, client = rectClient, newWindowRect;
1279 RECT newClientRect;
1280 WINDOWPOS wndPos;
1281 ULONG rc;
1282
1283 if(lpWndPos)
1284 {
1285 //set new window rectangle
1286 setWindowRect(lpWndPos->x, lpWndPos->y, lpWndPos->x+lpWndPos->cx,
1287 lpWndPos->y+lpWndPos->cy);
1288 newWindowRect = rectWindow;
1289 }
1290 else {
1291 wndPos.hwnd = getWindowHandle();
1292 wndPos.hwndInsertAfter = 0;
1293 newWindowRect= rectWindow;
1294 wndPos.x = newWindowRect.left;
1295 wndPos.y = newWindowRect.top;
1296 wndPos.cx = newWindowRect.right - newWindowRect.left;
1297 wndPos.cy = newWindowRect.bottom - newWindowRect.top;
1298 wndPos.flags = SWP_FRAMECHANGED;
1299 lpWndPos = &wndPos;
1300 }
1301
1302 newClientRect = rectClient;
1303 rc = SendNCCalcSize(TRUE, &newWindowRect, &oldWindowRect, &client, lpWndPos, &newClientRect);
1304 rectClient = newClientRect; //must update rectClient here
1305
1306 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));
1307 dprintf(("MsgFormatFrame: old window rect (%d,%d)(%d,%d), new window (%d,%d)(%d,%d)", oldWindowRect.left, oldWindowRect.top, oldWindowRect.right, oldWindowRect.bottom, rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom));
1308
1309 if(!CanReceiveSizeMsgs() || !EqualRect(&client, &rectClient)) {
1310 OSLibWinSetClientPos(getOS2WindowHandle(), rectClient.left, rectClient.top, getClientWidth(), getClientHeight(), getWindowHeight());
1311 }
1312
1313#if 1
1314//this doesn't always work
1315// if(CanReceiveSizeMsgs() && (client.left != rectClient.left || client.top != rectClient.top))
1316 if(CanReceiveSizeMsgs() && ((oldWindowRect.right - oldWindowRect.left < rectClient.left
1317 || oldWindowRect.bottom - oldWindowRect.top < rectClient.top) ||
1318 (EqualRect(&oldWindowRect, &rectWindow) && (client.left != rectClient.left || client.top != rectClient.top))))
1319 {
1320 Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild();
1321
1322 //client rectangle has moved -> inform children
1323 dprintf(("MsgFormatFrame -> client rectangle has changed, move children"));
1324 while(child) {
1325 ::SetWindowPos(child->getWindowHandle(),
1326 HWND_TOP, child->getWindowRect()->left,
1327 child->getWindowRect()->top, 0, 0,
1328 SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
1329 child = (Win32BaseWindow *)child->getNextChild();
1330 }
1331 }
1332#endif
1333 if(fOS2Look && ((dwStyle & WS_CAPTION) == WS_CAPTION))
1334 {
1335 RECT rect = {0};
1336 int height = getWindowHeight();
1337 RECTLOS2 rectOS2;
1338
1339 AdjustRectOuter(&rect, FALSE);
1340
1341 rect.left = -rect.left;
1342 rect.top = rect.bottom - rect.top;
1343 rect.right = rectWindow.right - rectWindow.left - rect.right;
1344
1345 rectOS2.xLeft = rect.left;
1346 rectOS2.xRight = rect.right;
1347 rectOS2.yBottom = height - rect.top;
1348 rectOS2.yTop = height - rect.bottom;
1349 OSLibWinPositionFrameControls(getOS2FrameWindowHandle(), &rectOS2, dwStyle, dwExStyle, IconForWindow(ICON_SMALL));
1350 }
1351 return rc;
1352}
1353//******************************************************************************
1354//******************************************************************************
1355ULONG Win32BaseWindow::MsgSetText(LPSTR lpsz, LONG cch)
1356{
1357 return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
1358}
1359//******************************************************************************
1360//******************************************************************************
1361ULONG Win32BaseWindow::MsgGetTextLength()
1362{
1363 return SendInternalMessageA(WM_GETTEXTLENGTH, 0, 0);
1364}
1365//******************************************************************************
1366//******************************************************************************
1367void Win32BaseWindow::MsgGetText(char *wndtext, ULONG textlength)
1368{
1369 SendInternalMessageA(WM_GETTEXT, textlength, (LPARAM)wndtext);
1370}
1371//******************************************************************************
1372//******************************************************************************
1373BOOL Win32BaseWindow::isMDIClient()
1374{
1375 return FALSE;
1376}
1377//******************************************************************************
1378//******************************************************************************
1379BOOL Win32BaseWindow::isMDIChild()
1380{
1381 return FALSE;
1382}
1383//******************************************************************************
1384//TODO: Not complete
1385//******************************************************************************
1386BOOL Win32BaseWindow::isFrameWindow()
1387{
1388 if(getParent() == NULL)
1389 return TRUE;
1390
1391 return FALSE;
1392}
1393//******************************************************************************
1394//******************************************************************************
1395BOOL Win32BaseWindow::isDesktopWindow()
1396{
1397 return FALSE;
1398}
1399//******************************************************************************
1400//******************************************************************************
1401BOOL Win32BaseWindow::IsWindowIconic()
1402{
1403 return ((getStyle() & WS_MINIMIZE) && windowClass->getIcon());
1404}
1405//******************************************************************************
1406//******************************************************************************
1407SCROLLBAR_INFO *Win32BaseWindow::getScrollInfo(int nBar)
1408{
1409 switch(nBar)
1410 {
1411 case SB_HORZ:
1412 if (!horzScrollInfo)
1413 {
1414 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
1415 if (!horzScrollInfo) break;
1416 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
1417 horzScrollInfo->MaxVal = 100;
1418 horzScrollInfo->flags = ESB_ENABLE_BOTH;
1419 }
1420 return horzScrollInfo;
1421
1422 case SB_VERT:
1423 if (!vertScrollInfo)
1424 {
1425 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
1426 if (!vertScrollInfo) break;
1427 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
1428 vertScrollInfo->MaxVal = 100;
1429 vertScrollInfo->flags = ESB_ENABLE_BOTH;
1430 }
1431 return vertScrollInfo;
1432 }
1433
1434 return NULL;
1435}
1436//******************************************************************************
1437//******************************************************************************
1438LRESULT Win32BaseWindow::DefWndControlColor(UINT ctlType, HDC hdc)
1439{
1440 //SvL: Set background color to default button color (not window (white))
1441 if(ctlType == CTLCOLOR_BTN)
1442 {
1443 SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
1444 SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
1445 return GetSysColorBrush(COLOR_BTNFACE);
1446 }
1447 //SvL: Set background color to default dialog color if window is dialog
1448 if((ctlType == CTLCOLOR_DLG || ctlType == CTLCOLOR_STATIC) && IsDialog()) {
1449 SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
1450 SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
1451 return GetSysColorBrush(COLOR_BTNFACE);
1452 }
1453 if( ctlType == CTLCOLOR_SCROLLBAR)
1454 {
1455 HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
1456 COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
1457 SetTextColor( hdc, GetSysColor(COLOR_3DFACE));
1458 SetBkColor( hdc, bk);
1459
1460 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
1461 * we better use 0x55aa bitmap brush to make scrollbar's background
1462 * look different from the window background.
1463 */
1464 if (bk == GetSysColor(COLOR_WINDOW)) {
1465 return GetPattern55AABrush();
1466 }
1467
1468 UnrealizeObject( hb );
1469 return (LRESULT)hb;
1470 }
1471
1472 SetTextColor( hdc, GetSysColor(COLOR_WINDOWTEXT));
1473
1474 if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
1475 {
1476 SetBkColor( hdc, GetSysColor(COLOR_WINDOW) );
1477 }
1478 else
1479 {
1480 SetBkColor( hdc, GetSysColor(COLOR_3DFACE) );
1481 return (LRESULT)GetSysColorBrush(COLOR_3DFACE);
1482 }
1483 return (LRESULT)GetSysColorBrush(COLOR_WINDOW);
1484}
1485//******************************************************************************
1486//******************************************************************************
1487LRESULT Win32BaseWindow::DefWndPrint(HDC hdc,ULONG uFlags)
1488{
1489 /*
1490 * Visibility flag.
1491 */
1492 if ( (uFlags & PRF_CHECKVISIBLE) &&
1493 !IsWindowVisible(getWindowHandle()) )
1494 return 0;
1495
1496 /*
1497 * Unimplemented flags.
1498 */
1499 if ( (uFlags & PRF_CHILDREN) ||
1500 (uFlags & PRF_OWNED) ||
1501 (uFlags & PRF_NONCLIENT) )
1502 {
1503 dprintf(("WM_PRINT message with unsupported flags\n"));
1504 }
1505
1506 /*
1507 * Background
1508 */
1509 if ( uFlags & PRF_ERASEBKGND)
1510 SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
1511
1512 /*
1513 * Client area
1514 */
1515 if ( uFlags & PRF_CLIENT)
1516 SendInternalMessageA(WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
1517
1518
1519 return 0;
1520}
1521//******************************************************************************
1522//******************************************************************************
1523LRESULT Win32BaseWindow::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam)
1524{
1525 switch(Msg)
1526 {
1527 case WM_CLOSE:
1528 dprintf(("DefWindowProcA: WM_CLOSE %x", getWindowHandle()));
1529 DestroyWindow();
1530 return 0;
1531
1532 case WM_GETTEXTLENGTH:
1533 return windowNameLength;
1534
1535 case WM_GETTEXT:
1536 if (!lParam || !wParam)
1537 return 0;
1538 if (!windowNameA)
1539 ((LPSTR)lParam)[0] = 0;
1540 else
1541 memcpy((LPSTR)lParam, windowNameA, min(windowNameLength+1, wParam) );
1542 return min(windowNameLength, wParam);
1543
1544 case WM_SETTEXT:
1545 {
1546 LPCSTR lpsz = (LPCSTR)lParam;
1547
1548 // reallocate if new buffer is larger
1549 if (!lParam)
1550 {
1551 free(windowNameA);
1552 free(windowNameW);
1553 windowNameLength = 0;
1554 windowNameA = NULL;
1555 windowNameW = NULL;
1556 }
1557 else
1558 {
1559 // determine length of new text
1560 int iTextLength = strlen(lpsz);
1561
1562 if (windowNameLength < iTextLength)
1563 {
1564 if (windowNameA)
1565 {
1566 free(windowNameA);
1567 windowNameA = NULL;
1568 }
1569
1570 if (windowNameW)
1571 {
1572 free(windowNameW);
1573 windowNameW = NULL;
1574 }
1575 }
1576
1577 windowNameLength = iTextLength;
1578 if(!windowNameA)
1579 windowNameA = (LPSTR)_smalloc(windowNameLength+1);
1580 memcpy(windowNameA, lpsz, windowNameLength+1);
1581 if(!windowNameW)
1582 windowNameW = (LPWSTR)_smalloc((windowNameLength+1)*sizeof(WCHAR));
1583 lstrcpynAtoW(windowNameW, windowNameA, windowNameLength+1);
1584 }
1585
1586 dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, lParam));
1587 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
1588 {
1589 HandleNCPaint((HRGN)1);
1590 if(hTaskList) {
1591 OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
1592 }
1593 if(fOS2Look) {
1594 OSLibWinSetTitleBarText(OS2HwndFrame, getWindowNameA());
1595 }
1596 }
1597
1598 return TRUE;
1599 }
1600
1601 case WM_SETREDRAW:
1602 {
1603 if (wParam)
1604 {
1605 setStyle(getStyle() | WS_VISIBLE);
1606 dprintf(("Enable window update for %x", getWindowHandle()));
1607 OSLibWinEnableWindowUpdate(OS2HwndFrame, OS2Hwnd, TRUE);
1608 }
1609 else
1610 {
1611 if (getStyle() & WS_VISIBLE)
1612 {
1613 setStyle(getStyle() & ~WS_VISIBLE);
1614 dprintf(("Disable window update for %x", getWindowHandle()));
1615 OSLibWinEnableWindowUpdate(OS2HwndFrame, OS2Hwnd, FALSE);
1616 }
1617 }
1618 return 0;
1619 }
1620
1621 case WM_CTLCOLORMSGBOX:
1622 case WM_CTLCOLOREDIT:
1623 case WM_CTLCOLORLISTBOX:
1624 case WM_CTLCOLORBTN:
1625 case WM_CTLCOLORDLG:
1626 case WM_CTLCOLORSTATIC:
1627 case WM_CTLCOLORSCROLLBAR:
1628 return DefWndControlColor(Msg - WM_CTLCOLORMSGBOX, (HDC)wParam);
1629
1630 case WM_CTLCOLOR:
1631 return DefWndControlColor(HIWORD(lParam), (HDC)wParam);
1632
1633 case WM_VKEYTOITEM:
1634 case WM_CHARTOITEM:
1635 return -1;
1636
1637 case WM_PARENTNOTIFY:
1638 return 0;
1639
1640 case WM_MOUSEACTIVATE:
1641 {
1642 dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
1643 if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
1644 {
1645 if(getParent()) {
1646 LRESULT rc = getParent()->SendInternalMessageA(WM_MOUSEACTIVATE, wParam, lParam );
1647 if(rc) return rc;
1648 }
1649 }
1650 return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
1651 }
1652
1653 case WM_ACTIVATE:
1654 /* The default action in Windows is to set the keyboard focus to
1655 * the window, if it's being activated and not minimized */
1656 if (LOWORD(wParam) != WA_INACTIVE) {
1657 if(!(getStyle() & WS_MINIMIZE))
1658 SetFocus(getWindowHandle());
1659 }
1660 return 0;
1661
1662 case WM_SETCURSOR:
1663 {
1664 dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
1665 if((getStyle() & WS_CHILD))
1666 {
1667 if(getParent()) {
1668 LRESULT rc = getParent()->SendInternalMessageA(WM_SETCURSOR, wParam, lParam);
1669 if(rc) return rc;
1670 }
1671 }
1672 if (wParam == getWindowHandle())
1673 {
1674 HCURSOR hCursor;
1675
1676 switch(LOWORD(lParam))
1677 {
1678 case HTCLIENT:
1679 hCursor = windowClass ? windowClass->getCursor():LoadCursorA(0,IDC_ARROWA);
1680 break;
1681
1682 case HTLEFT:
1683 case HTRIGHT:
1684 hCursor = LoadCursorA(0,IDC_SIZEWEA);
1685 break;
1686
1687 case HTTOP:
1688 case HTBOTTOM:
1689 hCursor = LoadCursorA(0,IDC_SIZENSA);
1690 break;
1691
1692 case HTTOPLEFT:
1693 case HTBOTTOMRIGHT:
1694 hCursor = LoadCursorA(0,IDC_SIZENWSEA);
1695 break;
1696
1697 case HTTOPRIGHT:
1698 case HTBOTTOMLEFT:
1699 hCursor = LoadCursorA(0,IDC_SIZENESWA);
1700 break;
1701
1702 default:
1703 hCursor = LoadCursorA(0,IDC_ARROWA);
1704 break;
1705 }
1706
1707 if (hCursor)
1708 {
1709 SetCursor(hCursor);
1710 return 1;
1711 }
1712 else return 0;
1713 }
1714 else return 0;
1715 }
1716
1717 case WM_MOUSEMOVE:
1718 return 0;
1719
1720 case WM_WINDOWPOSCHANGED:
1721 {
1722 PWINDOWPOS wpos = (PWINDOWPOS)lParam;
1723 WPARAM wp = SIZE_RESTORED;
1724
1725 if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE))
1726 {
1727 SendInternalMessageA(WM_MOVE, 0, MAKELONG(rectClient.left,rectClient.top));
1728 }
1729 if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE))
1730 {
1731 if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
1732 else
1733 if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
1734
1735 SendInternalMessageA(WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left,
1736 rectClient.bottom - rectClient.top));
1737 }
1738 return 0;
1739 }
1740 case WM_WINDOWPOSCHANGING:
1741 return HandleWindowPosChanging((WINDOWPOS *)lParam);
1742
1743 case WM_ERASEBKGND:
1744 case WM_ICONERASEBKGND:
1745 {
1746 RECT rect;
1747 int rc;
1748
1749 if (!windowClass || !windowClass->getBackgroundBrush()) return 0;
1750
1751 rc = GetClipBox( (HDC)wParam, &rect );
1752 if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
1753 {
1754 HBRUSH hBrush = windowClass->getBackgroundBrush();
1755
1756 if (hBrush <= (HBRUSH)(SYSCOLOR_GetLastColor()+1))
1757 hBrush = GetSysColorBrush(hBrush-1);
1758
1759 FillRect( (HDC)wParam, &rect, hBrush);
1760 }
1761 return 1;
1762 }
1763
1764 case WM_PRINT:
1765 return DefWndPrint(wParam,lParam);
1766
1767 case WM_PAINTICON:
1768 case WM_PAINT:
1769 {
1770 PAINTSTRUCT ps;
1771 HDC hdc = BeginPaint(getWindowHandle(), &ps );
1772 if( hdc )
1773 {
1774 if( (getStyle() & WS_MINIMIZE) && (getWindowClass()->getIcon() || hIcon))
1775 {
1776 int x = (rectWindow.right - rectWindow.left - GetSystemMetrics(SM_CXICON))/2;
1777 int y = (rectWindow.bottom - rectWindow.top - GetSystemMetrics(SM_CYICON))/2;
1778 dprintf(("Painting class icon: vis rect=(%i,%i - %i,%i)\n", ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ));
1779 DrawIcon(hdc, x, y, hIcon ? hIcon:getWindowClass()->getIcon() );
1780 }
1781 EndPaint(getWindowHandle(), &ps );
1782 }
1783 return 0;
1784 }
1785
1786 case WM_GETDLGCODE:
1787 return 0;
1788
1789 case WM_NCPAINT:
1790 return HandleNCPaint((HRGN)wParam);
1791
1792 case WM_NCACTIVATE:
1793 return HandleNCActivate(wParam);
1794
1795 case WM_NCCREATE:
1796 return(TRUE);
1797
1798 case WM_NCDESTROY:
1799 return 0;
1800
1801 case WM_NCCALCSIZE:
1802 return HandleNCCalcSize((BOOL)wParam,(RECT*)lParam);
1803
1804 case WM_NCLBUTTONDOWN:
1805 return HandleNCLButtonDown(wParam,lParam);
1806
1807 case WM_LBUTTONDBLCLK:
1808 case WM_NCLBUTTONDBLCLK:
1809 return HandleNCLButtonDblClk(wParam,lParam);
1810
1811 case WM_NCRBUTTONDOWN:
1812 case WM_NCRBUTTONDBLCLK:
1813 case WM_NCMBUTTONDOWN:
1814 case WM_NCMBUTTONDBLCLK:
1815 if (lastHitTestVal == HTERROR) MessageBeep(MB_ICONEXCLAMATION);
1816 return 0;
1817
1818 case WM_NCRBUTTONUP:
1819 return HandleNCRButtonUp(wParam,lParam);
1820
1821 case WM_NCMBUTTONUP:
1822 return 0;
1823
1824 case WM_NCHITTEST:
1825 {
1826 POINT point;
1827 LRESULT retvalue;
1828
1829 point.x = (SHORT)LOWORD(lParam);
1830 point.y = (SHORT)HIWORD(lParam);
1831
1832 retvalue = HandleNCHitTest(point);
1833#if 0 //CB: let the Corel people fix the bugs first
1834 if(retvalue == HTMENU)
1835 MENU_TrackMouseMenuBar_MouseMove(Win32Hwnd,point,TRUE);
1836 else
1837 MENU_TrackMouseMenuBar_MouseMove(Win32Hwnd,point,FALSE);
1838#endif
1839 return retvalue;
1840 }
1841
1842 case WM_SYSCOMMAND:
1843 {
1844 POINT point;
1845
1846 point.x = LOWORD(lParam);
1847 point.y = HIWORD(lParam);
1848 return HandleSysCommand(wParam,&point);
1849 }
1850
1851 case WM_SYSKEYDOWN:
1852 {
1853 if( HIWORD(lParam) & KEYDATA_ALT )
1854 {
1855 /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
1856 if( wParam == VK_MENU && !iMenuSysKey )
1857 iMenuSysKey = 1;
1858 else
1859 iMenuSysKey = 0;
1860
1861 iF10Key = 0;
1862
1863 if( wParam == VK_F4 ) /* try to close the window */
1864 {
1865 HWND top = GetTopParent();
1866 if (!(GetClassLongW( top, GCL_STYLE ) & CS_NOCLOSE))
1867 PostMessageW( top, WM_SYSCOMMAND, SC_CLOSE, 0 );
1868 }
1869 }
1870 else if( wParam == VK_F10 )
1871 iF10Key = 1;
1872 else
1873 if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
1874 SendMessageW(WM_SYSCOMMAND, SC_KEYMENU, VK_SPACE );
1875
1876 Win32BaseWindow *siblingWindow;
1877 HWND sibling;
1878 char nameBuffer [40], mnemonic;
1879 int nameLength;
1880
1881 GetWindowTextA (nameBuffer, 40);
1882
1883 // search all sibling to see it this key is their mnemonic
1884 sibling = GetWindow (GW_HWNDFIRST);
1885 while (sibling != 0) {
1886 siblingWindow = GetWindowFromHandle (sibling);
1887 nameLength = siblingWindow->GetWindowTextA (nameBuffer, 40);
1888
1889 // find the siblings mnemonic
1890 mnemonic = '\0';
1891 for (int i=0 ; i<nameLength ; i++) {
1892 if (IsDBCSLeadByte(nameBuffer[i])) {
1893 // Skip DBCS
1894 continue;
1895 }
1896 if (nameBuffer [i] == '&') {
1897 mnemonic = nameBuffer [i+1];
1898 if ((mnemonic >= 'a') && (mnemonic <= 'z'))
1899 mnemonic -= 32; // make it uppercase
1900 break; // stop searching
1901 }
1902 }
1903
1904 // key matches siblings mnemonic, send mouseclick
1905 if (mnemonic == (char) wParam) {
1906 siblingWindow->SendInternalMessageA (BM_CLICK, 0, 0);
1907 }
1908 sibling = siblingWindow->GetNextWindow (GW_HWNDNEXT);
1909 RELEASE_WNDOBJ(siblingWindow);
1910 }
1911
1912 return 0;
1913 }
1914
1915 case WM_KEYUP:
1916 case WM_SYSKEYUP:
1917 /* Press and release F10 or ALT */
1918 if (((wParam == VK_MENU) && iMenuSysKey) ||
1919 ((wParam == VK_F10) && iF10Key))
1920 ::SendMessageW( GetTopWindow(), WM_SYSCOMMAND, SC_KEYMENU, 0L );
1921 iMenuSysKey = iF10Key = 0;
1922 break;
1923
1924 case WM_SYSCHAR:
1925 {
1926 iMenuSysKey = 0;
1927 if (wParam == VK_RETURN && (getStyle() & WS_MINIMIZE))
1928 {
1929 PostMessageA(getWindowHandle(), WM_SYSCOMMAND,
1930 (WPARAM)SC_RESTORE, 0L );
1931 break;
1932 }
1933 if((HIWORD(lParam) & KEYDATA_ALT) && wParam)
1934 {
1935 if (wParam == VK_TAB || wParam == VK_ESCAPE || wParam == VK_F4)
1936 break;
1937 if (wParam == VK_SPACE && (getStyle() & WS_CHILD)) {
1938 ::SendMessageW(GetParent(), Msg, wParam, lParam );
1939 }
1940 else SendMessageA(WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)wParam );
1941 }
1942#if 0
1943 else /* check for Ctrl-Esc */
1944 if (wParam != VK_ESCAPE) MessageBeep(0);
1945 break;
1946#endif
1947 }
1948
1949 case WM_SETHOTKEY:
1950 hotkey = wParam;
1951 return 1; //CB: always successful
1952
1953 case WM_GETHOTKEY:
1954 return hotkey;
1955
1956 case WM_CONTEXTMENU:
1957 if ((dwStyle & WS_CHILD) && getParent())
1958 getParent()->SendInternalMessageA(WM_CONTEXTMENU,wParam,lParam);
1959 return 0;
1960
1961 case WM_SHOWWINDOW:
1962 if (!lParam) return 0; /* sent from ShowWindow */
1963 if (!(dwStyle & WS_POPUP) || !owner) return 0;
1964 if ((dwStyle & WS_VISIBLE) && wParam) return 0;
1965 else if (!(dwStyle & WS_VISIBLE) && !wParam) return 0;
1966 ShowWindow(wParam ? SW_SHOW:SW_HIDE);
1967 return 0;
1968
1969 case WM_CANCELMODE:
1970 if (getParent() == windowDesktop) EndMenu();
1971 if (GetCapture() == Win32Hwnd) ReleaseCapture();
1972 return 0;
1973
1974 case WM_DROPOBJECT:
1975 return DRAG_FILE;
1976
1977 case WM_QUERYDROPOBJECT:
1978 return (dwExStyle & WS_EX_ACCEPTFILES) ? 1:0;
1979
1980 case WM_QUERYDRAGICON:
1981 {
1982 HICON hDragIcon = windowClass->getCursor();
1983 UINT len;
1984
1985 if(hDragIcon) return (LRESULT)hDragIcon;
1986 for(len = 1; len < 64; len++)
1987 {
1988 hDragIcon = LoadIconA(hInstance,MAKEINTRESOURCEA(len));
1989 if(hDragIcon)
1990 return (LRESULT)hDragIcon;
1991 }
1992 return (LRESULT)LoadIconA(0,IDI_APPLICATIONA);
1993 }
1994
1995 case WM_QUERYOPEN:
1996 case WM_QUERYENDSESSION:
1997 return 1;
1998
1999 case WM_NOTIFYFORMAT:
2000 return IsWindowUnicode() ? NFR_UNICODE:NFR_ANSI;
2001
2002 case WM_SETICON:
2003 case WM_GETICON:
2004 {
2005 LRESULT result = 0;
2006
2007 /* Set the appropriate icon members in the window structure. */
2008 if (wParam == ICON_SMALL)
2009 {
2010 result = hIconSm;
2011 if (Msg == WM_SETICON)
2012 hIconSm = (HICON)lParam;
2013 }
2014 else
2015 {
2016 result = hIcon;
2017 if (Msg == WM_SETICON)
2018 {
2019 hIcon = (HICON)lParam;
2020 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
2021 OSLibWinSetIcon(OS2HwndFrame,hIcon);
2022 }
2023 }
2024 if ((Msg == WM_SETICON) && ((dwStyle & WS_CAPTION) == WS_CAPTION))
2025 HandleNCPaint((HRGN)1);
2026
2027 return result;
2028 }
2029
2030 case WM_HELP:
2031 if (getParent()) getParent()->SendInternalMessageA(Msg,wParam,lParam);
2032 break;
2033
2034 case WM_NOTIFY:
2035 return 0; //comctl32 controls expect this
2036
2037 default:
2038 return 0;
2039 }
2040 return 0;
2041}
2042//******************************************************************************
2043//******************************************************************************
2044LRESULT Win32BaseWindow::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam)
2045{
2046 switch(Msg)
2047 {
2048 case WM_GETTEXTLENGTH:
2049 return windowNameLength;
2050
2051 case WM_GETTEXT:
2052 if (!lParam || !wParam)
2053 return 0;
2054 if (!windowNameW)
2055 ((LPWSTR)lParam)[0] = 0;
2056 else
2057 memcpy((LPSTR)lParam, windowNameW, min( sizeof(WCHAR) * (windowNameLength+1), wParam) );
2058 return min(windowNameLength, wParam);
2059
2060 case WM_SETTEXT:
2061 {
2062 LPWSTR lpsz = (LPWSTR)lParam;
2063
2064 // reallocate if new buffer is larger
2065 if (!lParam)
2066 {
2067 free(windowNameA);
2068 free(windowNameW);
2069 windowNameLength = 0;
2070 windowNameA = NULL;
2071 windowNameW = NULL;
2072 }
2073 else
2074 {
2075 // determine length of new text
2076 int iTextLength = lstrlenW(lpsz);
2077
2078 if (windowNameLength < iTextLength)
2079 {
2080 if (windowNameA)
2081 {
2082 free(windowNameA);
2083 windowNameA = NULL;
2084 }
2085
2086 if (windowNameW)
2087 {
2088 free(windowNameW);
2089 windowNameW = NULL;
2090 }
2091 }
2092
2093 windowNameLength = iTextLength;
2094 if(!windowNameW)
2095 windowNameW = (LPWSTR)_smalloc((windowNameLength+1)*sizeof(WCHAR));
2096 memcpy(windowNameW, lpsz, (windowNameLength+1) * sizeof(WCHAR));
2097 if(!windowNameA)
2098 windowNameA = (LPSTR)_smalloc(windowNameLength+1);
2099 lstrcpynWtoA(windowNameA, windowNameW, windowNameLength+1);
2100 }
2101
2102 dprintf(("WM_SETTEXT of %x\n",Win32Hwnd));
2103 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
2104 {
2105 HandleNCPaint((HRGN)1);
2106 if(hTaskList) {
2107 OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
2108 }
2109 if(fOS2Look) {
2110 OSLibWinSetTitleBarText(OS2HwndFrame, getWindowNameA());
2111 }
2112 }
2113
2114 return TRUE;
2115 }
2116
2117 default:
2118 return DefWindowProcA(Msg, wParam, lParam);
2119 }
2120}
2121//******************************************************************************
2122//******************************************************************************
2123LRESULT Win32BaseWindow::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
2124{
2125 //if the destination window is created by this process & thread, call window proc directly
2126 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
2127 return SendInternalMessageA(Msg, wParam, lParam);
2128 }
2129 //otherwise use WinSendMsg to send it to the right process/thread
2130 dprintf(("SendMessages (inter-process) %x %x %x %x", getWindowHandle(), Msg, wParam, lParam));
2131 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, FALSE);
2132}
2133//******************************************************************************
2134//******************************************************************************
2135LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
2136{
2137 //if the destination window is created by this process & thread, call window proc directly
2138 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
2139 return SendInternalMessageW(Msg, wParam, lParam);
2140 }
2141 //otherwise use WinSendMsg to send it to the right process/thread
2142 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, TRUE);
2143}
2144//******************************************************************************
2145//Called as a result of an OS/2 message or called from a class method
2146//******************************************************************************
2147LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
2148{
2149 LRESULT rc;
2150 HWND hwnd = getWindowHandle();
2151 BOOL fInternalMsgBackup = fInternalMsg;
2152
2153 //if the destination window was created by this process & thread, call window proc directly
2154 if(dwProcessId != currentProcessId || dwThreadId != GetCurrentThreadId()) {
2155 dprintf(("SendMessages (inter-process) %x %x %x %x", getWindowHandle(), Msg, wParam, lParam));
2156 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, FALSE);
2157 }
2158
2159 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE);
2160
2161 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, FALSE);
2162
2163 fInternalMsg = TRUE;
2164 switch(Msg)
2165 {
2166 case WM_CREATE:
2167 {
2168 if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
2169 dprintf(("WM_CREATE returned -1\n"));
2170 rc = -1; //don't create window
2171 break;
2172 }
2173 rc = 0;
2174 break;
2175 }
2176 case WM_LBUTTONDOWN:
2177 case WM_MBUTTONDOWN:
2178 case WM_RBUTTONDOWN:
2179 {
2180 if (getParent())
2181 {
2182 POINTS pt = MAKEPOINTS(lParam);
2183 POINT point;
2184
2185 point.x = pt.x;
2186 point.y = pt.y;
2187 MapWindowPoints(getWindowHandle(), getParent()->getWindowHandle(), &point, 1);
2188 NotifyParent(Msg,wParam,MAKELPARAM(point.x,point.y));
2189 }
2190 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
2191 break;
2192 }
2193 case WM_NCHITTEST:
2194 rc = lastHitTestVal = win32wndproc(getWindowHandle(), WM_NCHITTEST, wParam, lParam);
2195 break;
2196
2197 case WM_DESTROY:
2198 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
2199 break;
2200
2201 default:
2202 rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
2203 break;
2204 }
2205 if(!::IsWindow(hwnd)) {
2206 //window might have been destroyed by now. (this pointer invalid)
2207 //we must return immediately
2208 //(MS Visual C++ install heap corruption)
2209 //TODO: could happen in several places here!!!!
2210 return rc;
2211 }
2212 fInternalMsg = fInternalMsgBackup;
2213 dprintf2(("SendMessageA %x %x %x %x returned %x", getWindowHandle(), Msg, wParam, lParam, rc));
2214 return rc;
2215}
2216//******************************************************************************
2217//Called as a result of an OS/2 message or called from a class method
2218//******************************************************************************
2219LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
2220{
2221 LRESULT rc;
2222 HWND hwnd = getWindowHandle();
2223 BOOL fInternalMsgBackup = fInternalMsg;
2224
2225 //if the destination window was created by this process & thread, call window proc directly
2226 if(dwProcessId != currentProcessId || dwThreadId != GetCurrentThreadId()) {
2227 dprintf(("SendMessages (inter-process) %x %x %x %x", getWindowHandle(), Msg, wParam, lParam));
2228 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, FALSE);
2229 }
2230
2231 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE);
2232
2233 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, TRUE);
2234
2235 fInternalMsg = TRUE;
2236 switch(Msg)
2237 {
2238 case WM_CREATE:
2239 {
2240 if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
2241 dprintf(("WM_CREATE returned -1\n"));
2242 rc = -1; //don't create window
2243 break;
2244 }
2245 rc = 0;
2246 break;
2247 }
2248 case WM_LBUTTONDOWN:
2249 case WM_MBUTTONDOWN:
2250 case WM_RBUTTONDOWN:
2251 NotifyParent(Msg, wParam, lParam);
2252 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
2253 break;
2254
2255 case WM_NCHITTEST:
2256 rc = lastHitTestVal = win32wndproc(getWindowHandle(), WM_NCHITTEST, wParam, lParam);
2257 break;
2258
2259 case WM_DESTROY:
2260 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
2261 break;
2262 default:
2263 rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
2264 break;
2265 }
2266 if(!::IsWindow(hwnd)) {
2267 //window might have been destroyed by now. (this pointer invalid)
2268 //we must return immediately
2269 //(MS Visual C++ install heap corruption)
2270 //TODO: could happen in several places here!!!!
2271 return rc;
2272 }
2273 fInternalMsg = fInternalMsgBackup;
2274 dprintf2(("SendMessageW %x %x %x %x returned %x", getWindowHandle(), Msg, wParam, lParam, rc));
2275 return rc;
2276}
2277//******************************************************************************
2278//******************************************************************************
2279void Win32BaseWindow::CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
2280{
2281 CWPSTRUCT cwp;
2282
2283 cwp.lParam = lParam;
2284 cwp.wParam = wParam;
2285 cwp.message = Msg;
2286 cwp.hwnd = getWindowHandle();
2287
2288 switch(hooktype) {
2289 case WH_CALLWNDPROC:
2290 if(fUnicode) {
2291 HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
2292 }
2293 else HOOK_CallHooksA(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
2294 break;
2295 }
2296}
2297//******************************************************************************
2298//TODO: Do this more efficiently
2299//******************************************************************************
2300LRESULT Win32BaseWindow::BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam)
2301{
2302 Win32BaseWindow *window;
2303 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
2304
2305 dprintf(("BroadCastMessageA %x %x %x %s", msg, wParam, lParam, (type == BROADCAST_SEND) ? "Send" : "Post"));
2306
2307 for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
2308 window = GetWindowFromHandle(hwnd++);
2309 if(window) {
2310 if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
2311 {
2312 if(type == BROADCAST_SEND) {
2313 ::SendMessageA(window->getWindowHandle(), msg, wParam, lParam);
2314 }
2315 else PostMessageA(window->getWindowHandle(), msg, wParam, lParam);
2316 }
2317 RELEASE_WNDOBJ(window);
2318 }
2319 }
2320 return 0;
2321}
2322//******************************************************************************
2323//TODO: Do this more efficiently
2324//******************************************************************************
2325LRESULT Win32BaseWindow::BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam)
2326{
2327 Win32BaseWindow *window;
2328 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
2329
2330 dprintf(("BroadCastMessageW %x %x %x %s", msg, wParam, lParam, (type == BROADCAST_SEND) ? "Send" : "Post"));
2331
2332 for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
2333 window = GetWindowFromHandle(hwnd++);
2334 if(window) {
2335 if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
2336 {
2337 if(type == BROADCAST_SEND) {
2338 ::SendMessageW(window->getWindowHandle(), msg, wParam, lParam);
2339 }
2340 else PostMessageW(window->getWindowHandle(), msg, wParam, lParam);
2341 }
2342 RELEASE_WNDOBJ(window);
2343 }
2344 }
2345 return 0;
2346}
2347//******************************************************************************
2348//******************************************************************************
2349void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
2350{
2351 Win32BaseWindow *window = this;
2352 Win32BaseWindow *parentwindow;
2353
2354 while(window)
2355 {
2356 if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
2357 {
2358 /* Notify the parent window only */
2359 parentwindow = window->getParent();
2360 if(parentwindow) {
2361 parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam );
2362 }
2363 }
2364 else break;
2365
2366 window = parentwindow;
2367 }
2368}
2369//******************************************************************************
2370// Returns the big or small icon for the window, falling back to the
2371// class as windows does.
2372//******************************************************************************
2373HICON Win32BaseWindow::IconForWindow(WPARAM fType)
2374{
2375 HICON hWndIcon;
2376
2377 if (fType == ICON_BIG)
2378 {
2379 if (hIcon)
2380 hWndIcon = hIcon;
2381 else
2382 if (windowClass && windowClass->getIcon())
2383 hWndIcon = windowClass->getIcon();
2384 else
2385 if (!(dwStyle & DS_MODALFRAME))
2386 hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR);
2387 else hWndIcon = 0;
2388 }
2389 else
2390 {
2391 if (hIconSm)
2392 hWndIcon = hIconSm;
2393 else
2394 if (hIcon)
2395 hWndIcon = hIcon;
2396 else
2397 if (windowClass && windowClass->getIconSm())
2398 hWndIcon = windowClass->getIconSm();
2399 else
2400 if (windowClass && windowClass->getIcon())
2401 hWndIcon = windowClass->getIcon();
2402 else
2403 if (!(dwStyle & DS_MODALFRAME))
2404 hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR);
2405 else hWndIcon = 0;
2406 }
2407
2408 return hWndIcon;
2409}
2410//******************************************************************************
2411//******************************************************************************
2412BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow)
2413{
2414 ULONG swp = 0;
2415 HWND hWinAfter;
2416 BOOL rc,wasVisible,showFlag;
2417 RECT newPos = {0, 0, 0, 0};
2418
2419 dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
2420 wasVisible = (getStyle() & WS_VISIBLE) != 0;
2421
2422 dwOldStyle = getStyle();
2423
2424 switch(nCmdShow)
2425 {
2426 case SW_HIDE:
2427 if (!wasVisible) goto END;
2428
2429 swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER;
2430 break;
2431
2432 case SW_SHOWMINNOACTIVE:
2433 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
2434 /* fall through */
2435 case SW_SHOWMINIMIZED:
2436 swp |= SWP_SHOWWINDOW;
2437 /* fall through */
2438 case SW_MINIMIZE:
2439 swp |= SWP_FRAMECHANGED;
2440 if( !(getStyle() & WS_MINIMIZE) ) {
2441 swp |= MinMaximize(SW_MINIMIZE, &newPos );
2442 fMinMaxChange = TRUE; //-> invalidate entire window in WM_CALCINVALIDRECT
2443 }
2444 else swp |= SWP_NOSIZE | SWP_NOMOVE;
2445 break;
2446
2447 case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
2448 swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
2449 if( !(getStyle() & WS_MAXIMIZE) ) {
2450 swp |= MinMaximize(SW_MAXIMIZE, &newPos );
2451 fMinMaxChange = TRUE; //-> invalidate entire window in WM_CALCINVALIDRECT
2452 }
2453 else swp |= SWP_NOSIZE | SWP_NOMOVE;
2454 break;
2455
2456 case SW_SHOWNA:
2457 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
2458 /* fall through */
2459 case SW_SHOW:
2460 swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
2461
2462 /*
2463 * ShowWindow has a little peculiar behavior that if the
2464 * window is already the topmost window, it will not
2465 * activate it.
2466 */
2467 if (::GetTopWindow((HWND)0)==getWindowHandle() && (wasVisible || GetActiveWindow() == getWindowHandle()))
2468 swp |= SWP_NOACTIVATE;
2469
2470 break;
2471
2472 case SW_SHOWNOACTIVATE:
2473 swp |= SWP_NOZORDER;
2474 if (GetActiveWindow())
2475 swp |= SWP_NOACTIVATE;
2476 /* fall through */
2477 case SW_SHOWNORMAL: /* same as SW_NORMAL: */
2478 case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
2479 case SW_RESTORE:
2480 swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
2481
2482 if( getStyle() & (WS_MINIMIZE | WS_MAXIMIZE) ) {
2483 swp |= MinMaximize(SW_RESTORE, &newPos );
2484 fMinMaxChange = TRUE; //-> invalidate entire window in WM_CALCINVALIDRECT
2485 }
2486 else swp |= SWP_NOSIZE | SWP_NOMOVE;
2487 break;
2488 }
2489
2490 showFlag = (nCmdShow != SW_HIDE);
2491 if (showFlag != wasVisible)
2492 {
2493 SendInternalMessageA(WM_SHOWWINDOW, showFlag, 0 );
2494 if (!::IsWindow( getWindowHandle() )) goto END;
2495 }
2496
2497 /* We can't activate a child window */
2498 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_MDICHILD))
2499 swp |= SWP_NOACTIVATE | SWP_NOZORDER;
2500
2501 SetWindowPos(HWND_TOP, newPos.left, newPos.top, newPos.right, newPos.bottom, LOWORD(swp));
2502
2503 if(!(swp & SWP_NOACTIVATE)) {
2504 OSLibWinSetActiveWindow(OS2HwndFrame);
2505 }
2506
2507 if (flags & WIN_NEED_SIZE)
2508 {
2509 /* should happen only in CreateWindowEx() */
2510 int wParam = SIZE_RESTORED;
2511
2512 flags &= ~WIN_NEED_SIZE;
2513 if (dwStyle & WS_MAXIMIZE)
2514 wParam = SIZE_MAXIMIZED;
2515 else
2516 if (dwStyle & WS_MINIMIZE)
2517 wParam = SIZE_MINIMIZED;
2518
2519 SendInternalMessageA(WM_SIZE, wParam,
2520 MAKELONG(rectClient.right-rectClient.left,
2521 rectClient.bottom-rectClient.top));
2522 SendInternalMessageA(WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top));
2523 }
2524//testestest
2525 //temporary workaround for file dialogs with template dialog child
2526 //they don't redraw when switching directories
2527 //For some reason the new child's (syslistview32) update rectangle stays
2528 //empty after its parent is made visible with ShowWindow
2529 //TODO: find real cause
2530 if(!wasVisible) {
2531 InvalidateRect(getWindowHandle(), NULL, TRUE);
2532 }
2533//testestest
2534END:
2535 fMinMaxChange = FALSE;
2536 return wasVisible;
2537}
2538//******************************************************************************
2539//******************************************************************************
2540BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
2541{
2542 BOOL rc = FALSE;
2543 Win32BaseWindow *window;
2544 HWND hParent = 0;
2545 RECT oldClientRect = rectClient;
2546
2547 if (fuFlags &
2548 ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
2549 SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED |
2550 SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS |
2551 SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_DEFERERASE |
2552 SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE))
2553 {
2554 dprintf(("ERROR: SetWindowPos; UNKNOWN flag"));
2555 return FALSE;
2556 }
2557
2558 if( fuFlags & (SWP_DEFERERASE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)) {
2559 dprintf(("WARNING: SetWindowPos; unsupported flag"));
2560 }
2561
2562 if(IsWindowDestroyed()) {
2563 //changing the position of a window that's being destroyed can cause crashes in PMMERGE
2564 dprintf(("SetWindowPos; window already destroyed"));
2565 return TRUE;
2566 }
2567
2568#if 0
2569 /* Fix redundant flags */
2570 if(getStyle() & WS_VISIBLE) {
2571 fuFlags &= ~SWP_SHOWWINDOW;
2572 }
2573 else
2574 {
2575 if (!(fuFlags & SWP_SHOWWINDOW))
2576 fuFlags |= SWP_NOREDRAW;
2577 fuFlags &= ~SWP_HIDEWINDOW;
2578 }
2579
2580//// if(cx < 0) cx = 0;
2581//// if(cy < 0) cy = 0;
2582
2583 if((rectWindow.right - rectWindow.left == cx) && (rectWindow.bottom - rectWindow.top == cy)) {
2584 fuFlags |= SWP_NOSIZE; /* Already the right size */
2585 }
2586
2587 if((rectWindow.left == x) && (rectWindow.top == y)) {
2588 fuFlags |= SWP_NOMOVE; /* Already the right position */
2589 }
2590
2591 if(getWindowHandle() == GetActiveWindow()) {
2592 fuFlags |= SWP_NOACTIVATE; /* Already active */
2593 }
2594 else
2595 if((getStyle() & (WS_POPUP | WS_CHILD)) != WS_CHILD )
2596 {
2597 if(!(fuFlags & SWP_NOACTIVATE)) /* Bring to the top when activating */
2598 {
2599 fuFlags &= ~SWP_NOZORDER;
2600 hwndInsertAfter = HWND_TOP;
2601 }
2602 }
2603 /* TODO: Check hwndInsertAfter */
2604
2605#endif
2606
2607 //Note: Solitaire crashes when receiving WM_SIZE messages before WM_CREATE
2608 if(state < STATE_POST_WMNCCREATE)
2609 {//don't change size; modify internal structures only
2610 //TODO: not 100% correct yet (activate)
2611 dprintf2(("state < STATE_POST_WMNCCREATE"));
2612 if(!(fuFlags & SWP_NOZORDER)) {
2613 hwndLinkAfter = hwndInsertAfter;
2614 }
2615 if(!(fuFlags & SWP_NOMOVE)) {
2616 rectWindow.bottom = (rectWindow.bottom - rectWindow.top) + y;
2617 rectWindow.top = y;
2618 rectWindow.right = (rectWindow.right - rectWindow.left) + x;
2619 rectWindow.left = x;
2620 }
2621 if(!(fuFlags & SWP_NOSIZE)) {
2622 rectWindow.bottom = rectWindow.top + cy;
2623 rectWindow.right = rectWindow.left + cx;
2624 }
2625 return TRUE;
2626 }
2627
2628 WINDOWPOS wpos;
2629 SWP swp, swpOld;
2630 wpos.flags = fuFlags;
2631 wpos.cy = cy;
2632 wpos.cx = cx;
2633 wpos.x = x;
2634 wpos.y = y;
2635 wpos.hwndInsertAfter = hwndInsertAfter;
2636 wpos.hwnd = getWindowHandle();
2637
2638 if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
2639 {
2640 if (isChild())
2641 {
2642 if(!getParent()) {
2643 dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
2644 }
2645 }
2646 OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
2647 }
2648
2649 if(getParent()) {
2650 OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, getParent()->getClientHeight(),
2651 OS2HwndFrame);
2652 }
2653 else OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, OSLibQueryScreenHeight(), OS2HwndFrame);
2654
2655 if (swp.fl == 0) {
2656 dprintf2(("swp.fl == 0"));
2657 if(fuFlags & SWP_FRAMECHANGED)
2658 {
2659 NotifyFrameChanged(&wpos, &oldClientRect);
2660 }
2661 return TRUE;
2662 }
2663
2664// if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
2665 if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
2666 {
2667 Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
2668 if(wndBehind) {
2669 swp.hwndInsertBehind = wndBehind->getOS2FrameWindowHandle();
2670 RELEASE_WNDOBJ(wndBehind);
2671 }
2672 else {
2673 dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
2674 swp.hwndInsertBehind = 0;
2675 }
2676 }
2677 swp.hwnd = OS2HwndFrame;
2678
2679 if(fuFlags & SWP_SHOWWINDOW && !IsWindowVisible(getWindowHandle())) {
2680 setStyle(getStyle() | WS_VISIBLE);
2681 if(hTaskList) {
2682 dprintf(("Adding window %x to tasklist", getWindowHandle()));
2683 OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), 1);
2684 }
2685 }
2686 else
2687 if((fuFlags & SWP_HIDEWINDOW) && IsWindowVisible(getWindowHandle())) {
2688 setStyle(getStyle() & ~WS_VISIBLE);
2689 if(hTaskList && !(getStyle() & WS_MINIMIZE)) {
2690 dprintf(("Removing window %x from tasklist", getWindowHandle()));
2691 OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), 0);
2692 }
2693 }
2694 dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
2695 rc = OSLibWinSetMultWindowPos(&swp, 1);
2696
2697 if(rc == FALSE)
2698 {
2699 dprintf(("OSLibWinSetMultWindowPos failed! Error %x",OSLibWinGetLastError()));
2700 return 0;
2701 }
2702
2703 if((fuFlags & SWP_FRAMECHANGED) && (fuFlags & (SWP_NOMOVE | SWP_NOSIZE) == (SWP_NOMOVE | SWP_NOSIZE)))
2704 {
2705 NotifyFrameChanged(&wpos, &oldClientRect);
2706 }
2707 if(!(getStyle() & (WS_MAXIMIZE|WS_MINIMIZE))) {
2708 //Restore position always changes when the window position is changed
2709 dprintf(("Save new restore position (%d,%d)(%d,%d)", rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom));
2710 windowpos.rcNormalPosition = rectWindow;
2711 }
2712 return (rc);
2713}
2714//******************************************************************************
2715//Called by ScrollWindowEx (dc.cpp) to notify child window that it has moved
2716//******************************************************************************
2717BOOL Win32BaseWindow::ScrollWindow(int dx, int dy)
2718{
2719 rectWindow.left += dx;
2720 rectWindow.right += dx;
2721 rectWindow.top += dy;
2722 rectWindow.bottom += dy;
2723 SendInternalMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
2724 return TRUE;
2725}
2726//******************************************************************************
2727//******************************************************************************
2728void Win32BaseWindow::NotifyFrameChanged(WINDOWPOS *wpos, RECT *oldClientRect)
2729{
2730 HRGN hrgn, hrgnClient;
2731 RECT rect;
2732
2733 MsgFormatFrame(NULL);
2734
2735 if(RECT_WIDTH(rectClient) != RECT_WIDTH(*oldClientRect) ||
2736 RECT_HEIGHT(rectClient) != RECT_HEIGHT(*oldClientRect))
2737 {
2738 wpos->flags &= ~(SWP_NOSIZE|SWP_NOCLIENTSIZE);
2739 wpos->cx = RECT_WIDTH(rectWindow);
2740 wpos->cy = RECT_HEIGHT(rectWindow);
2741 }
2742
2743 if(rectClient.left != oldClientRect->left ||
2744 rectClient.top != oldClientRect->top)
2745 {
2746 wpos->flags &= ~(SWP_NOMOVE|SWP_NOCLIENTMOVE);
2747 wpos->x = rectWindow.left;
2748 wpos->y = rectWindow.top;
2749 }
2750
2751 WINDOWPOS wpOld = *wpos;
2752 if(!(wpos->flags & SWP_NOSENDCHANGING))
2753 SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, (LPARAM)wpos);
2754
2755 if ((wpos->hwndInsertAfter != wpOld.hwndInsertAfter) ||
2756 (wpos->x != wpOld.x) || (wpos->y != wpOld.y) || (wpos->cx != wpOld.cx) || (wpos->cy != wpOld.cy) || (wpos->flags != wpOld.flags))
2757 {
2758 dprintf(("WARNING, NotifyFrameChanged: TODO -> adjust flags!!!!"));
2759 SetWindowPos(wpos->hwndInsertAfter, wpos->x, wpos->y, wpos->cx, wpos->cy, wpos->flags | SWP_NOSENDCHANGING);
2760 }
2761 else SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, (LPARAM)wpos);
2762
2763 //Calculate invalid areas
2764 rect = rectWindow;
2765 OffsetRect(&rect, -rectWindow.left, -rectWindow.top);
2766 hrgn = CreateRectRgnIndirect(&rect);
2767 if (!hrgn) {
2768 dprintf(("ERROR: NotifyFrameChanged, CreateRectRgnIndirect failed!!"));
2769 return;
2770 }
2771 rect = rectClient;
2772 hrgnClient = CreateRectRgnIndirect(&rect);
2773 if (!hrgn) {
2774 dprintf(("ERROR: NotifyFrameChanged, CreateRectRgnIndirect failed!!"));
2775 return;
2776 }
2777 CombineRgn(hrgn, hrgn, hrgnClient, RGN_DIFF);
2778 DeleteObject(hrgnClient);
2779
2780 if(!EqualRect(oldClientRect, &rectClient)) {
2781 UnionRect(oldClientRect, oldClientRect, &rectClient);
2782 hrgnClient = CreateRectRgnIndirect(oldClientRect);
2783 if (!hrgn) {
2784 dprintf(("ERROR: NotifyFrameChanged, CreateRectRgnIndirect failed!!"));
2785 return;
2786 }
2787 CombineRgn(hrgn, hrgn, hrgnClient, RGN_OR);
2788 DeleteObject(hrgnClient);
2789 }
2790 RedrawWindow(getWindowHandle(), NULL, hrgn, RDW_ALLCHILDREN |
2791 RDW_INVALIDATE | RDW_ERASE | RDW_FRAME);
2792 DeleteObject(hrgn);
2793}
2794//******************************************************************************
2795//TODO: Check how this api really works in NT
2796//******************************************************************************
2797BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *wndpl)
2798{
2799 dprintf(("SetWindowPlacement %x min (%d,%d)", getWindowHandle(), wndpl->ptMinPosition.x, wndpl->ptMinPosition.y));
2800 dprintf(("SetWindowPlacement %x max (%d,%d)", getWindowHandle(), wndpl->ptMaxPosition.x, wndpl->ptMaxPosition.y));
2801 dprintf(("SetWindowPlacement %x norm (%d,%d)(%d,%d)", getWindowHandle(), wndpl->rcNormalPosition.left, wndpl->rcNormalPosition.top, wndpl->rcNormalPosition.right, wndpl->rcNormalPosition.bottom));
2802 windowpos.ptMinPosition = wndpl->ptMinPosition;
2803 windowpos.ptMaxPosition = wndpl->ptMaxPosition;
2804 windowpos.rcNormalPosition = wndpl->rcNormalPosition;
2805
2806 if(getStyle() & WS_MINIMIZE )
2807 {
2808 //TODO: Why can't this be (0,0)?
2809 if(wndpl->flags & WPF_SETMINPOSITION && !(!windowpos.ptMinPosition.x && !windowpos.ptMinPosition.y)) {
2810 SetWindowPos(0, windowpos.ptMinPosition.x, windowpos.ptMinPosition.y,
2811 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
2812 }
2813 }
2814 else
2815 if(getStyle() & WS_MAXIMIZE )
2816 {
2817 //TODO: Why can't this be (0,0)?
2818 if(windowpos.ptMaxPosition.x != 0 || windowpos.ptMaxPosition.y != 0 )
2819 SetWindowPos(0, windowpos.ptMaxPosition.x, windowpos.ptMaxPosition.y,
2820 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
2821 }
2822 else {
2823 SetWindowPos(0, windowpos.rcNormalPosition.left, windowpos.rcNormalPosition.top,
2824 windowpos.rcNormalPosition.right - windowpos.rcNormalPosition.left,
2825 windowpos.rcNormalPosition.bottom - windowpos.rcNormalPosition.top,
2826 SWP_NOZORDER | SWP_NOACTIVATE );
2827 }
2828 ShowWindow(wndpl->showCmd);
2829 if( ::IsWindow(getWindowHandle()) && getStyle() & WS_MINIMIZE )
2830 {
2831 /* SDK: ...valid only the next time... */
2832 if(wndpl->flags & WPF_RESTORETOMAXIMIZED)
2833 setFlags(getFlags() | WIN_RESTORE_MAX);
2834 }
2835 return TRUE;
2836}
2837//******************************************************************************
2838//******************************************************************************
2839BOOL Win32BaseWindow::GetWindowPlacement(LPWINDOWPLACEMENT wndpl)
2840{
2841 wndpl->length = sizeof(*wndpl);
2842 if(getStyle() & WS_MINIMIZE )
2843 wndpl->showCmd = SW_SHOWMINIMIZED;
2844 else wndpl->showCmd = (getStyle() & WS_MAXIMIZE) ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL;
2845
2846 //TODO: Verify if this is correct -> SDK docs claim this flag must always be set to 0
2847 if(getFlags() & WIN_RESTORE_MAX )
2848 wndpl->flags = WPF_RESTORETOMAXIMIZED;
2849 else wndpl->flags = 0;
2850
2851 wndpl->ptMinPosition = windowpos.ptMinPosition;
2852 wndpl->ptMaxPosition = windowpos.ptMaxPosition;
2853 //Must be in parent coordinates (or screen if no parent); verified in NT4, SP6
2854 wndpl->rcNormalPosition = rectWindow;
2855
2856 return TRUE;
2857}
2858//******************************************************************************
2859//Also destroys all the child windows (destroy children first, parent last)
2860//******************************************************************************
2861BOOL Win32BaseWindow::DestroyWindow()
2862{
2863 HWND hwnd = getWindowHandle();
2864
2865 dprintf(("DestroyWindow %x", hwnd));
2866
2867 /* Call hooks */
2868 if(HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, getWindowHandle(), 0L))
2869 {
2870 return FALSE;
2871 }
2872
2873 if(!(getStyle() & WS_CHILD) && getOwner() == NULL)
2874 {
2875 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWDESTROYED, getWindowHandle(), 0L);
2876 /* FIXME: clean up palette - see "Internals" p.352 */
2877 }
2878
2879 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
2880 {
2881 if(getParent() && getParent()->IsWindowDestroyed() == FALSE)
2882 {
2883 /* Notify the parent window only */
2884 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
2885 if(!::IsWindow(hwnd) )
2886 {
2887 return TRUE;
2888 }
2889 }
2890//// else DebugInt3();
2891 }
2892 /* Hide the window */
2893 if(IsWindowVisible(getWindowHandle()))
2894 {
2895 SetWindowPos(0, 0, 0, 0, 0, SWP_HIDEWINDOW |
2896 SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE);
2897 if(!::IsWindow(hwnd))
2898 {
2899 return TRUE;
2900 }
2901 }
2902 dprintf(("DestroyWindow %x -> HIDDEN", hwnd));
2903
2904 // check the handle for the last active popup window
2905 Win32BaseWindow* owner = getOwner();
2906 if (NULL != owner)
2907 {
2908 if (owner->getLastActive() == hwnd)
2909 owner->setLastActive( owner->getWindowHandle() );
2910 }
2911
2912 fDestroyWindowCalled = TRUE;
2913 return OSLibWinDestroyWindow(OS2HwndFrame);
2914}
2915//******************************************************************************
2916//******************************************************************************
2917Win32BaseWindow *Win32BaseWindow::getParent()
2918{
2919 Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
2920 return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
2921}
2922//******************************************************************************
2923//Note: does not set last error if no parent (verified in NT4, SP6)
2924//******************************************************************************
2925HWND Win32BaseWindow::GetParent()
2926{
2927 Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
2928
2929 if(getStyle() & WS_CHILD) {
2930 if(wndparent) {
2931 return wndparent->getWindowHandle();
2932 }
2933 dprintf(("WARNING: GetParent: WS_CHILD but no parent!!"));
2934 DebugInt3();
2935 return 0;
2936 }
2937 else
2938 if(getStyle() & WS_POPUP)
2939 return (getOwner()) ? getOwner()->getWindowHandle() : 0;
2940 else return 0;
2941}
2942//******************************************************************************
2943//******************************************************************************
2944HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
2945{
2946 HWND oldhwnd;
2947 Win32BaseWindow *newparent;
2948 Win32BaseWindow *oldparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
2949 BOOL fShow = FALSE;
2950
2951 if(oldparent) {
2952 oldhwnd = oldparent->getWindowHandle();
2953 oldparent->removeChild(this);
2954 }
2955 else oldhwnd = 0;
2956
2957 /* Windows hides the window first, then shows it again
2958 * including the WM_SHOWWINDOW messages and all */
2959 if(IsWindowCreated() && (getStyle() & WS_VISIBLE)) {
2960 ShowWindow(SW_HIDE);
2961 fShow = TRUE;
2962 }
2963 if(oldparent) {
2964 //release parent here (increased refcount during creation)
2965 RELEASE_WNDOBJ(oldparent);
2966 }
2967 newparent = GetWindowFromHandle(hwndNewParent);
2968 if(newparent && !newparent->isDesktopWindow())
2969 {
2970 setParent(newparent);
2971 getParent()->addChild(this);
2972 fParentChange = TRUE;
2973
2974 OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
2975 if(!(getStyle() & WS_CHILD))
2976 {
2977 //TODO: Send WM_STYLECHANGED msg?
2978 setStyle(getStyle() | WS_CHILD);
2979 if(getWindowId())
2980 {
2981 DestroyMenu( (HMENU) getWindowId() );
2982 setWindowId(0);
2983 }
2984 }
2985 //SvL: Even though the win32 coordinates might not change, the PM
2986 // coordinates can. We must make sure the control stays at the
2987 // same position (y) relative to the (new) parent.
2988 SetWindowPos(HWND_TOPMOST, rectWindow.left, rectWindow.top, 0, 0,
2989 SWP_NOACTIVATE|SWP_NOSIZE);
2990 fParentChange = FALSE;
2991 }
2992 else {
2993 if(newparent) RELEASE_WNDOBJ(newparent);
2994
2995 setParent(windowDesktop);
2996 windowDesktop->addRef();
2997 windowDesktop->addChild(this);
2998 OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
2999
3000 //TODO: Send WM_STYLECHANGED msg?
3001 setStyle(getStyle() & ~WS_CHILD);
3002 setWindowId(0);
3003 }
3004 /* SetParent additionally needs to make hwndChild the topmost window
3005 in the x-order and send the expected WM_WINDOWPOSCHANGING and
3006 WM_WINDOWPOSCHANGED notification messages.
3007 */
3008 if(state >= STATE_PRE_WMNCCREATE) {
3009 SetWindowPos(HWND_TOPMOST, 0, 0, 0, 0,
3010 SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|(fShow? SWP_SHOWWINDOW : 0));
3011
3012 /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
3013 * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */
3014 }
3015 return oldhwnd;
3016}
3017//******************************************************************************
3018//******************************************************************************
3019BOOL Win32BaseWindow::IsChild(HWND hwndParent)
3020{
3021 // PH: Optimizer won't unroll calls to getParent() even
3022 // in release build.
3023 Win32BaseWindow *_parent = getParent();
3024
3025 if(_parent)
3026 {
3027 if(_parent->getWindowHandle() == hwndParent)
3028 return TRUE;
3029
3030 return _parent->IsChild(hwndParent);
3031 }
3032 else
3033 return 0;
3034}
3035//******************************************************************************
3036//******************************************************************************
3037HWND Win32BaseWindow::GetTopWindow()
3038{
3039 HWND hwndTop;
3040 Win32BaseWindow *topwindow;
3041
3042 hwndTop = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
3043 if(!isDesktopWindow())
3044 {
3045 topwindow = GetWindowFromOS2FrameHandle(hwndTop);
3046 //Note: GetTopWindow can't return a window that hasn't processed
3047 // WM_NCCREATE yet (verified in NT4, SP6)
3048 if(topwindow) {
3049 if(topwindow->state >= STATE_POST_WMNCCREATE) {
3050 hwndTop = topwindow->getWindowHandle();
3051 }
3052 else hwndTop = topwindow->GetWindow(GW_HWNDNEXT);
3053 RELEASE_WNDOBJ(topwindow);
3054 return hwndTop;
3055 }
3056 if(topwindow) RELEASE_WNDOBJ(topwindow);
3057 return 0;
3058 }
3059 while(hwndTop) {
3060 topwindow = GetWindowFromOS2FrameHandle(hwndTop);
3061 //Note: GetTopWindow can't return a window that hasn't processed
3062 // WM_NCCREATE yet (verified in NT4, SP6)
3063 if(topwindow) {
3064 if(topwindow->state >= STATE_POST_WMNCCREATE) {
3065 hwndTop = topwindow->getWindowHandle();
3066 }
3067 else hwndTop = topwindow->GetWindow(GW_HWNDNEXT);
3068 RELEASE_WNDOBJ(topwindow);
3069 return hwndTop;
3070 }
3071 if(topwindow) RELEASE_WNDOBJ(topwindow);
3072 hwndTop = OSLibWinQueryWindow(hwndTop, QWOS_NEXT);
3073 }
3074
3075 return 0;
3076}
3077//******************************************************************************
3078// Get the top-level parent for a child window.
3079//******************************************************************************
3080HWND Win32BaseWindow::GetTopParent()
3081{
3082 Win32BaseWindow *window = this;
3083 HWND hwndTopParent = 0;
3084
3085 lock();
3086 while(window && (window->getStyle() & WS_CHILD))
3087 {
3088 window = window->getParent();
3089 }
3090 if(window) {
3091 hwndTopParent = window->getWindowHandle();
3092 }
3093 unlock();
3094 return hwndTopParent;
3095}
3096//******************************************************************************
3097//TODO: Should not enumerate children that are created during the enumeration!
3098//******************************************************************************
3099BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
3100{
3101 BOOL rc = TRUE;
3102 HWND hwnd;
3103 Win32BaseWindow *prevchild = 0, *child = 0;
3104
3105 dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
3106 lock();
3107 for (child = (Win32BaseWindow *)getFirstChild(); child != NULL; child = (Win32BaseWindow *)child->getNextChild())
3108 {
3109 dprintf(("EnumChildWindows: enumerating child %x (owner %x; parent %x)", child->getWindowHandle(), (child->getOwner()) ? child->getOwner()->getWindowHandle() : 0, getWindowHandle()));
3110 hwnd = child->getWindowHandle();
3111 if(child->IsWindowDestroyed() || child->getOwner()) {
3112 continue; //shouldn't have an owner (Wine)
3113 }
3114 child->addRef();
3115 unlock();
3116 if(lpfn(hwnd, lParam) == FALSE)
3117 {
3118 child->release();
3119 return FALSE;
3120 }
3121 child->release();
3122 lock();
3123 //check if the window still exists
3124 if(!::IsWindow(hwnd))
3125 {
3126 child = prevchild;
3127 if(child == NULL) break;
3128 continue;
3129 }
3130 if(child->getFirstChild() != NULL)
3131 {
3132 dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle()));
3133 child->addRef();
3134 unlock();
3135 if(child->EnumChildWindows(lpfn, lParam) == FALSE)
3136 {
3137 child->release();
3138 return FALSE;
3139 }
3140 child->release();
3141 lock();
3142 }
3143 prevchild = child;
3144 }
3145 unlock();
3146 return rc;
3147}
3148//******************************************************************************
3149//Enumerate first-level children only and check thread id
3150//******************************************************************************
3151BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
3152{
3153 Win32BaseWindow *child = 0;
3154 ULONG tid, pid;
3155 BOOL rc;
3156 HWND hwnd;
3157
3158 dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam));
3159
3160 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
3161 {
3162 OSLibWinQueryWindowProcess(child->getOS2WindowHandle(), &pid, &tid);
3163
3164 if(dwThreadId == tid) {
3165 dprintf2(("EnumThreadWindows: Found Window %x", child->getWindowHandle()));
3166 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
3167 break;
3168 }
3169 }
3170 }
3171 return TRUE;
3172}
3173//******************************************************************************
3174//Enumerate first-level children only
3175//******************************************************************************
3176BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
3177{
3178 Win32BaseWindow *child = 0;
3179 BOOL rc;
3180 HWND hwnd;
3181
3182 dprintf(("EnumWindows %x %x", lpfn, lParam));
3183
3184 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
3185 {
3186 hwnd = child->getWindowHandle();
3187
3188 dprintf2(("EnumWindows: Found Window %x", child->getWindowHandle()));
3189 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
3190 break;
3191 }
3192 }
3193 return TRUE;
3194}
3195//******************************************************************************
3196//******************************************************************************
3197HWND Win32BaseWindow::FindWindowById(int id)
3198{
3199 HWND hwnd;
3200
3201 lock();
3202 for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
3203 {
3204 if (child->getWindowId() == id)
3205 {
3206 hwnd = child->getWindowHandle();
3207 unlock();
3208 return hwnd;
3209 }
3210 }
3211 unlock();
3212 return 0;
3213}
3214//******************************************************************************
3215//TODO:
3216//We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
3217//the current process owns them.
3218//******************************************************************************
3219HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, ATOM atom, LPSTR lpszWindow)
3220{
3221 Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
3222 Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
3223 Win32BaseWindow *firstchild = child;
3224
3225 dprintf(("FindWindowEx %x %x %x %s", hwndParent, hwndChildAfter, atom, lpszWindow));
3226 if((hwndParent != 0 && !parent) ||
3227 (hwndChildAfter != 0 && !child) ||
3228 (hwndParent == 0 && hwndChildAfter != 0))
3229 {
3230 if(parent) RELEASE_WNDOBJ(parent);
3231 if(firstchild) RELEASE_WNDOBJ(firstchild);
3232 dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
3233 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
3234 return 0;
3235 }
3236 SetLastError(0);
3237 if(hwndParent != 0)
3238 {//if the current process owns the window, just do a quick search
3239 lock(&critsect);
3240 child = (Win32BaseWindow *)parent->getFirstChild();
3241 if(hwndChildAfter != 0)
3242 {
3243 while(child)
3244 {
3245 if(child->getWindowHandle() == hwndChildAfter)
3246 {
3247 child = (Win32BaseWindow *)child->getNextChild();
3248 break;
3249 }
3250 child = (Win32BaseWindow *)child->getNextChild();
3251 }
3252 }
3253 while(child)
3254 {
3255 //According to Wine, the class doesn't need to be specified
3256 if((!atom || child->getWindowClass()->getAtom() == atom) &&
3257 (!lpszWindow || child->hasWindowName(lpszWindow)))
3258 {
3259 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
3260 HWND hwndChild = child->getWindowHandle();
3261 unlock(&critsect);
3262 if(parent) RELEASE_WNDOBJ(parent);
3263 if(firstchild) RELEASE_WNDOBJ(firstchild);
3264 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
3265 return hwndChild;
3266 }
3267 child = (Win32BaseWindow *)child->getNextChild();
3268 }
3269 unlock(&critsect);
3270 if(parent) RELEASE_WNDOBJ(parent);
3271 if(firstchild) RELEASE_WNDOBJ(firstchild);
3272 }
3273 else {
3274 Win32BaseWindow *wnd;
3275 HWND henum, hwnd;
3276
3277 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
3278 hwnd = OSLibWinGetNextWindow(henum);
3279
3280 while(hwnd)
3281 {
3282 wnd = GetWindowFromOS2FrameHandle(hwnd);
3283 if(wnd == NULL) {
3284 hwnd = OSLibWinQueryClientWindow(hwnd);
3285 if(hwnd) wnd = GetWindowFromOS2Handle(hwnd);
3286 }
3287
3288 if(wnd) {
3289 //According to Wine, the class doesn't need to be specified
3290 if((!atom || wnd->getWindowClass()->getAtom() == atom) &&
3291 (!lpszWindow || wnd->hasWindowName(lpszWindow)))
3292 {
3293 OSLibWinEndEnumWindows(henum);
3294 dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
3295 HWND hwndret = wnd->getWindowHandle();
3296 RELEASE_WNDOBJ(wnd);
3297 return hwndret;
3298 }
3299 RELEASE_WNDOBJ(wnd);
3300 }
3301 hwnd = OSLibWinGetNextWindow(henum);
3302 }
3303 OSLibWinEndEnumWindows(henum);
3304 if(parent) RELEASE_WNDOBJ(parent);
3305 if(firstchild) RELEASE_WNDOBJ(firstchild);
3306 }
3307 SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
3308 return 0;
3309}
3310//******************************************************************************
3311//******************************************************************************
3312HWND Win32BaseWindow::GetWindow(UINT uCmd)
3313{
3314 HWND hwndRelated = 0;
3315 Win32BaseWindow *window;
3316
3317 switch(uCmd)
3318 {
3319 case GW_HWNDFIRST:
3320 window = (Win32BaseWindow *)getParent();
3321 if(window)
3322 {
3323 hwndRelated = OSLibWinQueryWindow(window->getOS2WindowHandle(), QWOS_TOP);
3324 window = GetWindowFromOS2FrameHandle(hwndRelated);
3325 if(window) {
3326 hwndRelated = window->getWindowHandle();
3327 RELEASE_WNDOBJ(window);
3328 }
3329 else hwndRelated = 0;
3330 }
3331 else {
3332 dprintf(("WARNING: GW_HWNDFIRST not correctly implemented for toplevel/most windows!"));
3333 hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
3334 }
3335 break;
3336
3337 case GW_HWNDLAST:
3338 window = (Win32BaseWindow *)getParent();
3339 if(window) {
3340 hwndRelated = OSLibWinQueryWindow(window->getOS2WindowHandle(), QWOS_BOTTOM);
3341 dprintf(("os2 handle %x", hwndRelated));
3342 window = GetWindowFromOS2FrameHandle(hwndRelated);
3343 if(window) {
3344 hwndRelated = window->getWindowHandle();
3345 RELEASE_WNDOBJ(window);
3346 }
3347 else hwndRelated = 0;
3348 }
3349 else {
3350 dprintf(("WARNING: GW_HWNDLAST not correctly implemented for toplevel/most windows!"));
3351 hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
3352 }
3353 break;
3354
3355 case GW_HWNDNEXT:
3356 if(getParent()) {
3357 hwndRelated = OSLibWinQueryWindow(getOS2FrameWindowHandle(), QWOS_NEXT);
3358 window = GetWindowFromOS2FrameHandle(hwndRelated);
3359 if(window) {
3360 hwndRelated = window->getWindowHandle();
3361 RELEASE_WNDOBJ(window);
3362 }
3363 else hwndRelated = 0;
3364 }
3365 else {
3366 dprintf(("WARNING: GW_HWNDNEXT not correctly implemented for toplevel/most windows!"));
3367 hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
3368 }
3369 break;
3370
3371 case GW_HWNDPREV:
3372 if(getParent()) {
3373 hwndRelated = OSLibWinQueryWindow(getOS2FrameWindowHandle(), QWOS_PREV);
3374 window = GetWindowFromOS2FrameHandle(hwndRelated);
3375 if(window) {
3376 hwndRelated = window->getWindowHandle();
3377 RELEASE_WNDOBJ(window);
3378 }
3379 else hwndRelated = 0;
3380 }
3381 else {
3382 dprintf(("WARNING: GW_HWNDPREV not correctly implemented for toplevel/most windows!"));
3383 hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
3384 }
3385 break;
3386
3387 case GW_OWNER:
3388 {
3389 Win32BaseWindow *owner = getOwner();
3390 if(owner) {
3391 hwndRelated = owner->getWindowHandle();
3392 }
3393 break;
3394 }
3395
3396 case GW_CHILD:
3397 hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
3398 window = GetWindowFromOS2FrameHandle(hwndRelated);
3399
3400 //Before a window has processed WM_NCCREATE:
3401 //- GetWindow(parent, GW_CHILD) can't return that window handle
3402 //(verified in NT4, SP6)
3403 if(window) {
3404 if(window->state >= STATE_POST_WMNCCREATE) {
3405 hwndRelated = window->getWindowHandle();
3406 RELEASE_WNDOBJ(window);
3407 }
3408 else {
3409 hwndRelated = window->GetWindow(GW_HWNDNEXT);
3410 RELEASE_WNDOBJ(window);
3411 }
3412 }
3413 else hwndRelated = 0;
3414
3415 break;
3416
3417 //for internal use only
3418 case GW_HWNDNEXTCHILD:
3419 lock();
3420 window = (Win32BaseWindow *)getNextChild();
3421 if(window) {
3422 hwndRelated = window->getWindowHandle();
3423 }
3424 else hwndRelated = 0;
3425 unlock();
3426 break;
3427
3428 case GW_HWNDPREVCHILD:
3429 DebugInt3();
3430 break;
3431
3432 case GW_HWNDFIRSTCHILD:
3433 lock();
3434 window = (Win32BaseWindow *)getFirstChild();
3435 if(window) {
3436 hwndRelated = window->getWindowHandle();
3437 }
3438 else hwndRelated = 0;
3439 unlock();
3440 break;
3441
3442 case GW_HWNDLASTCHILD:
3443 lock();
3444 window = (Win32BaseWindow *)getFirstChild();
3445 if(window) {
3446 while (window->getNextChild())
3447 {
3448 window = (Win32BaseWindow *)window->getNextChild();
3449 }
3450 hwndRelated = window->getWindowHandle();
3451 }
3452 else hwndRelated = 0;
3453 unlock();
3454 break;
3455 }
3456end:
3457 dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
3458 return hwndRelated;
3459}
3460//******************************************************************************
3461//******************************************************************************
3462HWND Win32BaseWindow::SetActiveWindow()
3463{
3464 HWND hwndActive;
3465
3466 dprintf(("SetActiveWindow %x", getWindowHandle()));
3467 if(getStyle() & WS_CHILD) {
3468// if(getStyle() & (WS_DISABLED | WS_CHILD)) {
3469 dprintf(("WARNING: Window is a child or disabled"));
3470 return 0;
3471 }
3472
3473 if(GetActiveWindow() == getWindowHandle()) {
3474 dprintf(("Window already active"));
3475 return getWindowHandle();
3476 }
3477 if (HOOK_IsHooked( WH_CBT ))
3478 {
3479 CBTACTIVATESTRUCT cbta;
3480 LRESULT ret;
3481
3482 cbta.fMouse = FALSE;
3483 cbta.hWndActive = GetActiveWindow();
3484 ret = HOOK_CallHooksA(WH_CBT, HCBT_ACTIVATE, getWindowHandle(), (LPARAM)&cbta);
3485 if(ret)
3486 {
3487 dprintf(("SetActiveWindow %x, CBT hook cancelled operation", getWindowHandle()));
3488 return cbta.hWndActive;
3489 }
3490 }
3491 SetWindowPos(HWND_TOP, 0,0,0,0, SWP_NOSIZE | SWP_NOMOVE );
3492
3493// if(OSLibWinSetActiveWindow(OS2Hwnd) == FALSE) {
3494// dprintf(("OSLibWinSetActiveWindow %x returned FALSE!", OS2Hwnd));
3495// }
3496 hwndActive = GetActiveWindow();
3497 return (hwndActive) ? hwndActive : windowDesktop->getWindowHandle(); //pretend the desktop was active
3498}
3499//******************************************************************************
3500//Used to change active status of an mdi window
3501//******************************************************************************
3502BOOL Win32BaseWindow::DeactivateChildWindow()
3503{
3504 /* child windows get a WM_CHILDACTIVATE message */
3505 if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
3506 {
3507 ULONG flags = OSLibWinGetWindowULong(getOS2WindowHandle(), OFFSET_WIN32FLAGS);
3508 OSLibWinSetWindowULong(getOS2WindowHandle(), OFFSET_WIN32FLAGS, (flags & ~WINDOWFLAG_ACTIVE));
3509 return TRUE;
3510 }
3511 DebugInt3(); //should not be called for non-child window
3512 return FALSE;
3513}
3514//******************************************************************************
3515//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
3516//******************************************************************************
3517BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
3518{
3519 BOOL rc;
3520
3521 dprintf(("Win32BaseWindow::EnableWindow %x %d", getWindowHandle(), fEnable));
3522 //return true if previous state was disabled, else false (sdk docs)
3523 rc = (getStyle() & WS_DISABLED) != 0;
3524 if(rc && !fEnable) {
3525 SendMessageA(WM_CANCELMODE, 0, 0);
3526 }
3527 OSLibWinEnableWindow(OS2HwndFrame, fEnable);
3528 if(fEnable == FALSE) {
3529 //SvL: No need to clear focus as PM already does this
3530 if(getWindowHandle() == GetCapture()) {
3531 ReleaseCapture(); /* A disabled window can't capture the mouse */
3532 dprintf(("Released capture for window %x that is being disabled", getWindowHandle()));
3533 }
3534 }
3535 return rc;
3536}
3537//******************************************************************************
3538//******************************************************************************
3539BOOL Win32BaseWindow::CloseWindow()
3540{
3541 return OSLibWinMinimizeWindow(OS2Hwnd);
3542}
3543//******************************************************************************
3544//TODO: Not be 100% correct; should return active window of current thread
3545// or NULL when there is none -> WinQueryActiveWindow just returns
3546// the current active window
3547//******************************************************************************
3548HWND Win32BaseWindow::GetActiveWindow()
3549{
3550 HWND hwndActive;
3551
3552 hwndActive = OSLibWinQueryActiveWindow();
3553 return OS2ToWin32Handle(hwndActive);
3554}
3555//******************************************************************************
3556//******************************************************************************
3557BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
3558{
3559 INT len = GetWindowTextLength(fUnicode);
3560 BOOL res;
3561
3562 if (wndname == NULL)
3563 return (len == 0);
3564
3565 len++;
3566 if (fUnicode)
3567 {
3568 WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR));
3569
3570 GetWindowTextW(text,len);
3571 res = (lstrcmpW(text,(LPWSTR)wndname) == 0);
3572 free(text);
3573 }
3574 else
3575 {
3576 CHAR *text = (CHAR*)malloc(len*sizeof(CHAR));
3577
3578 GetWindowTextA(text,len);
3579 res = (strcmp(text,wndname) == 0);
3580 free(text);
3581 }
3582
3583 return res;
3584}
3585//******************************************************************************
3586//******************************************************************************
3587CHAR *Win32BaseWindow::getWindowNamePtrA()
3588{
3589 INT len = GetWindowTextLength(FALSE);
3590 CHAR *text;
3591
3592 if (len == 0) return NULL;
3593 len++;
3594 text = (CHAR*)malloc(len*sizeof(CHAR));
3595 GetWindowTextA(text,len);
3596
3597 return text;
3598}
3599//******************************************************************************
3600//******************************************************************************
3601WCHAR *Win32BaseWindow::getWindowNamePtrW()
3602{
3603 INT len = GetWindowTextLength(TRUE);
3604 WCHAR *text;
3605
3606 if (len == 0) return NULL;
3607 len++;
3608 text = (WCHAR*)malloc(len*sizeof(WCHAR));
3609 GetWindowTextW(text,len);
3610
3611 return text;
3612}
3613//******************************************************************************
3614//******************************************************************************
3615VOID Win32BaseWindow::freeWindowNamePtr(PVOID namePtr)
3616{
3617 if (namePtr) free(namePtr);
3618}
3619//******************************************************************************
3620//When using this API for a window that was created by a different process, NT
3621//does NOT send WM_GETTEXTLENGTH.
3622//******************************************************************************
3623int Win32BaseWindow::GetWindowTextLength(BOOL fUnicode)
3624{
3625 //if the destination window is created by this process, send message
3626 if(dwProcessId == currentProcessId) {
3627 if(fUnicode) {
3628 return SendInternalMessageW(WM_GETTEXTLENGTH,0,0);
3629 }
3630 else return SendInternalMessageA(WM_GETTEXTLENGTH,0,0);
3631 }
3632 //else get data directory from window structure
3633 //TODO: must lock window structure.... (TODO)
3634 return windowNameLength;
3635}
3636//******************************************************************************
3637//When using this API for a window that was created by a different process, NT
3638//does NOT send WM_GETTEXT.
3639//******************************************************************************
3640int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
3641{
3642 //if the destination window is created by this process, send message
3643 if(dwProcessId == currentProcessId) {
3644 return SendInternalMessageA(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
3645 }
3646
3647 //else get data directory from window structure
3648 if (!lpsz || !cch) return 0;
3649 if (!windowNameA) lpsz[0] = 0;
3650 else memcpy(lpsz, windowNameA, min(windowNameLength + 1, cch) );
3651 return min(windowNameLength, cch);
3652}
3653//******************************************************************************
3654//When using this API for a window that was created by a different process, NT
3655//does NOT send WM_GETTEXT.
3656//******************************************************************************
3657int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
3658{
3659 //if the destination window is created by this process, send message
3660 if(dwProcessId == currentProcessId) {
3661 return SendInternalMessageW(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
3662 }
3663 //else get data directory from window structure
3664 if (!lpsz || !cch)
3665 return 0;
3666 if (!windowNameW)
3667 lpsz[0] = 0;
3668 else
3669 memcpy(lpsz, windowNameW, min( sizeof(WCHAR) * (windowNameLength+1), cch));
3670
3671 return min(windowNameLength, cch);
3672}
3673//******************************************************************************
3674//TODO: How does this work when the target window belongs to a different process???
3675//******************************************************************************
3676BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
3677{
3678 return SendInternalMessageA(WM_SETTEXT,0,(LPARAM)lpsz);
3679}
3680//******************************************************************************
3681//******************************************************************************
3682BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
3683{
3684 return SendInternalMessageW(WM_SETTEXT,0,(LPARAM)lpsz);
3685}
3686//******************************************************************************
3687//******************************************************************************
3688LONG Win32BaseWindow::SetWindowLong(int index, ULONG value, BOOL fUnicode)
3689{
3690 LONG oldval;
3691
3692 switch(index) {
3693 case GWL_EXSTYLE:
3694 {
3695 STYLESTRUCT ss;
3696
3697 if(dwExStyle == value) {
3698 oldval = value;
3699 break;
3700 }
3701 ss.styleOld = dwExStyle;
3702 ss.styleNew = value;
3703 dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
3704 SendInternalMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
3705 setExStyle(ss.styleNew);
3706 SendInternalMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
3707 oldval = ss.styleOld;
3708 break;
3709 }
3710 case GWL_STYLE:
3711 {
3712 STYLESTRUCT ss;
3713
3714 //SvL: TODO: Can you change minimize or maximize status here too?
3715
3716 if(dwStyle == value) {
3717 oldval = value;
3718 break;
3719 }
3720 dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x (%x)", getWindowHandle(), dwStyle, value));
3721#ifdef DEBUG
3722// if((value & WS_CHILD) != (dwStyle & WS_CHILD)) {
3723// DebugInt3(); //is this allowed?
3724// }
3725#endif
3726 value &= ~(WS_CHILD);
3727 ss.styleOld = getStyle();
3728 ss.styleNew = value | (ss.styleOld & WS_CHILD);
3729 SendInternalMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
3730 setStyle(ss.styleNew);
3731 SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
3732 OSLibSetWindowStyle(getOS2FrameWindowHandle(), getOS2WindowHandle(), getStyle(), getExStyle());
3733
3734 //TODO: Might not be correct to use ShowWindow here
3735 if((ss.styleOld & WS_VISIBLE) != (ss.styleNew & WS_VISIBLE)) {
3736 if(ss.styleNew & WS_VISIBLE)
3737 ShowWindow(SW_SHOWNOACTIVATE);
3738 else ShowWindow(SW_HIDE);
3739 }
3740#ifdef DEBUG
3741 PrintWindowStyle(ss.styleNew, 0);
3742#endif
3743 oldval = ss.styleOld;
3744 break;
3745 }
3746 case GWL_WNDPROC:
3747 {
3748 //Note: Type of SetWindowLong determines new window proc type
3749 // UNLESS the new window proc has already been registered
3750 // (use the old type in that case)
3751 // (VERIFIED in NT 4, SP6)
3752 WINDOWPROCTYPE type = WINPROC_GetProcType((HWINDOWPROC)value);
3753 if(type == WIN_PROC_INVALID) {
3754 type = (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A;
3755 }
3756 oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
3757 dprintf(("SetWindowLong%c GWL_WNDPROC %x old %x new wndproc %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), oldval, value));
3758 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, type, WIN_PROC_WINDOW);
3759 break;
3760 }
3761 case GWL_HINSTANCE:
3762 oldval = hInstance;
3763 hInstance = value;
3764 break;
3765
3766 case GWL_HWNDPARENT:
3767 oldval = SetParent((HWND)value);
3768 break;
3769
3770 case GWL_ID:
3771 dprintf(("GWL_ID old %x, new %x", getWindowId(), value));
3772 oldval = getWindowId();
3773 setWindowId(value);
3774 break;
3775
3776 case GWL_USERDATA:
3777 oldval = userData;
3778 userData = value;
3779 break;
3780
3781 default:
3782 if(index >= 0 && index + sizeof(ULONG) <= nrUserWindowBytes)
3783 {
3784 oldval = *(ULONG *)(userWindowBytes + index);
3785 *(ULONG *)(userWindowBytes + index) = value;
3786 break;
3787 }
3788 dprintf(("WARNING: SetWindowLong%c %x %d %x returned %x INVALID index!", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
3789 SetLastError(ERROR_INVALID_INDEX); //verified in NT4, SP6
3790 return 0;
3791 }
3792 //Note: NT4, SP6 does not set the last error to 0
3793 SetLastError(ERROR_SUCCESS);
3794 dprintf2(("SetWindowLong%c %x %d %x returned %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value, oldval));
3795 return oldval;
3796}
3797//******************************************************************************
3798//******************************************************************************
3799ULONG Win32BaseWindow::GetWindowLong(int index, BOOL fUnicode)
3800{
3801 ULONG value;
3802
3803 switch(index) {
3804 case GWL_EXSTYLE:
3805 value = dwExStyle;
3806 break;
3807 case GWL_STYLE:
3808 value = dwStyle;
3809 break;
3810 case GWL_WNDPROC:
3811 value = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
3812 break;
3813 case GWL_HINSTANCE:
3814 value = hInstance;
3815 break;
3816 case GWL_HWNDPARENT:
3817 value = GetParent();
3818 break;
3819 case GWL_ID:
3820 value = getWindowId();
3821 break;
3822 case GWL_USERDATA:
3823 value = userData;
3824 break;
3825 default:
3826 if(index >= 0 && index + sizeof(ULONG) <= nrUserWindowBytes)
3827 {
3828 value = *(ULONG *)(userWindowBytes + index);
3829 break;
3830 }
3831 dprintf(("WARNING: GetWindowLong%c %x %d %x returned %x INVALID index!", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
3832 SetLastError(ERROR_INVALID_INDEX); //verified in NT4, SP6
3833 return 0;
3834 }
3835 dprintf2(("GetWindowLong%c %x %d %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
3836 //Note: NT4, SP6 does not set the last error to 0
3837 SetLastError(ERROR_SUCCESS);
3838 return value;
3839}
3840//******************************************************************************
3841//******************************************************************************
3842WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
3843{
3844 WORD oldval;
3845
3846 if(index >= 0 && index + sizeof(WORD) <= nrUserWindowBytes)
3847 {
3848 oldval = *(WORD *)(userWindowBytes + index);
3849 *(WORD *)(userWindowBytes + index) = value;
3850 //Note: NT4, SP6 does not set the last error to 0
3851 dprintf2(("SetWindowWord %x %d %x returned %x", getWindowHandle(), index, value, oldval));
3852 SetLastError(ERROR_SUCCESS);
3853 return oldval;
3854 }
3855 switch(index)
3856 {
3857 case GWW_HINSTANCE:
3858 oldval = hInstance;
3859 hInstance = value;
3860 break;
3861
3862 case GWW_HWNDPARENT:
3863 oldval = SetParent((HWND)(WNDHANDLE_MAGIC_HIGHWORD | value));
3864 break;
3865
3866 case GWW_ID:
3867 oldval = getWindowId();
3868 setWindowId(value);
3869 break;
3870
3871 default:
3872 dprintf(("WARNING: SetWindowWord %x %d %x returned %x INVALID index!", getWindowHandle(), index, value));
3873 SetLastError(ERROR_INVALID_INDEX); //verified in NT4, SP6
3874 return 0;
3875 }
3876 //Note: NT4, SP6 does not set the last error to 0
3877 SetLastError(ERROR_SUCCESS);
3878 dprintf2(("SetWindowWord %x %d %x returned %x", getWindowHandle(), index, value, oldval));
3879 return oldval;
3880}
3881//******************************************************************************
3882//******************************************************************************
3883WORD Win32BaseWindow::GetWindowWord(int index)
3884{
3885 if(index >= 0 && index + sizeof(WORD) <= nrUserWindowBytes)
3886 {
3887 //Note: NT4, SP6 does not set the last error to 0
3888 SetLastError(ERROR_SUCCESS);
3889 dprintf2(("GetWindowWord %x %d %x", getWindowHandle(), index, *(WORD *)(userWindowBytes + index)));
3890 return *(WORD *)(userWindowBytes + index);
3891 }
3892 switch(index)
3893 {
3894 case GWW_ID:
3895 if(HIWORD(getWindowId()))
3896 dprintf(("WARNING: GWW_ID: discards high bits of 0x%08x!\n", getWindowId()));
3897 return (WORD)getWindowId();
3898
3899 case GWW_HWNDPARENT:
3900 dprintf(("WARNING: GWW_HWNDPARENT: discards high bits of 0x%08x!\n", GetParent()));
3901 return (WORD) GetParent();
3902
3903 case GWW_HINSTANCE:
3904 if (HIWORD(hInstance))
3905 dprintf(("WARNING: GWW_HINSTANCE: discards high bits of 0x%08x!\n", hInstance));
3906 return (WORD)hInstance;
3907 }
3908
3909 dprintf(("WARNING: GetWindowWord %x %d returned %x INVALID index!", getWindowHandle(), index));
3910 SetLastError(ERROR_INVALID_INDEX); //verified in NT4, SP6
3911 return 0;
3912}
3913//******************************************************************************
3914//Locates window in linked list and increases reference count (if found)
3915//Window object must be unreferenced after usage
3916//******************************************************************************
3917Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
3918{
3919 Win32BaseWindow *window;
3920
3921////TODO: temporary workaround for crashes in Opera (pmwinx; releasesemaphore)
3922//// while browsing
3923//// Not thread safe now!
3924//// lock(&critsect);
3925 if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
3926 if(window) {
3927//// dprintf(("addRef %x; refcount %d", hwnd, window->getRefCount()+1));
3928 window->addRef();
3929 }
3930//// unlock(&critsect);
3931 return window;
3932 }
3933//// unlock(&critsect);
3934// dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
3935 return NULL;
3936}
3937//******************************************************************************
3938//Locates window in linked list and increases reference count (if found)
3939//Window object must be unreferenced after usage
3940//******************************************************************************
3941Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwndOS2)
3942{
3943 DWORD magic;
3944 HWND hwnd;
3945
3946 if(hwndOS2 == OSLIB_HWND_DESKTOP)
3947 {
3948 windowDesktop->addRef();
3949 return windowDesktop;
3950 }
3951
3952 hwnd = (HWND)OSLibWinGetWindowULong(hwndOS2, OFFSET_WIN32WNDPTR);
3953 magic = OSLibWinGetWindowULong(hwndOS2, OFFSET_WIN32PM_MAGIC);
3954
3955 if(hwnd && CheckMagicDword(magic)) {
3956 return GetWindowFromHandle(hwnd);
3957 }
3958// dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwndOS2));
3959 return 0;
3960}
3961//******************************************************************************
3962//Locates window in linked list and increases reference count (if found)
3963//Window object must be unreferenced after usage
3964//******************************************************************************
3965Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
3966{
3967 return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
3968}
3969//******************************************************************************
3970//******************************************************************************
3971HWND WIN32API Win32ToOS2Handle(HWND hwnd)
3972{
3973 HWND hwndOS2;
3974
3975 Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
3976
3977 if(window) {
3978 hwndOS2 = window->getOS2WindowHandle();
3979 RELEASE_WNDOBJ(window);
3980 return hwndOS2;
3981 }
3982// dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
3983 return hwnd;
3984}
3985//******************************************************************************
3986//******************************************************************************
3987HWND WIN32API Win32ToOS2FrameHandle(HWND hwnd)
3988{
3989 HWND hwndOS2;
3990
3991 Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
3992
3993 if(window) {
3994 hwndOS2 = window->getOS2FrameWindowHandle();
3995 RELEASE_WNDOBJ(window);
3996 return hwndOS2;
3997 }
3998// dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
3999 return hwnd;
4000}
4001//******************************************************************************
4002//******************************************************************************
4003HWND WIN32API OS2ToWin32Handle(HWND hwnd)
4004{
4005 Win32BaseWindow *window = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
4006 HWND hwndWin32;
4007
4008 if(window) {
4009 hwndWin32 = window->getWindowHandle();
4010 RELEASE_WNDOBJ(window);
4011 return hwndWin32;
4012 }
4013 window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
4014 if(window) {
4015 hwndWin32 = window->getWindowHandle();
4016 RELEASE_WNDOBJ(window);
4017 return hwndWin32;
4018 }
4019
4020// dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
4021 return 0;
4022// else return hwnd; //OS/2 window handle
4023}
4024#ifdef DEBUG
4025LONG Win32BaseWindow::addRef()
4026{
4027// dprintf2(("addRef %x %d", getWindowHandle(), getRefCount()+1));
4028 return GenericObject::addRef();
4029}
4030//******************************************************************************
4031//******************************************************************************
4032LONG Win32BaseWindow::release(char *function, int line)
4033{
4034// dprintf2(("release %s %d %x %d", function, line, getWindowHandle(), getRefCount()-1));
4035 return GenericObject::release();
4036}
4037#endif
4038//******************************************************************************
4039//******************************************************************************
4040GenericObject *Win32BaseWindow::windows = NULL;
4041CRITICAL_SECTION Win32BaseWindow::critsect = {0};
4042
4043//******************************************************************************
4044//******************************************************************************
4045#ifdef DEBUG
4046void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
4047{
4048 char style[256] = "";
4049 char exstyle[256] = "";
4050
4051 /* Window styles */
4052 if(dwStyle & WS_CHILD)
4053 strcat(style, "WS_CHILD ");
4054 if(dwStyle & WS_POPUP)
4055 strcat(style, "WS_POPUP ");
4056 if(dwStyle & WS_VISIBLE)
4057 strcat(style, "WS_VISIBLE ");
4058 if(dwStyle & WS_DISABLED)
4059 strcat(style, "WS_DISABLED ");
4060 if(dwStyle & WS_CLIPSIBLINGS)
4061 strcat(style, "WS_CLIPSIBLINGS ");
4062 if(dwStyle & WS_CLIPCHILDREN)
4063 strcat(style, "WS_CLIPCHILDREN ");
4064 if(dwStyle & WS_MAXIMIZE)
4065 strcat(style, "WS_MAXIMIZE ");
4066 if(dwStyle & WS_MINIMIZE)
4067 strcat(style, "WS_MINIMIZE ");
4068 if(dwStyle & WS_GROUP)
4069 strcat(style, "WS_GROUP ");
4070 if(dwStyle & WS_TABSTOP)
4071 strcat(style, "WS_TABSTOP ");
4072
4073 if((dwStyle & WS_CAPTION) == WS_CAPTION)
4074 strcat(style, "WS_CAPTION ");
4075 if(dwStyle & WS_DLGFRAME)
4076 strcat(style, "WS_DLGFRAME ");
4077 if(dwStyle & WS_BORDER)
4078 strcat(style, "WS_BORDER ");
4079
4080 if(dwStyle & WS_VSCROLL)
4081 strcat(style, "WS_VSCROLL ");
4082 if(dwStyle & WS_HSCROLL)
4083 strcat(style, "WS_HSCROLL ");
4084 if(dwStyle & WS_SYSMENU)
4085 strcat(style, "WS_SYSMENU ");
4086 if(dwStyle & WS_THICKFRAME)
4087 strcat(style, "WS_THICKFRAME ");
4088 if(dwStyle & WS_MINIMIZEBOX)
4089 strcat(style, "WS_MINIMIZEBOX ");
4090 if(dwStyle & WS_MAXIMIZEBOX)
4091 strcat(style, "WS_MAXIMIZEBOX ");
4092
4093 if(dwExStyle & WS_EX_DLGMODALFRAME)
4094 strcat(exstyle, "WS_EX_DLGMODALFRAME ");
4095 if(dwExStyle & WS_EX_ACCEPTFILES)
4096 strcat(exstyle, "WS_EX_ACCEPTFILES ");
4097 if(dwExStyle & WS_EX_NOPARENTNOTIFY)
4098 strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
4099 if(dwExStyle & WS_EX_TOPMOST)
4100 strcat(exstyle, "WS_EX_TOPMOST ");
4101 if(dwExStyle & WS_EX_TRANSPARENT)
4102 strcat(exstyle, "WS_EX_TRANSPARENT ");
4103
4104 if(dwExStyle & WS_EX_MDICHILD)
4105 strcat(exstyle, "WS_EX_MDICHILD ");
4106 if(dwExStyle & WS_EX_TOOLWINDOW)
4107 strcat(exstyle, "WS_EX_TOOLWINDOW ");
4108 if(dwExStyle & WS_EX_WINDOWEDGE)
4109 strcat(exstyle, "WS_EX_WINDOWEDGE ");
4110 if(dwExStyle & WS_EX_CLIENTEDGE)
4111 strcat(exstyle, "WS_EX_CLIENTEDGE ");
4112 if(dwExStyle & WS_EX_CONTEXTHELP)
4113 strcat(exstyle, "WS_EX_CONTEXTHELP ");
4114 if(dwExStyle & WS_EX_RIGHT)
4115 strcat(exstyle, "WS_EX_RIGHT ");
4116 if(dwExStyle & WS_EX_LEFT)
4117 strcat(exstyle, "WS_EX_LEFT ");
4118 if(dwExStyle & WS_EX_RTLREADING)
4119 strcat(exstyle, "WS_EX_RTLREADING ");
4120 if(dwExStyle & WS_EX_LTRREADING)
4121 strcat(exstyle, "WS_EX_LTRREADING ");
4122 if(dwExStyle & WS_EX_LEFTSCROLLBAR)
4123 strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
4124 if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
4125 strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
4126 if(dwExStyle & WS_EX_CONTROLPARENT)
4127 strcat(exstyle, "WS_EX_CONTROLPARENT ");
4128 if(dwExStyle & WS_EX_STATICEDGE)
4129 strcat(exstyle, "WS_EX_STATICEDGE ");
4130 if(dwExStyle & WS_EX_APPWINDOW)
4131 strcat(exstyle, "WS_EX_APPWINDOW ");
4132
4133 dprintf(("Window style: %x %s", dwStyle, style));
4134 dprintf(("Window exStyle: %x %s", dwExStyle, exstyle));
4135}
4136#endif
4137//******************************************************************************
4138//******************************************************************************
Note: See TracBrowser for help on using the repository browser.