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

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

MDI + SetParent + activation fixes

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