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

Last change on this file since 2668 was 2668, checked in by cbratschi, 26 years ago

ported WinHelpA from WINE

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