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

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

kdb hook change

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