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

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

YD: SetWindowPos bugfix (SWP_NOSENDCHANGING)

File size: 122.2 KB
Line 
1/* $Id: win32wbase.cpp,v 1.227 2000-12-27 23:07:19 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 | SWP_NOSENDCHANGING | SWP_DEFERERASE |
2227 SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE))
2228 {
2229 dprintf(("ERROR: SetWindowPos; UNKNOWN flag"));
2230 return FALSE;
2231 }
2232
2233 if( fuFlags & (SWP_DEFERERASE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)) {
2234 dprintf(("WARNING: SetWindowPos; unsupported flag"));
2235 }
2236
2237 if(IsWindowDestroyed()) {
2238 //changing the position of a window that's being destroyed can cause crashes in PMMERGE
2239 dprintf(("SetWindowPos; window already destroyed"));
2240 return TRUE;
2241 }
2242#if 0
2243 /* Fix redundant flags */
2244 if(getStyle() & WS_VISIBLE) {
2245 fuFlags &= ~SWP_SHOWWINDOW;
2246 }
2247 else
2248 {
2249 if (!(fuFlags & SWP_SHOWWINDOW))
2250 fuFlags |= SWP_NOREDRAW;
2251 fuFlags &= ~SWP_HIDEWINDOW;
2252 }
2253
2254 if(cx < 0) cx = 0;
2255 if(cy < 0) cy = 0;
2256
2257 if((rectWindow.right - rectWindow.left == cx) && (rectWindow.bottom - rectWindow.top == cy)) {
2258 fuFlags |= SWP_NOSIZE; /* Already the right size */
2259 }
2260
2261 if((rectWindow.left == x) && (rectWindow.top == y)) {
2262 fuFlags |= SWP_NOMOVE; /* Already the right position */
2263 }
2264
2265 if(getWindowHandle() == GetActiveWindow()) {
2266 fuFlags |= SWP_NOACTIVATE; /* Already active */
2267 }
2268 else
2269 if((getStyle() & (WS_POPUP | WS_CHILD)) != WS_CHILD )
2270 {
2271 if(!(fuFlags & SWP_NOACTIVATE)) /* Bring to the top when activating */
2272 {
2273 fuFlags &= ~SWP_NOZORDER;
2274 hwndInsertAfter = HWND_TOP;
2275 }
2276 }
2277#endif
2278
2279 if(!fCreateSetWindowPos)
2280 {//don't change size; modify internal structures only
2281 //TODO: not 100% correct yet (activate)
2282 if(!(fuFlags & SWP_NOZORDER)) {
2283 hwndLinkAfter = hwndInsertAfter;
2284 }
2285 if(!(fuFlags & SWP_NOMOVE)) {
2286 rectWindow.bottom = (rectWindow.bottom - rectWindow.top) + y;
2287 rectWindow.top = y;
2288 rectWindow.right = (rectWindow.right - rectWindow.left) + x;
2289 rectWindow.left = x;
2290 }
2291 if(!(fuFlags & SWP_NOSIZE)) {
2292 rectWindow.bottom = rectWindow.top + cy;
2293 rectWindow.right = rectWindow.left + cx;
2294 }
2295 return TRUE;
2296 }
2297
2298 WINDOWPOS wpos;
2299 SWP swp, swpOld;
2300 wpos.flags = fuFlags;
2301 wpos.cy = cy;
2302 wpos.cx = cx;
2303 wpos.x = x;
2304 wpos.y = y;
2305 wpos.hwndInsertAfter = hwndInsertAfter;
2306 wpos.hwnd = getWindowHandle();
2307
2308 if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
2309 {
2310 if (isChild())
2311 {
2312 if(!getParent()) {
2313 dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
2314 }
2315 }
2316 OSLibWinQueryWindowPos(OS2Hwnd, &swpOld);
2317 }
2318
2319 if(getParent()) {
2320 OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, getParent()->getWindowHeight(),
2321 getParent()->getClientRectPtr()->left,
2322 getParent()->getClientRectPtr()->top,
2323 OS2Hwnd);
2324 }
2325 else OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, OSLibQueryScreenHeight(), 0, 0, OS2Hwnd);
2326 if (swp.fl == 0) {
2327 if(fuFlags & SWP_FRAMECHANGED)
2328 {
2329 NotifyFrameChanged(&wpos, &oldClientRect);
2330 }
2331 return TRUE;
2332 }
2333
2334// if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
2335 if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
2336 {
2337 Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
2338 if(wndBehind) {
2339 swp.hwndInsertBehind = wndBehind->getOS2WindowHandle();
2340 }
2341 else {
2342 dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
2343 swp.hwndInsertBehind = 0;
2344 }
2345 }
2346 swp.hwnd = OS2Hwnd;
2347
2348 if(fuFlags & SWP_SHOWWINDOW && !IsWindowVisible()) {
2349 setStyle(getStyle() | WS_VISIBLE);
2350 if(hTaskList) {
2351 dprintf(("Adding window %x to tasklist", getWindowHandle()));
2352 OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
2353 }
2354 }
2355 else
2356 if(fuFlags & SWP_HIDEWINDOW && IsWindowVisible()) {
2357 setStyle(getStyle() & ~WS_VISIBLE);
2358 if(hTaskList) {
2359 dprintf(("Removing window %x from tasklist", getWindowHandle()));
2360 OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
2361 }
2362 }
2363 dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
2364 rc = OSLibWinSetMultWindowPos(&swp, 1);
2365
2366 if(rc == FALSE)
2367 {
2368 dprintf(("OSLibWinSetMultWindowPos failed! Error %x",OSLibWinGetLastError()));
2369 return 0;
2370 }
2371
2372 if((fuFlags & SWP_FRAMECHANGED) && (fuFlags & (SWP_NOMOVE | SWP_NOSIZE) == (SWP_NOMOVE | SWP_NOSIZE)))
2373 {
2374 NotifyFrameChanged(&wpos, &oldClientRect);
2375 }
2376 return (rc);
2377}
2378//******************************************************************************
2379//******************************************************************************
2380void Win32BaseWindow::NotifyFrameChanged(WINDOWPOS *wpos, RECT *oldClientRect)
2381{
2382 HRGN hrgn, hrgnClient;
2383 RECT rect;
2384
2385 MsgFormatFrame(NULL);
2386 if(RECT_WIDTH(rectClient) != RECT_WIDTH(*oldClientRect) ||
2387 RECT_HEIGHT(rectClient) != RECT_HEIGHT(*oldClientRect))
2388 {
2389 wpos->flags &= ~SWP_NOSIZE;
2390 }
2391
2392 WINDOWPOS wpOld = *wpos;
2393 SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, (LPARAM)wpos);
2394
2395 if ((wpos->hwndInsertAfter != wpOld.hwndInsertAfter) ||
2396 (wpos->x != wpOld.x) || (wpos->y != wpOld.y) || (wpos->cx != wpOld.cx) || (wpos->cy != wpOld.cy) || (wpos->flags != wpOld.flags))
2397 {
2398 dprintf(("WARNING, NotifyFrameChanged: TODO -> adjust flags!!!!"));
2399 SetWindowPos(wpos->hwndInsertAfter, wpos->x, wpos->y, wpos->cx, wpos->cy, wpos->flags | SWP_NOSENDCHANGING);
2400 }
2401 else SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, (LPARAM)wpos);
2402
2403 rect = rectWindow;
2404 OffsetRect(&rect, -rectWindow.left, -rectWindow.top);
2405 hrgn = CreateRectRgnIndirect(&rect);
2406 if (!hrgn) {
2407 dprintf(("ERROR: NotifyFrameChanged, CreateRectRgnIndirect failed!!"));
2408 return;
2409 }
2410 rect = rectClient;
2411 OffsetRect(&rect, -rectClient.left, -rectClient.top);
2412 hrgnClient = CreateRectRgnIndirect(&rect);
2413 if (!hrgn) {
2414 dprintf(("ERROR: NotifyFrameChanged, CreateRectRgnIndirect failed!!"));
2415 return;
2416 }
2417 CombineRgn(hrgn, hrgn, hrgnClient, RGN_DIFF);
2418 DeleteObject(hrgnClient);
2419
2420 if(!EqualRect(oldClientRect, &rectClient)) {
2421 UnionRect(oldClientRect, oldClientRect, &rectClient);
2422 OffsetRect(oldClientRect, -rectClient.left, -rectClient.top);
2423 hrgnClient = CreateRectRgnIndirect(oldClientRect);
2424 if (!hrgn) {
2425 dprintf(("ERROR: NotifyFrameChanged, CreateRectRgnIndirect failed!!"));
2426 return;
2427 }
2428 CombineRgn(hrgn, hrgn, hrgnClient, RGN_OR);
2429 DeleteObject(hrgnClient);
2430 }
2431 InvalidateRgn(getWindowHandle(), hrgn, TRUE);
2432 DeleteObject(hrgn);
2433}
2434//******************************************************************************
2435//TODO: Check how this api really works in NT
2436//******************************************************************************
2437BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *wndpl)
2438{
2439 windowpos.ptMinPosition = wndpl->ptMinPosition;
2440 windowpos.ptMaxPosition = wndpl->ptMaxPosition;
2441 windowpos.rcNormalPosition = wndpl->rcNormalPosition;
2442
2443 if(getStyle() & WS_MINIMIZE )
2444 {
2445 //TODO: Why can't this be (0,0)?
2446 if(wndpl->flags & WPF_SETMINPOSITION && !(!windowpos.ptMinPosition.x && !windowpos.ptMinPosition.y)) {
2447 SetWindowPos(0, windowpos.ptMinPosition.x, windowpos.ptMinPosition.y,
2448 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
2449 }
2450 }
2451 else
2452 if(getStyle() & WS_MAXIMIZE )
2453 {
2454 //TODO: Why can't this be (0,0)?
2455 if(windowpos.ptMaxPosition.x != 0 || windowpos.ptMaxPosition.y != 0 )
2456 SetWindowPos(0, windowpos.ptMaxPosition.x, windowpos.ptMaxPosition.y,
2457 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
2458 }
2459 else {
2460 SetWindowPos(0, windowpos.rcNormalPosition.left, windowpos.rcNormalPosition.top,
2461 windowpos.rcNormalPosition.right - windowpos.rcNormalPosition.left,
2462 windowpos.rcNormalPosition.bottom - windowpos.rcNormalPosition.top,
2463 SWP_NOZORDER | SWP_NOACTIVATE );
2464 }
2465 ShowWindow(wndpl->showCmd);
2466 if( ::IsWindow(getWindowHandle()) && getStyle() & WS_MINIMIZE )
2467 {
2468 /* SDK: ...valid only the next time... */
2469 if(wndpl->flags & WPF_RESTORETOMAXIMIZED)
2470 setFlags(getFlags() | WIN_RESTORE_MAX);
2471 }
2472 return TRUE;
2473}
2474//******************************************************************************
2475//******************************************************************************
2476BOOL Win32BaseWindow::GetWindowPlacement(LPWINDOWPLACEMENT wndpl)
2477{
2478 wndpl->length = sizeof(*wndpl);
2479 if(getStyle() & WS_MINIMIZE )
2480 wndpl->showCmd = SW_SHOWMINIMIZED;
2481 else wndpl->showCmd = (getStyle() & WS_MAXIMIZE) ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL;
2482
2483 //TODO: Verify if this is correct -> SDK docs claim this flag must always be set to 0
2484 if(getFlags() & WIN_RESTORE_MAX )
2485 wndpl->flags = WPF_RESTORETOMAXIMIZED;
2486 else wndpl->flags = 0;
2487
2488 wndpl->ptMinPosition = windowpos.ptMinPosition;
2489 wndpl->ptMaxPosition = windowpos.ptMaxPosition;
2490 //Must be in parent coordinates (or screen if no parent); verified in NT4, SP6
2491 wndpl->rcNormalPosition = rectWindow;
2492
2493 return TRUE;
2494}
2495//******************************************************************************
2496//Also destroys all the child windows (destroy children first, parent last)
2497//******************************************************************************
2498BOOL Win32BaseWindow::DestroyWindow()
2499{
2500 HWND hwnd = getWindowHandle();
2501
2502 dprintf(("DestroyWindow %x", hwnd));
2503
2504 /* Call hooks */
2505 if(HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, getWindowHandle(), 0L))
2506 {
2507 return FALSE;
2508 }
2509
2510 if(!(getStyle() & WS_CHILD) && getOwner() == NULL)
2511 {
2512 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWDESTROYED, getWindowHandle(), 0L);
2513 /* FIXME: clean up palette - see "Internals" p.352 */
2514 }
2515
2516 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
2517 {
2518 if(getParent() && getParent()->IsWindowDestroyed() == FALSE)
2519 {
2520 /* Notify the parent window only */
2521 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
2522 if(!::IsWindow(hwnd) )
2523 {
2524 return TRUE;
2525 }
2526 }
2527//// else DebugInt3();
2528 }
2529 /* Hide the window */
2530 if(IsWindowVisible())
2531 {
2532 SetWindowPos(0, 0, 0, 0, 0, SWP_HIDEWINDOW |
2533 SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE);
2534 if(!::IsWindow(hwnd))
2535 {
2536 return TRUE;
2537 }
2538 }
2539 dprintf(("DestroyWindow %x -> HIDDEN", hwnd));
2540
2541 fDestroyWindowCalled = TRUE;
2542 return OSLibWinDestroyWindow(OS2Hwnd);
2543}
2544//******************************************************************************
2545//******************************************************************************
2546Win32BaseWindow *Win32BaseWindow::getParent()
2547{
2548 Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
2549 return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
2550}
2551//******************************************************************************
2552//******************************************************************************
2553HWND Win32BaseWindow::GetParent()
2554{
2555 if((!(getStyle() & (WS_POPUP|WS_CHILD)))) {
2556 return 0;
2557 }
2558
2559 Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
2560
2561 if(getStyle() & WS_CHILD) {
2562 if(wndparent) {
2563 return wndparent->getWindowHandle();
2564 }
2565 dprintf(("WARNING: GetParent: WS_CHILD but no parent!!"));
2566 DebugInt3();
2567 return 0;
2568 }
2569 else return (getOwner()) ? getOwner()->getWindowHandle() : 0;
2570}
2571//******************************************************************************
2572//******************************************************************************
2573HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
2574{
2575 HWND oldhwnd;
2576 Win32BaseWindow *newparent;
2577 Win32BaseWindow *oldparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
2578 BOOL fShow = FALSE;
2579
2580 if(oldparent) {
2581 oldhwnd = oldparent->getWindowHandle();
2582 oldparent->removeChild(this);
2583 }
2584 else oldhwnd = 0;
2585
2586 /* Windows hides the window first, then shows it again
2587 * including the WM_SHOWWINDOW messages and all */
2588 if(fCreated && (getStyle() & WS_VISIBLE)) {
2589 ShowWindow(SW_HIDE);
2590 fShow = TRUE;
2591 }
2592
2593 newparent = GetWindowFromHandle(hwndNewParent);
2594 if(newparent && !newparent->isDesktopWindow())
2595 {
2596 setParent(newparent);
2597 getParent()->addChild(this);
2598 OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
2599 if(!(getStyle() & WS_CHILD))
2600 {
2601 //TODO: Send WM_STYLECHANGED msg?
2602 setStyle(getStyle() | WS_CHILD);
2603 if(getWindowId())
2604 {
2605 DestroyMenu( (HMENU) getWindowId() );
2606 setWindowId(0);
2607 }
2608 }
2609 }
2610 else {
2611 setParent(windowDesktop);
2612 windowDesktop->addChild(this);
2613 OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
2614
2615 //TODO: Send WM_STYLECHANGED msg?
2616 setStyle(getStyle() & ~WS_CHILD);
2617 setWindowId(0);
2618 }
2619 /* SetParent additionally needs to make hwndChild the topmost window
2620 in the x-order and send the expected WM_WINDOWPOSCHANGING and
2621 WM_WINDOWPOSCHANGED notification messages.
2622 */
2623 if(fCreated) {
2624 SetWindowPos(HWND_TOPMOST, 0, 0, 0, 0,
2625 SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|(fShow? SWP_SHOWWINDOW : 0));
2626
2627 /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
2628 * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */
2629 }
2630 return oldhwnd;
2631}
2632//******************************************************************************
2633//******************************************************************************
2634BOOL Win32BaseWindow::IsChild(HWND hwndParent)
2635{
2636 if(getParent()) {
2637 return getParent()->getWindowHandle() == hwndParent;
2638 }
2639 else return 0;
2640}
2641//******************************************************************************
2642//******************************************************************************
2643HWND Win32BaseWindow::GetTopWindow()
2644{
2645 HWND hwndTop;
2646 Win32BaseWindow *topwindow;
2647
2648 hwndTop = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
2649 if(!isDesktopWindow()) {
2650 topwindow = GetWindowFromOS2Handle(hwndTop);
2651 if(topwindow) {
2652 return topwindow->getWindowHandle();
2653 }
2654 return 0;
2655 }
2656 while(hwndTop) {
2657 topwindow = GetWindowFromOS2Handle(hwndTop);
2658 if(topwindow) {
2659 return topwindow->getWindowHandle();
2660 }
2661 hwndTop = OSLibWinQueryWindow(hwndTop, QWOS_NEXT);
2662 }
2663
2664 return 0;
2665}
2666//******************************************************************************
2667// Get the top-level parent for a child window.
2668//******************************************************************************
2669Win32BaseWindow *Win32BaseWindow::GetTopParent()
2670{
2671 Win32BaseWindow *window = this;
2672
2673 while(window && (window->getStyle() & WS_CHILD))
2674 {
2675 window = window->getParent();
2676 }
2677 return window;
2678}
2679//******************************************************************************
2680//TODO: Should not enumerate children that are created during the enumeration!
2681//******************************************************************************
2682BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
2683{
2684 BOOL rc = TRUE;
2685 HWND hwnd;
2686 Win32BaseWindow *prevchild = 0, *child = 0;
2687
2688 dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
2689 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2690 {
2691 dprintf(("EnumChildWindows: enumerating child %x (owner %x; parent %x)", child->getWindowHandle(), (child->getOwner()) ? child->getOwner()->getWindowHandle() : 0, getWindowHandle()));
2692 hwnd = child->getWindowHandle();
2693 if(child->getOwner()) {
2694 continue; //shouldn't have an owner (Wine)
2695 }
2696 if(lpfn(hwnd, lParam) == FALSE)
2697 {
2698 rc = FALSE;
2699 break;
2700 }
2701 //check if the window still exists
2702 if(!::IsWindow(hwnd))
2703 {
2704 child = prevchild;
2705 continue;
2706 }
2707 if(child->getFirstChild() != NULL)
2708 {
2709 dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle()));
2710 if(child->EnumChildWindows(lpfn, lParam) == FALSE)
2711 {
2712 rc = FALSE;
2713 break;
2714 }
2715 }
2716 prevchild = child;
2717 }
2718 return rc;
2719}
2720//******************************************************************************
2721//Enumerate first-level children only and check thread id
2722//******************************************************************************
2723BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
2724{
2725 Win32BaseWindow *child = 0;
2726 ULONG tid, pid;
2727 BOOL rc;
2728 HWND hwnd;
2729
2730 dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam));
2731
2732 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2733 {
2734 OSLibWinQueryWindowProcess(child->getOS2WindowHandle(), &pid, &tid);
2735
2736 if(dwThreadId == tid) {
2737 dprintf2(("EnumThreadWindows: Found Window %x", child->getWindowHandle()));
2738 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
2739 break;
2740 }
2741 }
2742 }
2743 return TRUE;
2744}
2745//******************************************************************************
2746//Enumerate first-level children only
2747//******************************************************************************
2748BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
2749{
2750 Win32BaseWindow *child = 0;
2751 BOOL rc;
2752 HWND hwnd;
2753
2754 dprintf(("EnumWindows %x %x", lpfn, lParam));
2755
2756 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2757 {
2758 hwnd = child->getWindowHandle();
2759
2760 dprintf2(("EnumWindows: Found Window %x", child->getWindowHandle()));
2761 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
2762 break;
2763 }
2764 }
2765 return TRUE;
2766}
2767//******************************************************************************
2768//******************************************************************************
2769Win32BaseWindow *Win32BaseWindow::FindWindowById(int id)
2770{
2771 for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2772 {
2773 if (child->getWindowId() == id)
2774 {
2775 return child;
2776 }
2777 }
2778 return 0;
2779}
2780//******************************************************************************
2781//TODO:
2782//We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
2783//the current process owns them.
2784//******************************************************************************
2785HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, ATOM atom, LPSTR lpszWindow)
2786{
2787 Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
2788 Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
2789
2790 dprintf(("FindWindowEx %x %x %x %s", hwndParent, hwndChildAfter, atom, lpszWindow));
2791 if((hwndParent != 0 && !parent) ||
2792 (hwndChildAfter != 0 && !child) ||
2793 (hwndParent == 0 && hwndChildAfter != 0))
2794 {
2795 dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
2796 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
2797 return 0;
2798 }
2799 SetLastError(0);
2800 if(hwndParent != 0)
2801 {//if the current process owns the window, just do a quick search
2802 child = (Win32BaseWindow *)parent->getFirstChild();
2803 if(hwndChildAfter != 0)
2804 {
2805 while(child)
2806 {
2807 if(child->getWindowHandle() == hwndChildAfter)
2808 {
2809 child = (Win32BaseWindow *)child->getNextChild();
2810 break;
2811 }
2812 child = (Win32BaseWindow *)child->getNextChild();
2813 }
2814 }
2815 while(child)
2816 {
2817 //According to Wine, the class doesn't need to be specified
2818 if((!atom || child->getWindowClass()->getAtom() == atom) &&
2819 (!lpszWindow || child->hasWindowName(lpszWindow)))
2820 {
2821 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
2822 return child->getWindowHandle();
2823 }
2824 child = (Win32BaseWindow *)child->getNextChild();
2825 }
2826 }
2827 else {
2828 Win32BaseWindow *wnd;
2829 HWND henum, hwnd;
2830
2831 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
2832 hwnd = OSLibWinGetNextWindow(henum);
2833
2834 while(hwnd)
2835 {
2836 wnd = GetWindowFromOS2Handle(hwnd);
2837 if(wnd == NULL) {
2838 hwnd = OSLibWinQueryClientWindow(hwnd);
2839 if(hwnd) wnd = GetWindowFromOS2Handle(hwnd);
2840 }
2841
2842 if(wnd) {
2843 //According to Wine, the class doesn't need to be specified
2844 if((!atom || wnd->getWindowClass()->getAtom() == atom) &&
2845 (!lpszWindow || wnd->hasWindowName(lpszWindow)))
2846 {
2847 OSLibWinEndEnumWindows(henum);
2848 dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
2849 return wnd->getWindowHandle();
2850 }
2851 }
2852 hwnd = OSLibWinGetNextWindow(henum);
2853 }
2854 OSLibWinEndEnumWindows(henum);
2855 }
2856 SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
2857 return 0;
2858}
2859//******************************************************************************
2860//******************************************************************************
2861HWND Win32BaseWindow::GetWindow(UINT uCmd)
2862{
2863 HWND hwndRelated = 0;
2864 Win32BaseWindow *window;
2865
2866#if 1
2867 switch(uCmd)
2868 {
2869 case GW_HWNDFIRST:
2870 if(getParent())
2871 {
2872 window = (Win32BaseWindow *)getParent();
2873 hwndRelated = OSLibWinQueryWindow(window->getOS2WindowHandle(), QWOS_TOP);
2874 window = GetWindowFromOS2Handle(hwndRelated);
2875 if(window) {
2876 hwndRelated = window->getWindowHandle();
2877 }
2878 else hwndRelated = 0;
2879 }
2880 else hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
2881 break;
2882
2883 case GW_HWNDLAST:
2884 hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_BOTTOM);
2885 window = GetWindowFromOS2Handle(hwndRelated);
2886 if(window) {
2887 hwndRelated = window->getWindowHandle();
2888 }
2889 else hwndRelated = 0;
2890 break;
2891
2892 case GW_HWNDNEXT:
2893 hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_NEXT);
2894 window = GetWindowFromOS2Handle(hwndRelated);
2895 if(window) {
2896 hwndRelated = window->getWindowHandle();
2897 }
2898 else hwndRelated = 0;
2899 break;
2900
2901 case GW_HWNDPREV:
2902 hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_PREV);
2903 window = GetWindowFromOS2Handle(hwndRelated);
2904 if(window) {
2905 hwndRelated = window->getWindowHandle();
2906 }
2907 else hwndRelated = 0;
2908 break;
2909
2910 case GW_OWNER:
2911 if(getOwner()) {
2912 hwndRelated = getOwner()->getWindowHandle();
2913 }
2914 break;
2915
2916 case GW_CHILD:
2917 hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
2918 window = GetWindowFromOS2Handle(hwndRelated);
2919 if(window) {
2920 hwndRelated = window->getWindowHandle();
2921 }
2922 else hwndRelated = 0;
2923 break;
2924 }
2925#else
2926 switch(uCmd)
2927 {
2928 case GW_HWNDFIRST:
2929 if(getParent()) {
2930 window = (Win32BaseWindow *)getParent()->getFirstChild();
2931 hwndRelated = window->getWindowHandle();
2932 }
2933 break;
2934
2935 case GW_HWNDLAST:
2936 if(!getParent())
2937 {
2938 goto end;
2939 }
2940
2941 window = this;
2942 while(window->getNextChild())
2943 {
2944 window = (Win32BaseWindow *)window->getNextChild();
2945 }
2946 hwndRelated = window->getWindowHandle();
2947 break;
2948
2949 case GW_HWNDNEXT:
2950 window = (Win32BaseWindow *)getNextChild();
2951 if(window) {
2952 hwndRelated = window->getWindowHandle();
2953 }
2954 break;
2955
2956 case GW_HWNDPREV:
2957 if(!getParent())
2958 {
2959 goto end;
2960 }
2961 window = (Win32BaseWindow *)(getParent()->getFirstChild()); /* First sibling */
2962 if(window == this)
2963 {
2964 hwndRelated = 0; /* First in list */
2965 goto end;
2966 }
2967 while(window->getNextChild())
2968 {
2969 if (window->getNextChild() == this)
2970 {
2971 hwndRelated = window->getWindowHandle();
2972 goto end;
2973 }
2974 window = (Win32BaseWindow *)window->getNextChild();
2975 }
2976 break;
2977
2978 case GW_OWNER:
2979 if(getOwner()) {
2980 hwndRelated = getOwner()->getWindowHandle();
2981 }
2982 break;
2983
2984 case GW_CHILD:
2985 if(getFirstChild()) {
2986 hwndRelated = ((Win32BaseWindow *)getFirstChild())->getWindowHandle();
2987 }
2988 break;
2989 }
2990#endif
2991end:
2992 dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
2993 return hwndRelated;
2994}
2995//******************************************************************************
2996//******************************************************************************
2997HWND Win32BaseWindow::SetActiveWindow()
2998{
2999 HWND hwndActive;
3000
3001 dprintf(("SetActiveWindow %x", getWindowHandle()));
3002 if (HOOK_IsHooked( WH_CBT ))
3003 {
3004 CBTACTIVATESTRUCT cbta;
3005 LRESULT ret;
3006
3007 cbta.fMouse = FALSE;
3008 cbta.hWndActive = GetActiveWindow();
3009 ret = HOOK_CallHooksA(WH_CBT, HCBT_ACTIVATE, getWindowHandle(), (LPARAM)&cbta);
3010 if(ret)
3011 {
3012 dprintf(("SetActiveWindow %x, CBT hook cancelled operation", getWindowHandle()));
3013 return cbta.hWndActive;
3014 }
3015 }
3016 SetWindowPos(HWND_TOP, 0,0,0,0, SWP_NOSIZE | SWP_NOMOVE );
3017
3018// if(OSLibWinSetActiveWindow(OS2Hwnd) == FALSE) {
3019// dprintf(("OSLibWinSetActiveWindow %x returned FALSE!", OS2Hwnd));
3020// }
3021 hwndActive = GetActiveWindow();
3022 return (hwndActive) ? hwndActive : windowDesktop->getWindowHandle(); //pretend the desktop was active
3023}
3024//******************************************************************************
3025//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
3026//******************************************************************************
3027BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
3028{
3029 BOOL rc;
3030
3031 dprintf(("Win32BaseWindow::EnableWindow %x %d", getWindowHandle(), fEnable));
3032 //return true if previous state was disabled, else false (sdk docs)
3033 rc = (getStyle() & WS_DISABLED) != 0;
3034 if(rc && !fEnable) {
3035 SendMessageA(WM_CANCELMODE, 0, 0);
3036 }
3037 OSLibWinEnableWindow(OS2Hwnd, fEnable);
3038 if(fEnable == FALSE) {
3039 //SvL: No need to clear focus as PM already does this
3040 if(getWindowHandle() == GetCapture()) {
3041 ReleaseCapture(); /* A disabled window can't capture the mouse */
3042 dprintf(("Released capture for window %x that is being disabled", getWindowHandle()));
3043 }
3044 }
3045 return rc;
3046}
3047//******************************************************************************
3048//******************************************************************************
3049BOOL Win32BaseWindow::CloseWindow()
3050{
3051 return OSLibWinMinimizeWindow(OS2Hwnd);
3052}
3053//******************************************************************************
3054//TODO: Not be 100% correct; should return active window of current thread
3055// or NULL when there is none -> WinQueryActiveWindow just returns
3056// the current active window
3057//******************************************************************************
3058HWND Win32BaseWindow::GetActiveWindow()
3059{
3060 HWND hwndActive;
3061 Win32BaseWindow *win32wnd;
3062 ULONG magic;
3063
3064 hwndActive = OSLibWinQueryActiveWindow();
3065
3066 return OS2ToWin32Handle(hwndActive);
3067}
3068//******************************************************************************
3069//******************************************************************************
3070BOOL Win32BaseWindow::IsWindowEnabled()
3071{
3072 return OSLibWinIsWindowEnabled(OS2Hwnd);
3073}
3074//******************************************************************************
3075//******************************************************************************
3076BOOL Win32BaseWindow::IsWindowVisible()
3077{
3078 //TODO: Do we have to check the state of the parent window? (as Wine does)
3079#if 1
3080 return (dwStyle & WS_VISIBLE) == WS_VISIBLE;
3081#else
3082 return OSLibWinIsWindowVisible(OS2Hwnd);
3083#endif
3084}
3085//******************************************************************************
3086//******************************************************************************
3087BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
3088{
3089 INT len = GetWindowTextLength();
3090 BOOL res;
3091
3092 if (wndname == NULL)
3093 return (len == 0);
3094
3095 len++;
3096 if (fUnicode)
3097 {
3098 WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR));
3099
3100 GetWindowTextW(text,len);
3101 res = (lstrcmpW(text,(LPWSTR)wndname) == 0);
3102 free(text);
3103 } else
3104 {
3105 CHAR *text = (CHAR*)malloc(len*sizeof(CHAR));
3106
3107 GetWindowTextA(text,len);
3108 res = (strcmp(text,wndname) == 0);
3109 free(text);
3110 }
3111
3112 return res;
3113}
3114//******************************************************************************
3115//******************************************************************************
3116CHAR *Win32BaseWindow::getWindowNamePtrA()
3117{
3118 INT len = GetWindowTextLength();
3119 CHAR *text;
3120
3121 if (len == 0) return NULL;
3122 len++;
3123 text = (CHAR*)malloc(len*sizeof(CHAR));
3124 GetWindowTextA(text,len);
3125
3126 return text;
3127}
3128//******************************************************************************
3129//******************************************************************************
3130WCHAR *Win32BaseWindow::getWindowNamePtrW()
3131{
3132 INT len = GetWindowTextLength();
3133 WCHAR *text;
3134
3135 if (len == 0) return NULL;
3136 len++;
3137 text = (WCHAR*)malloc(len*sizeof(WCHAR));
3138 GetWindowTextW(text,len);
3139
3140 return text;
3141}
3142//******************************************************************************
3143//******************************************************************************
3144VOID Win32BaseWindow::freeWindowNamePtr(PVOID namePtr)
3145{
3146 if (namePtr) free(namePtr);
3147}
3148//******************************************************************************
3149//When using this API for a window that was created by a different process, NT
3150//does NOT send WM_GETTEXTLENGTH.
3151//******************************************************************************
3152int Win32BaseWindow::GetWindowTextLength()
3153{
3154 //if the destination window is created by this process, send message
3155 if(dwProcessId == currentProcessId) {
3156 return SendInternalMessageA(WM_GETTEXTLENGTH,0,0);
3157 }
3158 //else get data directory from window structure
3159 return wndNameLength;
3160}
3161//******************************************************************************
3162//When using this API for a window that was created by a different process, NT
3163//does NOT send WM_GETTEXT.
3164//******************************************************************************
3165int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
3166{
3167 //if the destination window is created by this process, send message
3168 if(dwProcessId == currentProcessId) {
3169 return SendInternalMessageA(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
3170 }
3171 //else get data directory from window structure
3172 if (!lpsz || !cch) return 0;
3173 if (!windowNameA) lpsz[0] = 0;
3174 else lstrcpynA(lpsz, windowNameA, cch);
3175 return min(wndNameLength, cch);
3176}
3177//******************************************************************************
3178//When using this API for a window that was created by a different process, NT
3179//does NOT send WM_GETTEXT.
3180//******************************************************************************
3181int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
3182{
3183 //if the destination window is created by this process, send message
3184 if(dwProcessId == currentProcessId) {
3185 return SendInternalMessageW(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
3186 }
3187 //else get data directory from window structure
3188 if (!lpsz || !cch) return 0;
3189 if (!windowNameW) lpsz[0] = 0;
3190 else lstrcpynW(lpsz, windowNameW, cch);
3191 return min(wndNameLength, cch);
3192}
3193//******************************************************************************
3194//TODO: How does this work when the target window belongs to a different process???
3195//******************************************************************************
3196BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
3197{
3198 return SendInternalMessageA(WM_SETTEXT,0,(LPARAM)lpsz);
3199}
3200//******************************************************************************
3201//******************************************************************************
3202BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
3203{
3204 return SendInternalMessageW(WM_SETTEXT,0,(LPARAM)lpsz);
3205}
3206//******************************************************************************
3207//******************************************************************************
3208LONG Win32BaseWindow::SetWindowLongA(int index, ULONG value, BOOL fUnicode)
3209{
3210 LONG oldval;
3211
3212 switch(index) {
3213 case GWL_EXSTYLE:
3214 {
3215 STYLESTRUCT ss;
3216
3217 if(dwExStyle == value) {
3218 oldval = value;
3219 break;
3220 }
3221 ss.styleOld = dwExStyle;
3222 ss.styleNew = value;
3223 dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
3224 SendInternalMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
3225 setExStyle(ss.styleNew);
3226 SendInternalMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
3227 oldval = ss.styleOld;
3228 break;
3229 }
3230 case GWL_STYLE:
3231 {
3232 STYLESTRUCT ss;
3233
3234 //SvL: TODO: Can you change minimize or maximize status here too?
3235
3236 if(dwStyle == value) {
3237 oldval = value;
3238 break;
3239 }
3240 value &= ~(WS_CHILD|WS_VISIBLE); /* Some bits can't be changed this way (WINE) */
3241 ss.styleOld = getStyle();
3242 ss.styleNew = value | (ss.styleOld & (WS_CHILD|WS_VISIBLE));
3243 dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), ss.styleOld, ss.styleNew));
3244 SendInternalMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
3245 setStyle(ss.styleNew);
3246 SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
3247//// OSLibSetWindowStyle(getOS2WindowHandle(), getStyle(), getExStyle(),
3248//// windowClass->getStyle() & CS_SAVEBITS);
3249#ifdef DEBUG
3250 PrintWindowStyle(ss.styleNew, 0);
3251#endif
3252 oldval = ss.styleOld;
3253 break;
3254 }
3255 case GWL_WNDPROC:
3256 {
3257 //Note: Type of SetWindowLong determines new window proc type
3258 // UNLESS the new window proc has already been registered
3259 // (use the old type in that case)
3260 // (VERIFIED in NT 4, SP6)
3261 WINDOWPROCTYPE type = WINPROC_GetProcType((HWINDOWPROC)value);
3262 if(type == WIN_PROC_INVALID) {
3263 type = (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A;
3264 }
3265 oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
3266 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, type, WIN_PROC_WINDOW);
3267 break;
3268 }
3269 case GWL_HINSTANCE:
3270 oldval = hInstance;
3271 hInstance = value;
3272 break;
3273
3274 case GWL_HWNDPARENT:
3275 oldval = SetParent((HWND)value);
3276 break;
3277
3278 case GWL_ID:
3279 oldval = getWindowId();
3280 setWindowId(value);
3281 break;
3282
3283 case GWL_USERDATA:
3284 oldval = userData;
3285 userData = value;
3286 break;
3287
3288 default:
3289 if(index >= 0 && index/4 < nrUserWindowLong)
3290 {
3291 oldval = userWindowLong[index/4];
3292 userWindowLong[index/4] = value;
3293 break;
3294 }
3295 dprintf(("WARNING: SetWindowLong%c %x %d %x returned %x INVALID index!", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
3296 SetLastError(ERROR_INVALID_PARAMETER);
3297 return 0;
3298 }
3299 SetLastError(ERROR_SUCCESS);
3300 dprintf2(("SetWindowLong%c %x %d %x returned %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value, oldval));
3301 return oldval;
3302}
3303//******************************************************************************
3304//******************************************************************************
3305ULONG Win32BaseWindow::GetWindowLongA(int index, BOOL fUnicode)
3306{
3307 ULONG value;
3308
3309 switch(index) {
3310 case GWL_EXSTYLE:
3311 value = dwExStyle;
3312 break;
3313 case GWL_STYLE:
3314 value = dwStyle;
3315 break;
3316 case GWL_WNDPROC:
3317 value = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
3318 break;
3319 case GWL_HINSTANCE:
3320 value = hInstance;
3321 break;
3322 case GWL_HWNDPARENT:
3323 value = GetParent();
3324 break;
3325 case GWL_ID:
3326 value = getWindowId();
3327 break;
3328 case GWL_USERDATA:
3329 value = userData;
3330 break;
3331 default:
3332 if(index >= 0 && index/4 < nrUserWindowLong)
3333 {
3334 value = userWindowLong[index/4];
3335 break;
3336 }
3337 SetLastError(ERROR_INVALID_PARAMETER);
3338 return 0;
3339 }
3340 dprintf2(("GetWindowLongA %x %d %x", getWindowHandle(), index, value));
3341 return value;
3342}
3343//******************************************************************************
3344//******************************************************************************
3345WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
3346{
3347 WORD oldval;
3348
3349 if(index >= 0 && index/4 < nrUserWindowLong)
3350 {
3351 oldval = ((WORD *)userWindowLong)[index/2];
3352 ((WORD *)userWindowLong)[index/2] = value;
3353 return oldval;
3354 }
3355 SetLastError(ERROR_INVALID_PARAMETER);
3356 return 0;
3357}
3358//******************************************************************************
3359//******************************************************************************
3360WORD Win32BaseWindow::GetWindowWord(int index)
3361{
3362 if(index >= 0 && index/4 < nrUserWindowLong)
3363 {
3364 return ((WORD *)userWindowLong)[index/2];
3365 }
3366 SetLastError(ERROR_INVALID_PARAMETER);
3367 return 0;
3368}
3369//******************************************************************************
3370//******************************************************************************
3371void Win32BaseWindow::setWindowId(DWORD id)
3372{
3373 dwIDMenu = id;
3374}
3375//******************************************************************************
3376//******************************************************************************
3377Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
3378{
3379 Win32BaseWindow *window;
3380
3381 if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
3382 return window;
3383 }
3384// dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
3385 return NULL;
3386}
3387//******************************************************************************
3388//******************************************************************************
3389Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd)
3390{
3391 Win32BaseWindow *win32wnd;
3392 DWORD magic;
3393
3394 if(hwnd == OSLIB_HWND_DESKTOP)
3395 {
3396 return windowDesktop;
3397 }
3398
3399 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
3400 magic = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
3401
3402 if(win32wnd && CheckMagicDword(magic)) {
3403 return win32wnd;
3404 }
3405// dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwnd));
3406 return 0;
3407}
3408//******************************************************************************
3409//******************************************************************************
3410HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd)
3411{
3412 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
3413
3414 if(window) {
3415 return window->getOS2WindowHandle();
3416 }
3417// dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
3418 return hwnd;
3419}
3420//******************************************************************************
3421//******************************************************************************
3422HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd)
3423{
3424 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
3425
3426 if(window) {
3427 return window->getWindowHandle();
3428 }
3429// dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
3430 return 0;
3431// else return hwnd; //OS/2 window handle
3432}
3433//******************************************************************************
3434//******************************************************************************
3435HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
3436{
3437 Win32BaseWindow *child, *nextchild, *lastchild;
3438 HWND retvalue;
3439
3440 if (hwndCtrl)
3441 {
3442 child = GetWindowFromHandle(hwndCtrl);
3443 if (!child)
3444 {
3445 retvalue = 0;
3446 goto END;
3447 }
3448 /* Make sure hwndCtrl is a top-level child */
3449 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
3450 {
3451 child = child->getParent();
3452 if(child == NULL) break;
3453 }
3454
3455 if (!child || (child->getParent() != this))
3456 {
3457 retvalue = 0;
3458 goto END;
3459 }
3460 }
3461 else
3462 {
3463 /* No ctrl specified -> start from the beginning */
3464 child = (Win32BaseWindow *)getFirstChild();
3465 if (!child)
3466 {
3467 retvalue = 0;
3468 goto END;
3469 }
3470
3471 if (!fPrevious)
3472 {
3473 while (child->getNextChild())
3474 {
3475 child = (Win32BaseWindow *)child->getNextChild();
3476 }
3477 }
3478 }
3479
3480 lastchild = child;
3481 nextchild = (Win32BaseWindow *)child->getNextChild();
3482 while (TRUE)
3483 {
3484 if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild();
3485
3486 if (child == nextchild) break;
3487
3488 if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) &&
3489 !(nextchild->getStyle() & WS_DISABLED))
3490 {
3491 lastchild = nextchild;
3492 if (!fPrevious) break;
3493 }
3494 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
3495 }
3496 retvalue = lastchild->getWindowHandle();
3497
3498END:
3499 return retvalue;
3500}
3501//******************************************************************************
3502//******************************************************************************
3503HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
3504{
3505 Win32BaseWindow *child, *nextchild, *lastchild;
3506 HWND retvalue;
3507
3508 if (hwndCtrl)
3509 {
3510 child = GetWindowFromHandle(hwndCtrl);
3511 if (!child)
3512 {
3513 retvalue = 0;
3514 goto END;
3515 }
3516 /* Make sure hwndCtrl is a top-level child */
3517 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
3518 {
3519 child = child->getParent();
3520 if(child == NULL) break;
3521 }
3522
3523 if (!child || (child->getParent() != this))
3524 {
3525 retvalue = 0;
3526 goto END;
3527 }
3528 }
3529 else
3530 {
3531 /* No ctrl specified -> start from the beginning */
3532 child = (Win32BaseWindow *)getFirstChild();
3533 if (!child)
3534 {
3535 retvalue = 0;
3536 goto END;
3537 }
3538
3539 if (fPrevious)
3540 {
3541 while (child->getNextChild())
3542 {
3543 child = (Win32BaseWindow *)child->getNextChild();
3544 }
3545 }
3546 }
3547
3548 lastchild = child;
3549 nextchild = (Win32BaseWindow *)child->getNextChild();
3550 while (TRUE)
3551 {
3552 if (!nextchild || (nextchild->getStyle() & WS_GROUP))
3553 {
3554 /* Wrap-around to the beginning of the group */
3555 Win32BaseWindow *pWndTemp;
3556
3557 nextchild = (Win32BaseWindow *)getFirstChild();
3558
3559 for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild())
3560 {
3561 if (pWndTemp->getStyle() & WS_GROUP)
3562 nextchild = pWndTemp;
3563
3564 if (pWndTemp == child)
3565 break;
3566 }
3567
3568 }
3569 if (nextchild == child)
3570 break;
3571
3572 if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED))
3573 {
3574 lastchild = nextchild;
3575
3576 if (!fPrevious)
3577 break;
3578 }
3579
3580 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
3581 }
3582 retvalue = lastchild->getWindowHandle();
3583END:
3584 return retvalue;
3585}
3586//******************************************************************************
3587//******************************************************************************
3588#ifdef DEBUG
3589void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
3590{
3591 char style[256] = "";
3592 char exstyle[256] = "";
3593
3594 /* Window styles */
3595 if(dwStyle & WS_CHILD)
3596 strcat(style, "WS_CHILD ");
3597 if(dwStyle & WS_POPUP)
3598 strcat(style, "WS_POPUP ");
3599 if(dwStyle & WS_VISIBLE)
3600 strcat(style, "WS_VISIBLE ");
3601 if(dwStyle & WS_DISABLED)
3602 strcat(style, "WS_DISABLED ");
3603 if(dwStyle & WS_CLIPSIBLINGS)
3604 strcat(style, "WS_CLIPSIBLINGS ");
3605 if(dwStyle & WS_CLIPCHILDREN)
3606 strcat(style, "WS_CLIPCHILDREN ");
3607 if(dwStyle & WS_MAXIMIZE)
3608 strcat(style, "WS_MAXIMIZE ");
3609 if(dwStyle & WS_MINIMIZE)
3610 strcat(style, "WS_MINIMIZE ");
3611 if(dwStyle & WS_GROUP)
3612 strcat(style, "WS_GROUP ");
3613 if(dwStyle & WS_TABSTOP)
3614 strcat(style, "WS_TABSTOP ");
3615
3616 if((dwStyle & WS_CAPTION) == WS_CAPTION)
3617 strcat(style, "WS_CAPTION ");
3618 if(dwStyle & WS_DLGFRAME)
3619 strcat(style, "WS_DLGFRAME ");
3620 if(dwStyle & WS_BORDER)
3621 strcat(style, "WS_BORDER ");
3622
3623 if(dwStyle & WS_VSCROLL)
3624 strcat(style, "WS_VSCROLL ");
3625 if(dwStyle & WS_HSCROLL)
3626 strcat(style, "WS_HSCROLL ");
3627 if(dwStyle & WS_SYSMENU)
3628 strcat(style, "WS_SYSMENU ");
3629 if(dwStyle & WS_THICKFRAME)
3630 strcat(style, "WS_THICKFRAME ");
3631 if(dwStyle & WS_MINIMIZEBOX)
3632 strcat(style, "WS_MINIMIZEBOX ");
3633 if(dwStyle & WS_MAXIMIZEBOX)
3634 strcat(style, "WS_MAXIMIZEBOX ");
3635
3636 if(dwExStyle & WS_EX_DLGMODALFRAME)
3637 strcat(exstyle, "WS_EX_DLGMODALFRAME ");
3638 if(dwExStyle & WS_EX_ACCEPTFILES)
3639 strcat(exstyle, "WS_EX_ACCEPTFILES ");
3640 if(dwExStyle & WS_EX_NOPARENTNOTIFY)
3641 strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
3642 if(dwExStyle & WS_EX_TOPMOST)
3643 strcat(exstyle, "WS_EX_TOPMOST ");
3644 if(dwExStyle & WS_EX_TRANSPARENT)
3645 strcat(exstyle, "WS_EX_TRANSPARENT ");
3646
3647 if(dwExStyle & WS_EX_MDICHILD)
3648 strcat(exstyle, "WS_EX_MDICHILD ");
3649 if(dwExStyle & WS_EX_TOOLWINDOW)
3650 strcat(exstyle, "WS_EX_TOOLWINDOW ");
3651 if(dwExStyle & WS_EX_WINDOWEDGE)
3652 strcat(exstyle, "WS_EX_WINDOWEDGE ");
3653 if(dwExStyle & WS_EX_CLIENTEDGE)
3654 strcat(exstyle, "WS_EX_CLIENTEDGE ");
3655 if(dwExStyle & WS_EX_CONTEXTHELP)
3656 strcat(exstyle, "WS_EX_CONTEXTHELP ");
3657 if(dwExStyle & WS_EX_RIGHT)
3658 strcat(exstyle, "WS_EX_RIGHT ");
3659 if(dwExStyle & WS_EX_LEFT)
3660 strcat(exstyle, "WS_EX_LEFT ");
3661 if(dwExStyle & WS_EX_RTLREADING)
3662 strcat(exstyle, "WS_EX_RTLREADING ");
3663 if(dwExStyle & WS_EX_LTRREADING)
3664 strcat(exstyle, "WS_EX_LTRREADING ");
3665 if(dwExStyle & WS_EX_LEFTSCROLLBAR)
3666 strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
3667 if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
3668 strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
3669 if(dwExStyle & WS_EX_CONTROLPARENT)
3670 strcat(exstyle, "WS_EX_CONTROLPARENT ");
3671 if(dwExStyle & WS_EX_STATICEDGE)
3672 strcat(exstyle, "WS_EX_STATICEDGE ");
3673 if(dwExStyle & WS_EX_APPWINDOW)
3674 strcat(exstyle, "WS_EX_APPWINDOW ");
3675
3676 dprintf(("Window style: %x %s", dwStyle, style));
3677 dprintf(("Window exStyle: %x %s", dwExStyle, exstyle));
3678}
3679#endif
3680//******************************************************************************
3681//******************************************************************************
3682
3683GenericObject *Win32BaseWindow::windows = NULL;
Note: See TracBrowser for help on using the repository browser.