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

Last change on this file since 9466 was 9466, checked in by sandervl, 23 years ago

PF: Support the standard system menu hotkeys in OS/2 GUI mode

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