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

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

fixed CW_USEDEFAULT

File size: 103.1 KB
Line 
1/* $Id: win32wbase.cpp,v 1.158 2000-02-07 20:32:42 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 hClipRegion = 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(isOwnDC())
183 releaseOwnDC(ownDC);
184
185 if(Win32Hwnd)
186 HwFreeWindowHandle(Win32Hwnd);
187
188 if(userWindowLong)
189 free(userWindowLong);
190
191 if(windowNameA) {
192 free(windowNameA);
193 windowNameA = NULL;
194 }
195 if(windowNameW) {
196 free(windowNameW);
197 windowNameW = NULL;
198 }
199 if(vertScrollInfo) {
200 free(vertScrollInfo);
201 vertScrollInfo = NULL;
202 }
203 if(horzScrollInfo) {
204 free(horzScrollInfo);
205 horzScrollInfo = NULL;
206 }
207}
208//******************************************************************************
209//******************************************************************************
210void Win32BaseWindow::DestroyAll()
211{
212 fDestroyAll = TRUE;
213 GenericObject::DestroyAll(windows);
214}
215//******************************************************************************
216//******************************************************************************
217BOOL Win32BaseWindow::isChild()
218{
219 return ((dwStyle & WS_CHILD) != 0);
220}
221//******************************************************************************
222//******************************************************************************
223BOOL Win32BaseWindow::IsWindowUnicode()
224{
225 dprintf2(("IsWindowUnicode %x %d", getWindowHandle(), WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W));
226 return (WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W);
227}
228//******************************************************************************
229//******************************************************************************
230BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom)
231{
232 char buffer[256];
233
234#ifdef DEBUG
235 PrintWindowStyle(cs->style, cs->dwExStyle);
236#endif
237
238 sw = SW_SHOW;
239 SetLastError(0);
240
241 /* Find the parent window */
242 if (cs->hwndParent)
243 {
244 Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
245 if(!window) {
246 dprintf(("Bad parent %04x\n", cs->hwndParent ));
247 SetLastError(ERROR_INVALID_PARAMETER);
248 return FALSE;
249 }
250 /* Make sure parent is valid */
251 if (!window->IsWindow() )
252 {
253 dprintf(("Bad parent %04x\n", cs->hwndParent ));
254 SetLastError(ERROR_INVALID_PARAMETER);
255 return FALSE;
256 }
257 }
258 else
259 if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
260 dprintf(("No parent for child window\n" ));
261 SetLastError(ERROR_INVALID_PARAMETER);
262 return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
263 }
264
265 /* Find the window class */
266 windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
267 if (!windowClass)
268 {
269 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
270 dprintf(("Bad class '%s'\n", buffer ));
271 SetLastError(ERROR_INVALID_PARAMETER);
272 return 0;
273 }
274#ifdef DEBUG
275 if(HIWORD(cs->lpszClass))
276 {
277 char *astring;
278
279 if(isUnicode) astring = UnicodeToAsciiString((LPWSTR)cs->lpszClass);
280 else astring = (char *)cs->lpszClass;
281
282 dprintf(("Window class %s", astring));
283 if(isUnicode) FreeAsciiString(astring);
284 }
285 else dprintf(("Window class %x", cs->lpszClass));
286#endif
287
288 /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
289 * with an atom as the class name, put some programs expect to have a *REAL* string in
290 * lpszClass when the CREATESTRUCT is sent with WM_CREATE
291 */
292 if (!HIWORD(cs->lpszClass) ) {
293 if (isUnicode) {
294 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
295 }
296 else {
297 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
298 }
299 cs->lpszClass = buffer;
300 }
301
302 /* Fix the coordinates */
303 fXDefault = FALSE;
304 fCXDefault = FALSE;
305 if ((cs->x == CW_USEDEFAULT) || (cs->x == CW_USEDEFAULT16))
306 {
307 /* Never believe Microsoft's documentation... CreateWindowEx doc says
308 * that if an overlapped window is created with WS_VISIBLE style bit
309 * set and the x parameter is set to CW_USEDEFAULT, the system ignores
310 * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
311 * reveals that
312 *
313 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
314 * 2) it does not ignore the y parameter as the docs claim; instead, it
315 * uses it as second parameter to ShowWindow() unless y is either
316 * CW_USEDEFAULT or CW_USEDEFAULT16.
317 *
318 * The fact that we didn't do 2) caused bogus windows pop up when wine
319 * was running apps that were using this obscure feature. Example -
320 * calc.exe that comes with Win98 (only Win98, it's different from
321 * the one that comes with Win95 and NT)
322 */
323 if ((cs->y != CW_USEDEFAULT) && (cs->y != CW_USEDEFAULT16)) sw = cs->y;
324
325 /* We have saved cs->y, now we can trash it */
326 cs->x = 0;
327 cs->y = 0;
328 fXDefault = TRUE;
329 }
330 if ((cs->cx == CW_USEDEFAULT) || (cs->cx == CW_USEDEFAULT16))
331 {
332 cs->cx = 600; /* FIXME */
333 cs->cy = 400;
334 fCXDefault = TRUE;
335 }
336 if (fXDefault && !fCXDefault) fXDefault = FALSE; //CB: only x positioning doesn't work (calc.exe,cdrlabel.exe)
337
338 if (cs->x < 0) cs->x = 0;
339 if (cs->y < 0) cs->y = 0;
340
341 //Allocate window words
342 nrUserWindowLong = windowClass->getExtraWndWords();
343 if(nrUserWindowLong) {
344 userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
345 memset(userWindowLong, 0, nrUserWindowLong);
346 }
347
348 if ((cs->style & WS_CHILD) && cs->hwndParent)
349 {
350 SetParent(cs->hwndParent);
351 owner = GetWindowFromHandle(cs->hwndParent);
352 if(owner == NULL)
353 {
354 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
355 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
356 return FALSE;
357 }
358 }
359 else
360 {
361 SetParent(0);
362 if (!cs->hwndParent || (cs->hwndParent == windowDesktop->getWindowHandle())) {
363 owner = NULL;
364 }
365 else
366 {
367 owner = GetWindowFromHandle(cs->hwndParent)->GetTopParent();
368 if(owner == NULL)
369 {
370 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
371 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
372 return FALSE;
373 }
374 }
375 }
376
377 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc(), WINPROC_GetProcType(windowClass->getWindowProc()), WIN_PROC_WINDOW);
378 hInstance = cs->hInstance;
379 dwStyle = cs->style & ~WS_VISIBLE;
380 dwExStyle = cs->dwExStyle;
381
382 hwndLinkAfter = HWND_TOP;
383 if(CONTROLS_IsControl(this, BUTTON_CONTROL) && ((dwStyle & 0x0f) == BS_GROUPBOX))
384 {
385 hwndLinkAfter = HWND_BOTTOM;
386 dwStyle |= WS_CLIPSIBLINGS;
387 }
388 else
389 if(CONTROLS_IsControl(this, STATIC_CONTROL) && !(dwStyle & WS_GROUP)) {
390 dwStyle |= WS_CLIPSIBLINGS;
391 }
392
393 /* Increment class window counter */
394 windowClass->IncreaseWindowCount();
395
396 if (HOOK_IsHooked( WH_CBT ))
397 {
398 CBT_CREATEWNDA cbtc;
399 LRESULT ret;
400
401 cbtc.lpcs = cs;
402 cbtc.hwndInsertAfter = hwndLinkAfter;
403 ret = HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc);
404 if(ret)
405 {
406 dprintf(("CBT-hook returned 0!!"));
407 SetLastError(ERROR_CAN_NOT_COMPLETE); //todo: wrong error
408 return FALSE;
409 }
410 }
411
412 /* Correct the window style */
413 if (!(cs->style & WS_CHILD))
414 {
415 dwStyle |= WS_CLIPSIBLINGS;
416 if (!(cs->style & WS_POPUP))
417 {
418 dwStyle |= WS_CAPTION;
419 flags |= WIN_NEED_SIZE;
420 }
421 }
422 if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
423
424 if (cs->style & WS_HSCROLL)
425 {
426 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
427 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
428 horzScrollInfo->MaxVal = 100;
429 horzScrollInfo->flags = ESB_ENABLE_BOTH;
430 }
431
432 if (cs->style & WS_VSCROLL)
433 {
434 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
435 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
436 vertScrollInfo->MaxVal = 100;
437 vertScrollInfo->flags = ESB_ENABLE_BOTH;
438 }
439
440 if(HIWORD(cs->lpszName))
441 {
442 if (!isUnicode)
443 {
444 wndNameLength = strlen(cs->lpszName);
445 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
446 strcpy(windowNameA,cs->lpszName);
447 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
448 lstrcpyAtoW(windowNameW,windowNameA);
449 windowNameA[wndNameLength] = 0;
450 windowNameW[wndNameLength] = 0;
451 }
452 else
453 {
454 wndNameLength = lstrlenW((LPWSTR)cs->lpszName);
455 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
456 lstrcpyWtoA(windowNameA,(LPWSTR)cs->lpszName);
457 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
458 lstrcpyW(windowNameW,(LPWSTR)cs->lpszName);
459 windowNameA[wndNameLength] = 0;
460 windowNameW[wndNameLength] = 0;
461 }
462 }
463
464 //copy pointer of CREATESTRUCT for usage in MsgCreate method
465 tmpcs = cs;
466
467 //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it
468 THDB *thdb = GetThreadTHDB();
469
470 if(thdb == NULL) {
471 dprintf(("Window creation failed - thdb == NULL")); //this is VERY bad
472 ExitProcess(666);
473 return FALSE;
474 }
475
476 thdb->newWindow = (ULONG)this;
477
478 DWORD dwOSWinStyle;
479
480 OSLibWinConvertStyle(dwStyle,dwExStyle,&dwOSWinStyle);
481 if (((dwStyle & (WS_CAPTION | WS_SYSMENU | 0xC0000000)) == (WS_CAPTION | WS_SYSMENU))) fTaskList = TRUE;
482
483 OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
484 dwOSWinStyle,(char *)windowNameA,
485 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
486 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
487 &OS2HwndFrame, 0, fTaskList,fXDefault | fCXDefault,windowClass->getStyle() & CS_SAVEBITS);
488 if(OS2Hwnd == 0) {
489 dprintf(("Window creation failed!!"));
490 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
491 return FALSE;
492 }
493
494 SetLastError(0);
495 return TRUE;
496}
497//******************************************************************************
498//******************************************************************************
499BOOL Win32BaseWindow::MsgCreate(HWND hwndFrame, HWND hwndClient)
500{
501 CREATESTRUCTA *cs = tmpcs; //pointer to CREATESTRUCT used in CreateWindowExA method
502 POINT maxSize, maxPos, minTrack, maxTrack;
503
504 OS2Hwnd = hwndClient;
505 OS2HwndFrame = hwndFrame;
506
507 fNoSizeMsg = TRUE;
508
509 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
510 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
511 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
512 return FALSE;
513 }
514 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
515 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
516 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
517 return FALSE;
518 }
519
520 //adjust CW_USEDEFAULT position
521 if (fXDefault | fCXDefault)
522 {
523 RECT rect;
524
525 OSLibWinQueryWindowRect(OS2HwndFrame,&rect,RELATIVE_TO_SCREEN);
526 if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rect);
527 if (fXDefault)
528 {
529 cs->x = rect.left;
530 cs->y = rect.top;
531 if (!fCXDefault)
532 {
533 //CB: todo: adjust pos to screen rect
534 }
535 }
536 if (fCXDefault)
537 {
538 cs->cx = rect.right-rect.left;
539 cs->cy = rect.bottom-rect.top;
540 }
541 }
542
543 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
544 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
545 {
546 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
547 if (maxSize.x < cs->cx) cs->cx = maxSize.x;
548 if (maxSize.y < cs->cy) cs->cy = maxSize.y;
549 if (cs->cx < minTrack.x) cs->cx = minTrack.x;
550 if (cs->cy < minTrack.y) cs->cy = minTrack.y;
551 }
552
553 if(cs->style & WS_CHILD)
554 {
555 if(cs->cx < 0) cs->cx = 0;
556 if(cs->cy < 0) cs->cy = 0;
557 }
558 else
559 {
560 if (cs->cx <= 0) cs->cx = 1;
561 if (cs->cy <= 0) cs->cy = 1;
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 = GetDC(getWindowHandle()); //TODO: or GetWindowDC???
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 dprintf(("MsgNCPaint (%d,%d)(%d,%d)", rect.left, rect.top, rect.right, rect.bottom));
1031 hrgn = CreateRectRgnIndirect(&rect);
1032 if (!hrgn) return 0;
1033 rc = SendInternalMessageA(WM_NCPAINT,hrgn,0);
1034 DeleteObject(hrgn);
1035
1036 return rc;
1037 }
1038 else return 0;
1039}
1040//******************************************************************************
1041//Called when either the frame's size or position has changed (lpWndPos != NULL)
1042//or when the frame layout has changed (i.e. scrollbars added/removed) (lpWndPos == NULL)
1043//******************************************************************************
1044ULONG Win32BaseWindow::MsgFormatFrame(WINDOWPOS *lpWndPos)
1045{
1046 RECT oldWindowRect = rectWindow, client = rectClient, newWindowRect;
1047 WINDOWPOS wndPos;
1048 ULONG rc;
1049
1050 if(lpWndPos)
1051 {
1052 POINT point;
1053
1054 //set new window rectangle
1055 point.x = lpWndPos->x;
1056 point.y = lpWndPos->y;
1057 if (getParent()) ClientToScreen(getParent()->getWindowHandle(),&point);
1058
1059 setWindowRect(point.x,point.y,point.x+lpWndPos->cx,point.y+lpWndPos->cy);
1060 newWindowRect = rectWindow;
1061 }
1062 else {
1063 wndPos.hwnd = getWindowHandle();
1064 wndPos.hwndInsertAfter = 0;
1065 newWindowRect= rectWindow;
1066 if (getParent()) {
1067 mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&newWindowRect);
1068 }
1069 wndPos.x = newWindowRect.left;
1070 wndPos.y = newWindowRect.top;
1071 wndPos.cx = newWindowRect.right - newWindowRect.left;
1072 wndPos.cy = newWindowRect.bottom - newWindowRect.top;
1073 wndPos.flags = SWP_FRAMECHANGED;
1074 lpWndPos = &wndPos;
1075
1076 if (getParent()) {
1077 newWindowRect= rectWindow; //reset; was modified
1078 }
1079 }
1080
1081 rc = SendNCCalcSize(TRUE, &newWindowRect, &oldWindowRect, &client, lpWndPos, &rectClient);
1082
1083 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));
1084 return rc;
1085}
1086//******************************************************************************
1087//******************************************************************************
1088ULONG Win32BaseWindow::MsgSetText(LPSTR lpsz, LONG cch)
1089{
1090 return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
1091}
1092//******************************************************************************
1093//******************************************************************************
1094ULONG Win32BaseWindow::MsgGetTextLength()
1095{
1096 return SendInternalMessageA(WM_GETTEXTLENGTH, 0, 0);
1097}
1098//******************************************************************************
1099//******************************************************************************
1100void Win32BaseWindow::MsgGetText(char *wndtext, ULONG textlength)
1101{
1102 SendInternalMessageA(WM_GETTEXT, textlength, (LPARAM)wndtext);
1103}
1104//******************************************************************************
1105//******************************************************************************
1106BOOL Win32BaseWindow::isMDIClient()
1107{
1108 return FALSE;
1109}
1110//******************************************************************************
1111//******************************************************************************
1112BOOL Win32BaseWindow::isMDIChild()
1113{
1114 return FALSE;
1115}
1116//******************************************************************************
1117//TODO: Not complete
1118//******************************************************************************
1119BOOL Win32BaseWindow::isFrameWindow()
1120{
1121// if(isMDIChild() || IsDialog() || (getParent() == NULL || getParent() == windowDesktop) && ((dwStyle & WS_CAPTION) == WS_CAPTION))
1122 if((dwStyle & WS_CAPTION) == WS_CAPTION || dwStyle & (WS_VSCROLL|WS_HSCROLL))
1123 return TRUE;
1124
1125 return FALSE;
1126}
1127//******************************************************************************
1128//******************************************************************************
1129SCROLLBAR_INFO *Win32BaseWindow::getScrollInfo(int nBar)
1130{
1131 switch(nBar)
1132 {
1133 case SB_HORZ:
1134 if (!horzScrollInfo)
1135 {
1136 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
1137 if (!horzScrollInfo) break;
1138 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
1139 horzScrollInfo->MaxVal = 100;
1140 horzScrollInfo->flags = ESB_ENABLE_BOTH;
1141 }
1142 return horzScrollInfo;
1143
1144 case SB_VERT:
1145 if (!vertScrollInfo)
1146 {
1147 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
1148 if (!vertScrollInfo) break;
1149 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
1150 vertScrollInfo->MaxVal = 100;
1151 vertScrollInfo->flags = ESB_ENABLE_BOTH;
1152 }
1153 return vertScrollInfo;
1154 }
1155
1156 return NULL;
1157}
1158//******************************************************************************
1159//******************************************************************************
1160LRESULT Win32BaseWindow::DefWndControlColor(UINT ctlType, HDC hdc)
1161{
1162 //SvL: Set background color to default button color (not window (white))
1163 if(ctlType == CTLCOLOR_BTN)
1164 {
1165 SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
1166 SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
1167 return GetSysColorBrush(COLOR_BTNFACE);
1168 }
1169 //SvL: Set background color to default dialog color if window is dialog
1170 if((ctlType == CTLCOLOR_DLG || ctlType == CTLCOLOR_STATIC) && IsDialog()) {
1171 SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
1172 SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
1173 return GetSysColorBrush(COLOR_BTNFACE);
1174 }
1175
1176 if( ctlType == CTLCOLOR_SCROLLBAR)
1177 {
1178 HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
1179 COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
1180 SetTextColor( hdc, GetSysColor(COLOR_3DFACE));
1181 SetBkColor( hdc, bk);
1182
1183//TODO?
1184#if 0
1185 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
1186 * we better use 0x55aa bitmap brush to make scrollbar's background
1187 * look different from the window background.
1188 */
1189 if (bk == GetSysColor(COLOR_WINDOW)) {
1190 return CACHE_GetPattern55AABrush();
1191 }
1192#endif
1193 UnrealizeObject( hb );
1194 return (LRESULT)hb;
1195 }
1196
1197 SetTextColor( hdc, GetSysColor(COLOR_WINDOWTEXT));
1198
1199 if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
1200 {
1201 SetBkColor( hdc, GetSysColor(COLOR_WINDOW) );
1202 }
1203 else
1204 {
1205 SetBkColor( hdc, GetSysColor(COLOR_3DFACE) );
1206 return (LRESULT)GetSysColorBrush(COLOR_3DFACE);
1207 }
1208 return (LRESULT)GetSysColorBrush(COLOR_WINDOW);
1209}
1210//******************************************************************************
1211//******************************************************************************
1212LRESULT Win32BaseWindow::DefWndPrint(HDC hdc,ULONG uFlags)
1213{
1214 /*
1215 * Visibility flag.
1216 */
1217 if ( (uFlags & PRF_CHECKVISIBLE) &&
1218 !IsWindowVisible() )
1219 return 0;
1220
1221 /*
1222 * Unimplemented flags.
1223 */
1224 if ( (uFlags & PRF_CHILDREN) ||
1225 (uFlags & PRF_OWNED) ||
1226 (uFlags & PRF_NONCLIENT) )
1227 {
1228 dprintf(("WM_PRINT message with unsupported flags\n"));
1229 }
1230
1231 /*
1232 * Background
1233 */
1234 if ( uFlags & PRF_ERASEBKGND)
1235 SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
1236
1237 /*
1238 * Client area
1239 */
1240 if ( uFlags & PRF_CLIENT)
1241 SendInternalMessageA(WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
1242
1243
1244 return 0;
1245}
1246//******************************************************************************
1247//******************************************************************************
1248LRESULT Win32BaseWindow::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam)
1249{
1250 switch(Msg)
1251 {
1252 case WM_CLOSE:
1253 dprintf(("DefWindowProcA: WM_CLOSE %x", getWindowHandle()));
1254 DestroyWindow();
1255 return 0;
1256
1257 case WM_GETTEXTLENGTH:
1258 return wndNameLength;
1259
1260 case WM_GETTEXT:
1261 if (!lParam || !wParam) return 0;
1262 if (!windowNameA) ((LPSTR)lParam)[0] = 0;
1263 else lstrcpynA((LPSTR)lParam, windowNameA, wParam);
1264 return min(wndNameLength, wParam);
1265
1266 case WM_SETTEXT:
1267 {
1268 LPCSTR lpsz = (LPCSTR)lParam;
1269
1270 if(windowNameA) free(windowNameA);
1271 if(windowNameW) free(windowNameW);
1272 if (lParam)
1273 {
1274 wndNameLength = strlen(lpsz);
1275 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
1276 strcpy(windowNameA, lpsz);
1277 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
1278 lstrcpyAtoW(windowNameW, windowNameA);
1279 }
1280 else
1281 {
1282 windowNameA = NULL;
1283 windowNameW = NULL;
1284 wndNameLength = 0;
1285 }
1286 dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, lParam));
1287 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
1288 {
1289 HandleNCPaint((HRGN)1);
1290 OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
1291 }
1292
1293 return TRUE;
1294 }
1295
1296 case WM_SETREDRAW:
1297 {
1298 if (wParam)
1299 {
1300 setStyle(getStyle() | WS_VISIBLE);
1301 OSLibWinEnableWindowUpdate(OS2HwndFrame,TRUE);
1302 }
1303 else
1304 {
1305 if (getStyle() & WS_VISIBLE)
1306 {
1307 setStyle(getStyle() & ~WS_VISIBLE);
1308 OSLibWinEnableWindowUpdate(OS2HwndFrame,FALSE);
1309 }
1310 }
1311 return 0;
1312 }
1313
1314 case WM_CTLCOLORMSGBOX:
1315 case WM_CTLCOLOREDIT:
1316 case WM_CTLCOLORLISTBOX:
1317 case WM_CTLCOLORBTN:
1318 case WM_CTLCOLORDLG:
1319 case WM_CTLCOLORSTATIC:
1320 case WM_CTLCOLORSCROLLBAR:
1321 return DefWndControlColor(Msg - WM_CTLCOLORMSGBOX, (HDC)wParam);
1322
1323 case WM_CTLCOLOR:
1324 return DefWndControlColor(HIWORD(lParam), (HDC)wParam);
1325
1326 case WM_VKEYTOITEM:
1327 case WM_CHARTOITEM:
1328 return -1;
1329
1330 case WM_PARENTNOTIFY:
1331 return 0;
1332
1333 case WM_MOUSEACTIVATE:
1334 {
1335 dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
1336 if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
1337 {
1338 if(getParent()) {
1339 LRESULT rc = getParent()->SendInternalMessageA(WM_MOUSEACTIVATE, wParam, lParam );
1340 if(rc) return rc;
1341 }
1342 }
1343 return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
1344 }
1345
1346 case WM_ACTIVATE:
1347 return 0;
1348
1349 case WM_SETCURSOR:
1350 {
1351 dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
1352 if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
1353 {
1354 if(getParent()) {
1355 LRESULT rc = getParent()->SendInternalMessageA(WM_SETCURSOR, wParam, lParam);
1356 if(rc) return rc;
1357 }
1358 }
1359 if (wParam == Win32Hwnd)
1360 {
1361 HCURSOR hCursor;
1362
1363 switch(LOWORD(lParam))
1364 {
1365 case HTCLIENT:
1366 hCursor = windowClass ? windowClass->getCursor():LoadCursorA(0,IDC_ARROWA);
1367 break;
1368
1369 case HTLEFT:
1370 case HTRIGHT:
1371 hCursor = LoadCursorA(0,IDC_SIZEWEA);
1372 break;
1373
1374 case HTTOP:
1375 case HTBOTTOM:
1376 hCursor = LoadCursorA(0,IDC_SIZENSA);
1377 break;
1378
1379 case HTTOPLEFT:
1380 case HTBOTTOMRIGHT:
1381 hCursor = LoadCursorA(0,IDC_SIZENWSEA);
1382 break;
1383
1384 case HTTOPRIGHT:
1385 case HTBOTTOMLEFT:
1386 hCursor = LoadCursorA(0,IDC_SIZENESWA);
1387 break;
1388
1389 default:
1390 hCursor = LoadCursorA(0,IDC_ARROWA);
1391 break;
1392 }
1393
1394 if (hCursor)
1395 {
1396 SetCursor(hCursor);
1397 return 1;
1398 }
1399 else return 0;
1400 }
1401 else return 0;
1402 }
1403
1404 case WM_MOUSEMOVE:
1405 return 0;
1406
1407 case WM_WINDOWPOSCHANGED:
1408 {
1409 PWINDOWPOS wpos = (PWINDOWPOS)lParam;
1410 WPARAM wp = SIZE_RESTORED;
1411
1412 if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE))
1413 {
1414 SendInternalMessageA(WM_MOVE, 0, MAKELONG(rectClient.left,rectClient.top));
1415 }
1416 if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE))
1417 {
1418 if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
1419 else
1420 if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
1421
1422 SendInternalMessageA(WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left,
1423 rectClient.bottom - rectClient.top));
1424 }
1425 return 0;
1426 }
1427 case WM_WINDOWPOSCHANGING:
1428 return HandleWindowPosChanging((WINDOWPOS *)lParam);
1429
1430 case WM_ERASEBKGND:
1431 case WM_ICONERASEBKGND:
1432 {
1433 RECT rect;
1434 int rc;
1435
1436 if (!windowClass || !windowClass->getBackgroundBrush()) return 0;
1437
1438 rc = GetClipBox( (HDC)wParam, &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 }
1448 return 1;
1449 }
1450
1451 case WM_PRINT:
1452 return DefWndPrint(wParam,lParam);
1453
1454 case WM_PAINTICON:
1455 case WM_PAINT:
1456 {
1457 PAINTSTRUCT ps;
1458 HDC hdc = BeginPaint(getWindowHandle(), &ps );
1459 if( hdc )
1460 {
1461 if( (getStyle() & WS_MINIMIZE) && getWindowClass()->getIcon())
1462 {
1463 int x = (rectWindow.right - rectWindow.left - GetSystemMetrics(SM_CXICON))/2;
1464 int y = (rectWindow.bottom - rectWindow.top - GetSystemMetrics(SM_CYICON))/2;
1465 dprintf(("Painting class icon: vis rect=(%i,%i - %i,%i)\n", ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ));
1466 DrawIcon(hdc, x, y, getWindowClass()->getIcon() );
1467 }
1468 EndPaint(getWindowHandle(), &ps );
1469 }
1470 return 0;
1471 }
1472
1473 case WM_GETDLGCODE:
1474 return 0;
1475
1476 case WM_NCPAINT:
1477 return HandleNCPaint((HRGN)wParam);
1478
1479 case WM_NCACTIVATE:
1480 return HandleNCActivate(wParam);
1481
1482 case WM_NCCREATE:
1483 return(TRUE);
1484
1485 case WM_NCDESTROY:
1486 return 0;
1487
1488 case WM_NCCALCSIZE:
1489 return HandleNCCalcSize((BOOL)wParam,(RECT*)lParam);
1490
1491 case WM_NCLBUTTONDOWN:
1492 return HandleNCLButtonDown(wParam,lParam);
1493
1494 case WM_LBUTTONDBLCLK:
1495 case WM_NCLBUTTONDBLCLK:
1496 return HandleNCLButtonDblClk(wParam,lParam);
1497
1498 case WM_NCRBUTTONDOWN:
1499 case WM_NCRBUTTONDBLCLK:
1500 case WM_NCMBUTTONDOWN:
1501 case WM_NCMBUTTONDBLCLK:
1502 if (lastHitTestVal == HTERROR) MessageBeep(MB_ICONEXCLAMATION);
1503 return 0;
1504
1505 case WM_NCRBUTTONUP:
1506 return HandleNCRButtonUp(wParam,lParam);
1507
1508 case WM_NCMBUTTONUP:
1509 return 0;
1510
1511 case WM_NCHITTEST:
1512 {
1513 POINT point;
1514
1515 point.x = (SHORT)LOWORD(lParam);
1516 point.y = (SHORT)HIWORD(lParam);
1517
1518 return HandleNCHitTest(point);
1519 }
1520
1521 case WM_SYSCOMMAND:
1522 {
1523 POINT point;
1524
1525 point.x = LOWORD(lParam);
1526 point.y = HIWORD(lParam);
1527 return HandleSysCommand(wParam,&point);
1528 }
1529
1530 case WM_SYSKEYDOWN:
1531 if(wParam == VK_F4) /* try to close the window */
1532 {
1533 Win32BaseWindow *window = GetTopParent();
1534 if(window && !(window->getClass()->getStyle() & CS_NOCLOSE))
1535 PostMessageA(getWindowHandle(), WM_SYSCOMMAND, SC_CLOSE, 0);
1536 }
1537
1538 Win32BaseWindow *siblingWindow;
1539 HWND sibling;
1540 char nameBuffer [40], mnemonic;
1541 int nameLength;
1542
1543 GetWindowTextA (nameBuffer, 40);
1544
1545 // search all sibling to see it this key is their mnemonic
1546 sibling = GetWindow (GW_HWNDFIRST);
1547 while (sibling != 0) {
1548 siblingWindow = GetWindowFromHandle (sibling);
1549 nameLength = siblingWindow->GetWindowTextA (nameBuffer, 40);
1550
1551 // find the siblings mnemonic
1552 mnemonic = '\0';
1553 for (int i=0 ; i<nameLength ; i++) {
1554 if (nameBuffer [i] == '&') {
1555 mnemonic = nameBuffer [i+1];
1556 if ((mnemonic >= 'a') && (mnemonic <= 'z'))
1557 mnemonic -= 32; // make it uppercase
1558 break; // stop searching
1559 }
1560 }
1561
1562 // key matches siblings mnemonic, send mouseclick
1563 if (mnemonic == (char) wParam) {
1564 siblingWindow->SendInternalMessageA (BM_CLICK, 0, 0);
1565 }
1566
1567 sibling = siblingWindow->GetNextWindow (GW_HWNDNEXT);
1568 }
1569
1570 return 0;
1571
1572 case WM_SYSCHAR:
1573 {
1574 int iMenuSysKey = 0;
1575 if (wParam == VK_RETURN && (getStyle() & WS_MINIMIZE))
1576 {
1577 PostMessageA(getWindowHandle(), WM_SYSCOMMAND,
1578 (WPARAM)SC_RESTORE, 0L );
1579 break;
1580 }
1581 if ((HIWORD(lParam) & KEYDATA_ALT) && wParam)
1582 {
1583 if (wParam == VK_TAB || wParam == VK_ESCAPE) break;
1584 if (wParam == VK_SPACE && (getStyle() & WS_CHILD))
1585 getParent()->SendMessageA(Msg, wParam, lParam );
1586 else
1587 SendMessageA(WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)wParam );
1588 }
1589 else /* check for Ctrl-Esc */
1590 if (wParam != VK_ESCAPE) MessageBeep(0);
1591 break;
1592 }
1593 case WM_SETHOTKEY:
1594 hotkey = wParam;
1595 return 1; //CB: always successful
1596
1597 case WM_GETHOTKEY:
1598 return hotkey;
1599
1600 case WM_CONTEXTMENU:
1601 if ((dwStyle & WS_CHILD) && getParent())
1602 getParent()->SendInternalMessageA(WM_CONTEXTMENU,wParam,lParam);
1603 return 0;
1604
1605 case WM_SHOWWINDOW:
1606 if (!lParam) return 0; /* sent from ShowWindow */
1607 if (!(dwStyle & WS_POPUP) || !owner) return 0;
1608 if ((dwStyle & WS_VISIBLE) && wParam) return 0;
1609 else if (!(dwStyle & WS_VISIBLE) && !wParam) return 0;
1610 ShowWindow(wParam ? SW_SHOWNOACTIVATE : SW_HIDE);
1611 return 0;
1612
1613 case WM_CANCELMODE:
1614 if (getParent() == windowDesktop) EndMenu();
1615 if (GetCapture() == Win32Hwnd) ReleaseCapture();
1616 return 0;
1617
1618 case WM_DROPOBJECT:
1619 return DRAG_FILE;
1620
1621 case WM_QUERYDROPOBJECT:
1622 return (dwExStyle & WS_EX_ACCEPTFILES) ? 1:0;
1623
1624 case WM_QUERYDRAGICON:
1625 {
1626 HICON hIcon = windowClass->getCursor();
1627 UINT len;
1628
1629 if(hIcon) return (LRESULT)hIcon;
1630 for(len = 1; len < 64; len++)
1631 {
1632 hIcon = LoadIconA(hInstance,MAKEINTRESOURCEA(len));
1633 if(hIcon)
1634 return (LRESULT)hIcon;
1635 }
1636 return (LRESULT)LoadIconA(0,IDI_APPLICATIONA);
1637 }
1638
1639 case WM_QUERYOPEN:
1640 case WM_QUERYENDSESSION:
1641 return 1;
1642
1643 case WM_NOTIFYFORMAT:
1644 return IsWindowUnicode() ? NFR_UNICODE:NFR_ANSI;
1645
1646 case WM_SETICON:
1647 case WM_GETICON:
1648 {
1649 LRESULT result = 0;
1650 if (!windowClass) return result;
1651 int index = GCL_HICON;
1652
1653 if (wParam == ICON_SMALL)
1654 index = GCL_HICONSM;
1655
1656 result = windowClass->getClassLongA(index);
1657
1658 if (Msg == WM_SETICON)
1659 windowClass->setClassLongA(index, lParam);
1660
1661 return result;
1662 }
1663
1664 case WM_NOTIFY:
1665 return 0; //comctl32 controls expect this
1666
1667 default:
1668 return 0;
1669 }
1670 return 0;
1671}
1672//******************************************************************************
1673//******************************************************************************
1674LRESULT Win32BaseWindow::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam)
1675{
1676 switch(Msg)
1677 {
1678 case WM_GETTEXTLENGTH:
1679 return wndNameLength;
1680
1681 case WM_GETTEXT:
1682 if (!lParam || !wParam) return 0;
1683 if (!windowNameW) ((LPWSTR)lParam)[0] = 0;
1684 else lstrcpynW((LPWSTR)lParam,windowNameW,wParam);
1685 return min(wndNameLength,wParam);
1686
1687 case WM_SETTEXT:
1688 {
1689 LPWSTR lpsz = (LPWSTR)lParam;
1690
1691 if(windowNameA) free(windowNameA);
1692 if(windowNameW) free(windowNameW);
1693 if (lParam)
1694 {
1695 wndNameLength = lstrlenW(lpsz);
1696 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
1697 lstrcpyWtoA(windowNameA,lpsz);
1698 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
1699 lstrcpyW(windowNameW,lpsz);
1700 }
1701 else
1702 {
1703 windowNameA = NULL;
1704 windowNameW = NULL;
1705 wndNameLength = 0;
1706 }
1707 dprintf(("WM_SETTEXT of %x\n",Win32Hwnd));
1708 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
1709 {
1710 HandleNCPaint((HRGN)1);
1711 OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
1712 }
1713
1714 return TRUE;
1715 }
1716
1717 default:
1718 return DefWindowProcA(Msg, wParam, lParam);
1719 }
1720}
1721//******************************************************************************
1722//******************************************************************************
1723LRESULT Win32BaseWindow::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
1724{
1725 //if the destination window is created by this process & thread, call window proc directly
1726 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
1727 return SendInternalMessageA(Msg, wParam, lParam);
1728 }
1729 //otherwise use WinSendMsg to send it to the right process/thread
1730 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, FALSE);
1731}
1732//******************************************************************************
1733//******************************************************************************
1734LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
1735{
1736 //if the destination window is created by this process & thread, call window proc directly
1737 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
1738 return SendInternalMessageW(Msg, wParam, lParam);
1739 }
1740 //otherwise use WinSendMsg to send it to the right process/thread
1741 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, TRUE);
1742}
1743//******************************************************************************
1744//Called as a result of an OS/2 message or called from a class method
1745//******************************************************************************
1746LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
1747{
1748 LRESULT rc;
1749 BOOL fInternalMsgBackup = fInternalMsg;
1750
1751 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE);
1752
1753 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, FALSE);
1754
1755 fInternalMsg = TRUE;
1756 switch(Msg)
1757 {
1758 case WM_CREATE:
1759 {
1760 if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1761 dprintf(("WM_CREATE returned -1\n"));
1762 rc = -1; //don't create window
1763 break;
1764 }
1765 rc = 0;
1766 break;
1767 }
1768 case WM_LBUTTONDOWN:
1769 case WM_MBUTTONDOWN:
1770 case WM_RBUTTONDOWN:
1771 {
1772 if (getParent())
1773 {
1774 POINTS pt = MAKEPOINTS(lParam);
1775 POINT point;
1776
1777 point.x = pt.x;
1778 point.y = pt.y;
1779 mapWin32Point(OS2Hwnd,getParent()->getOS2WindowHandle(),(OSLIBPOINT*)&point);
1780 NotifyParent(Msg,wParam,MAKELPARAM(point.x,point.y));
1781 }
1782 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1783 break;
1784 }
1785
1786 case WM_DESTROY:
1787 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1788 break;
1789
1790 default:
1791 rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
1792 break;
1793 }
1794 fInternalMsg = fInternalMsgBackup;
1795 return rc;
1796}
1797//******************************************************************************
1798//Called as a result of an OS/2 message or called from a class method
1799//******************************************************************************
1800LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
1801{
1802 LRESULT rc;
1803 BOOL fInternalMsgBackup = fInternalMsg;
1804
1805 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE);
1806
1807 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, TRUE);
1808
1809 fInternalMsg = TRUE;
1810 switch(Msg)
1811 {
1812 case WM_CREATE:
1813 {
1814 if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1815 dprintf(("WM_CREATE returned -1\n"));
1816 rc = -1; //don't create window
1817 break;
1818 }
1819 rc = 0;
1820 break;
1821 }
1822 case WM_LBUTTONDOWN:
1823 case WM_MBUTTONDOWN:
1824 case WM_RBUTTONDOWN:
1825 NotifyParent(Msg, wParam, lParam);
1826 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1827 break;
1828
1829 case WM_DESTROY:
1830 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1831 break;
1832 default:
1833 rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
1834 break;
1835 }
1836 fInternalMsg = fInternalMsgBackup;
1837 return rc;
1838}
1839//******************************************************************************
1840//******************************************************************************
1841void Win32BaseWindow::CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
1842{
1843 CWPSTRUCT cwp;
1844
1845 cwp.lParam = lParam;
1846 cwp.wParam = wParam;
1847 cwp.message = Msg;
1848 cwp.hwnd = getWindowHandle();
1849
1850 switch(hooktype) {
1851 case WH_CALLWNDPROC:
1852 if(fUnicode) {
1853 HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
1854 }
1855 else HOOK_CallHooksA(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
1856 break;
1857 }
1858}
1859//******************************************************************************
1860//TODO: Do this more efficiently
1861//******************************************************************************
1862LRESULT Win32BaseWindow::BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam)
1863{
1864 Win32BaseWindow *window;
1865 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
1866
1867 dprintf(("BroadCastMessageA %x %x %x", msg, wParam, lParam, GetFS()));
1868
1869 for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
1870 window = GetWindowFromHandle(hwnd++);
1871 if(window) {
1872 if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
1873 {
1874
1875 if(type == BROADCAST_SEND) {
1876 window->SendInternalMessageA(msg, wParam, lParam);
1877 }
1878 else PostMessageA(window->getWindowHandle(), msg, wParam, lParam);
1879 }
1880 }
1881 }
1882 return 0;
1883}
1884//******************************************************************************
1885//TODO: Do this more efficiently
1886//******************************************************************************
1887LRESULT Win32BaseWindow::BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam)
1888{
1889 Win32BaseWindow *window;
1890 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
1891
1892 dprintf(("BroadCastMessageW %x %x %x", msg, wParam, lParam));
1893
1894 for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
1895 window = GetWindowFromHandle(hwnd++);
1896 if(window) {
1897 if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
1898 {
1899
1900 if(type == BROADCAST_SEND) {
1901 window->SendInternalMessageW(msg, wParam, lParam);
1902 }
1903 else PostMessageW(window->getWindowHandle(), msg, wParam, lParam);
1904 }
1905 }
1906 }
1907 return 0;
1908}
1909//******************************************************************************
1910//******************************************************************************
1911void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
1912{
1913 Win32BaseWindow *window = this;
1914 Win32BaseWindow *parentwindow;
1915
1916 while(window)
1917 {
1918 if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
1919 {
1920 /* Notify the parent window only */
1921 parentwindow = window->getParent();
1922 if(parentwindow) {
1923 parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam );
1924 }
1925 }
1926 else break;
1927
1928 window = parentwindow;
1929 }
1930}
1931//******************************************************************************
1932//******************************************************************************
1933BOOL Win32BaseWindow::SetIcon(HICON hIcon)
1934{
1935 dprintf(("Win32BaseWindow::SetIcon %x", hIcon));
1936 if(OSLibWinSetIcon(OS2HwndFrame, hIcon) == TRUE) {
1937//TODO: Wine does't send these. Correct?
1938// SendInternalMessageA(WM_SETICON, ICON_BIG, hIcon);
1939 return TRUE;
1940 }
1941 return FALSE;
1942}
1943//******************************************************************************
1944//******************************************************************************
1945BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow)
1946{
1947 ULONG showstate = 0;
1948 HWND hWinAfter;
1949
1950 dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
1951
1952 if (flags & WIN_NEED_SIZE)
1953 {
1954 /* should happen only in CreateWindowEx() */
1955 int wParam = SIZE_RESTORED;
1956
1957 flags &= ~WIN_NEED_SIZE;
1958 if (dwStyle & WS_MAXIMIZE)
1959 wParam = SIZE_MAXIMIZED;
1960 else
1961 if (dwStyle & WS_MINIMIZE)
1962 wParam = SIZE_MINIMIZED;
1963
1964 SendInternalMessageA(WM_SIZE, wParam,
1965 MAKELONG(rectClient.right-rectClient.left,
1966 rectClient.bottom-rectClient.top));
1967 SendInternalMessageA(WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top));
1968 }
1969 switch(nCmdShow)
1970 {
1971 case SW_SHOW:
1972 case SW_SHOWDEFAULT: //todo
1973 showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
1974 break;
1975 case SW_HIDE:
1976 showstate = SWPOS_HIDE;
1977 break;
1978 case SW_RESTORE:
1979 showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
1980 break;
1981 case SW_MINIMIZE:
1982 showstate = SWPOS_MINIMIZE;
1983 break;
1984 case SW_SHOWMAXIMIZED:
1985 showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
1986 break;
1987 case SW_SHOWMINIMIZED:
1988 showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
1989 break;
1990 case SW_SHOWMINNOACTIVE:
1991 showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
1992 break;
1993 case SW_SHOWNA:
1994 showstate = SWPOS_SHOW;
1995 break;
1996 case SW_SHOWNOACTIVATE:
1997 showstate = SWPOS_SHOW;
1998 break;
1999 case SW_SHOWNORMAL:
2000 showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
2001 break;
2002 }
2003
2004 /* We can't activate a child window (WINE) */
2005 if(getStyle() & WS_CHILD)
2006 showstate &= ~SWPOS_ACTIVATE;
2007
2008 if(showstate & SWPOS_SHOW) {
2009 setStyle(getStyle() | WS_VISIBLE);
2010 }
2011 else setStyle(getStyle() & ~WS_VISIBLE);
2012
2013 BOOL rc = OSLibWinShowWindow(OS2HwndFrame, showstate);
2014
2015 return rc;
2016}
2017//******************************************************************************
2018//******************************************************************************
2019BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
2020{
2021 BOOL rc = FALSE;
2022 Win32BaseWindow *window;
2023 HWND hParent = 0;
2024 BOOL fShow = FALSE, fHide = FALSE;
2025
2026 if (fuFlags &
2027 ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
2028 SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED |
2029 SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS |
2030 SWP_NOOWNERZORDER))
2031 {
2032 return FALSE;
2033 }
2034
2035 if(IsWindowDestroyed()) {
2036 //changing the position of a window that's being destroyed can cause crashes in PMMERGE
2037 dprintf(("SetWindowPos; window already destroyed"));
2038 return TRUE;
2039 }
2040 WINDOWPOS wpos;
2041 SWP swp, swpOld;
2042
2043#if 0 //CB: test: MSIE 2.0 displays the tool-/addressbar this way -> to check
2044 //CB: -> comctl32: toolbar (WM_SIZE), same bug: statusbar height
2045 //CB: cx or cy are 0
2046
2047if (cx == 0)
2048{
2049 dprintf(("CB: cx is 0! %d",fuFlags));
2050 if (fuFlags & SWP_NOSIZE) dprintf(("CB: nosize"));
2051 cx = 50;
2052}
2053if (cy == 0)
2054{
2055 dprintf(("CB: cy is 0! %d",fuFlags));
2056 if (fuFlags & SWP_NOSIZE) dprintf(("CB: nosize"));
2057 cy = 50;
2058}
2059
2060#endif
2061
2062 if(fuFlags & SWP_SHOWWINDOW) {
2063 fShow = TRUE;
2064 fuFlags &= ~SWP_SHOWWINDOW;
2065 }
2066 else
2067 if(fuFlags & SWP_HIDEWINDOW) {
2068 fHide = TRUE;
2069 fuFlags &= ~SWP_HIDEWINDOW;
2070 }
2071 wpos.flags = fuFlags;
2072 wpos.cy = cy;
2073 wpos.cx = cx;
2074 wpos.x = x;
2075 wpos.y = y;
2076 wpos.hwndInsertAfter = hwndInsertAfter;
2077 wpos.hwnd = getWindowHandle();
2078
2079 if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
2080 {
2081 if (isChild())
2082 {
2083 Win32BaseWindow *windowParent = getParent();
2084 if(windowParent) {
2085 hParent = getParent()->getOS2WindowHandle();
2086 }
2087 else dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
2088 }
2089 OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
2090 }
2091
2092 OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame);
2093 if (swp.fl == 0) {
2094 if (fuFlags & SWP_FRAMECHANGED)
2095 {
2096 FrameUpdateClient(this);
2097 }
2098 return TRUE;
2099 }
2100
2101// if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
2102 if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
2103 {
2104 Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
2105 if(wndBehind) {
2106 swp.hwndInsertBehind = wndBehind->getOS2FrameWindowHandle();
2107 }
2108 else {
2109 dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
2110 swp.hwndInsertBehind = 0;
2111 }
2112 }
2113 swp.hwnd = OS2HwndFrame;
2114
2115 dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
2116
2117 //SvL: For some reason WinSetMultWindowPos doesn't work for showing windows when they are hidden..
2118 if(fHide) {
2119 ShowWindow(SW_HIDE);
2120 }
2121 rc = OSLibWinSetMultWindowPos(&swp, 1);
2122 if(fShow) {
2123 ShowWindow(SW_SHOWNA);
2124 }
2125
2126 if (rc == FALSE)
2127 {
2128 dprintf(("OSLibWinSetMultWindowPos failed! Error %x",OSLibWinGetLastError()));
2129 }
2130
2131 if(fuFlags & SWP_FRAMECHANGED && (fuFlags & (SWP_NOMOVE | SWP_NOSIZE) == (SWP_NOMOVE | SWP_NOSIZE)))
2132 {
2133 FrameUpdateClient(this);
2134 }
2135
2136 return (rc);
2137}
2138//******************************************************************************
2139//TODO: WPF_RESTOREMAXIMIZED
2140//******************************************************************************
2141BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *winpos)
2142{
2143 if(isFrameWindow())
2144 {
2145 // Set the minimized position
2146 if (winpos->flags & WPF_SETMINPOSITION)
2147 {
2148 OSLibSetWindowMinPos(OS2HwndFrame, winpos->ptMinPosition.x, winpos->ptMinPosition.y);
2149 }
2150
2151 //TODO: Max position
2152
2153 // Set the new restore position.
2154 OSLibSetWindowRestoreRect(OS2HwndFrame, &winpos->rcNormalPosition);
2155 }
2156
2157 return ShowWindow(winpos->showCmd);
2158}
2159//******************************************************************************
2160//Also destroys all the child windows (destroy children first, parent last)
2161//******************************************************************************
2162BOOL Win32BaseWindow::DestroyWindow()
2163{
2164 /* Call hooks */
2165 if(HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, getWindowHandle(), 0L))
2166 {
2167 return FALSE;
2168 }
2169
2170 if(!(getStyle() & WS_CHILD) && getOwner() == NULL)
2171 {
2172 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWDESTROYED, getWindowHandle(), 0L);
2173 /* FIXME: clean up palette - see "Internals" p.352 */
2174 }
2175
2176 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
2177 {
2178 if(getParent())
2179 {
2180 /* Notify the parent window only */
2181 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
2182 if( !::IsWindow(getWindowHandle()) )
2183 {
2184 return TRUE;
2185 }
2186 }
2187 else DebugInt3();
2188 }
2189 fDestroyWindowCalled = TRUE;
2190 return OSLibWinDestroyWindow(OS2HwndFrame);
2191}
2192//******************************************************************************
2193//******************************************************************************
2194Win32BaseWindow *Win32BaseWindow::getParent()
2195{
2196 Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::GetParent();
2197 return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
2198}
2199//******************************************************************************
2200//******************************************************************************
2201HWND Win32BaseWindow::GetParent()
2202{
2203 Win32BaseWindow *wndparent;
2204
2205 if ((!(getStyle() & (WS_POPUP|WS_CHILD))))
2206 {
2207 return 0;
2208 }
2209 wndparent = ((getStyle() & WS_CHILD) ? getParent() : getOwner());
2210
2211 return (wndparent) ? wndparent->getWindowHandle() : 0;
2212}
2213//******************************************************************************
2214//******************************************************************************
2215HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
2216{
2217 HWND oldhwnd;
2218 Win32BaseWindow *newparent;
2219
2220 if(getParent()) {
2221 oldhwnd = getParent()->getWindowHandle();
2222 getParent()->RemoveChild(this);
2223 }
2224 else oldhwnd = 0;
2225
2226 newparent = GetWindowFromHandle(hwndNewParent);
2227 if(newparent)
2228 {
2229 setParent(newparent);
2230 getParent()->AddChild(this);
2231 OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
2232 return oldhwnd;
2233 }
2234 else {
2235 setParent(windowDesktop);
2236 windowDesktop->AddChild(this);
2237 OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
2238 return oldhwnd;
2239 }
2240}
2241//******************************************************************************
2242//******************************************************************************
2243BOOL Win32BaseWindow::IsChild(HWND hwndParent)
2244{
2245 if(getParent()) {
2246 return getParent()->getWindowHandle() == hwndParent;
2247 }
2248 else return 0;
2249}
2250//******************************************************************************
2251//******************************************************************************
2252HWND Win32BaseWindow::GetTopWindow()
2253{
2254 return GetWindow(GW_CHILD);
2255}
2256//******************************************************************************
2257// Get the top-level parent for a child window.
2258//******************************************************************************
2259Win32BaseWindow *Win32BaseWindow::GetTopParent()
2260{
2261 Win32BaseWindow *window = this;
2262
2263 while(window && (window->getStyle() & WS_CHILD))
2264 {
2265 window = window->getParent();
2266 }
2267 return window;
2268}
2269//******************************************************************************
2270//Don't call WinUpdateWindow as that one also updates the child windows
2271//Also need to send WM_PAINT directly to the window procedure, which doesn't
2272//always happen with WinUpdateWindow (could be posted if thread doesn't own window)
2273//******************************************************************************
2274BOOL Win32BaseWindow::UpdateWindow()
2275{
2276 RECT rect;
2277
2278 if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect))
2279 {//update region not empty
2280 HDC hdc;
2281
2282 hdc = O32_GetDC(OS2Hwnd);
2283 if (isIcon)
2284 {
2285 SendInternalMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
2286 SendInternalMessageA(WM_PAINTICON, 0, 0);
2287 }
2288 else
2289 {
2290 SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
2291 SendInternalMessageA(WM_PAINT, 0, 0);
2292 }
2293 O32_ReleaseDC(OS2Hwnd, hdc);
2294 }
2295 return TRUE;
2296}
2297//******************************************************************************
2298//******************************************************************************
2299BOOL Win32BaseWindow::IsIconic()
2300{
2301 return OSLibWinIsIconic(OS2Hwnd);
2302}
2303//******************************************************************************
2304//TODO: Should not enumerate children that are created during the enumeration!
2305//******************************************************************************
2306BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
2307{
2308 BOOL rc = TRUE;
2309 HWND hwnd;
2310 Win32BaseWindow *prevchild = 0, *child = 0;
2311
2312 dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
2313 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2314 {
2315 dprintf(("EnumChildWindows: enumerating child %x", child->getWindowHandle()));
2316 hwnd = child->getWindowHandle();
2317 if(child->getOwner()) {
2318 continue; //shouldn't have an owner (Wine)
2319 }
2320 if(lpfn(hwnd, lParam) == FALSE)
2321 {
2322 rc = FALSE;
2323 break;
2324 }
2325 //check if the window still exists
2326 if(!::IsWindow(hwnd))
2327 {
2328 child = prevchild;
2329 continue;
2330 }
2331 if(child->getFirstChild() != NULL)
2332 {
2333 dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle()));
2334 if(child->EnumChildWindows(lpfn, lParam) == FALSE)
2335 {
2336 rc = FALSE;
2337 break;
2338 }
2339 }
2340 prevchild = child;
2341 }
2342 return rc;
2343}
2344//******************************************************************************
2345//Enumerate first-level children only and check thread id
2346//******************************************************************************
2347BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
2348{
2349 Win32BaseWindow *child = 0;
2350 ULONG tid, pid;
2351 BOOL rc;
2352 HWND hwnd;
2353
2354 dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam));
2355
2356 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2357 {
2358 OSLibWinQueryWindowProcess(child->getOS2WindowHandle(), &pid, &tid);
2359
2360 if(dwThreadId == tid) {
2361 dprintf2(("EnumThreadWindows: Found Window %x", child->getWindowHandle()));
2362 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
2363 break;
2364 }
2365 }
2366 }
2367 return TRUE;
2368}
2369//******************************************************************************
2370//Enumerate first-level children only
2371//******************************************************************************
2372BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
2373{
2374 Win32BaseWindow *child = 0;
2375 BOOL rc;
2376 HWND hwnd;
2377
2378 dprintf(("EnumWindows %x %x", lpfn, lParam));
2379
2380 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2381 {
2382 hwnd = child->getWindowHandle();
2383
2384 dprintf2(("EnumWindows: Found Window %x", child->getWindowHandle()));
2385 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
2386 break;
2387 }
2388 }
2389 return TRUE;
2390}
2391//******************************************************************************
2392//******************************************************************************
2393Win32BaseWindow *Win32BaseWindow::FindWindowById(int id)
2394{
2395 for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2396 {
2397 if (child->getWindowId() == id)
2398 {
2399 return child;
2400 }
2401 }
2402 return 0;
2403}
2404//******************************************************************************
2405//TODO:
2406//We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
2407//the current process owns them.
2408//******************************************************************************
2409HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
2410 BOOL fUnicode)
2411{
2412 Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
2413 Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
2414
2415 if((hwndParent != OSLIB_HWND_DESKTOP && !parent) ||
2416 (hwndChildAfter != 0 && !child) ||
2417 (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0))
2418 {
2419 dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
2420 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
2421 return 0;
2422 }
2423 if(hwndParent != OSLIB_HWND_DESKTOP)
2424 {//if the current process owns the window, just do a quick search
2425 child = (Win32BaseWindow *)parent->getFirstChild();
2426 if(hwndChildAfter != 0)
2427 {
2428 while(child)
2429 {
2430 if(child->getWindowHandle() == hwndChildAfter)
2431 {
2432 child = (Win32BaseWindow *)child->getNextChild();
2433 break;
2434 }
2435 child = (Win32BaseWindow *)child->getNextChild();
2436 }
2437 }
2438 while(child)
2439 {
2440 if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
2441 (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
2442 {
2443 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
2444 return child->getWindowHandle();
2445 }
2446 child = (Win32BaseWindow *)child->getNextChild();
2447 }
2448 }
2449 else {
2450 Win32BaseWindow *wnd;
2451 HWND henum, hwnd;
2452
2453 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
2454 hwnd = OSLibWinGetNextWindow(henum);
2455
2456 while(hwnd)
2457 {
2458 wnd = GetWindowFromOS2Handle(hwnd);
2459 if(wnd == NULL) {
2460 hwnd = OSLibWinQueryClientWindow(hwnd);
2461 if(hwnd) wnd = GetWindowFromOS2Handle(hwnd);
2462 if(!hwnd) wnd = GetWindowFromOS2FrameHandle(hwnd);
2463 }
2464
2465 if(wnd) {
2466 if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
2467 (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
2468 {
2469 OSLibWinEndEnumWindows(henum);
2470 dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
2471 return wnd->getWindowHandle();
2472 }
2473 }
2474 hwnd = OSLibWinGetNextWindow(henum);
2475 }
2476 OSLibWinEndEnumWindows(henum);
2477 }
2478 SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
2479 return 0;
2480}
2481//******************************************************************************
2482//******************************************************************************
2483HWND Win32BaseWindow::GetWindow(UINT uCmd)
2484{
2485 HWND hwndRelated = 0;
2486 Win32BaseWindow *window;
2487
2488 switch(uCmd)
2489 {
2490 case GW_HWNDFIRST:
2491 if(getParent()) {
2492 window = (Win32BaseWindow *)getParent()->getFirstChild();
2493 hwndRelated = window->getWindowHandle();
2494 }
2495 break;
2496
2497 case GW_HWNDLAST:
2498 if(!getParent())
2499 {
2500 goto end;
2501 }
2502
2503 window = this;
2504 while(window->getNextChild())
2505 {
2506 window = (Win32BaseWindow *)window->getNextChild();
2507 }
2508 hwndRelated = window->getWindowHandle();
2509 break;
2510
2511 case GW_HWNDNEXT:
2512 window = (Win32BaseWindow *)getNextChild();
2513 if(window) {
2514 hwndRelated = window->getWindowHandle();
2515 }
2516 break;
2517
2518 case GW_HWNDPREV:
2519 if(!getParent())
2520 {
2521 goto end;
2522 }
2523 window = (Win32BaseWindow *)(getParent()->getFirstChild()); /* First sibling */
2524 if(window == this)
2525 {
2526 hwndRelated = 0; /* First in list */
2527 goto end;
2528 }
2529 while(window->getNextChild())
2530 {
2531 if (window->getNextChild() == this)
2532 {
2533 hwndRelated = window->getWindowHandle();
2534 goto end;
2535 }
2536 window = (Win32BaseWindow *)window->getNextChild();
2537 }
2538 break;
2539
2540 case GW_OWNER:
2541 if(getOwner()) {
2542 hwndRelated = getOwner()->getWindowHandle();
2543 }
2544 break;
2545
2546 case GW_CHILD:
2547 if(getFirstChild()) {
2548 hwndRelated = ((Win32BaseWindow *)getFirstChild())->getWindowHandle();
2549 }
2550 break;
2551 }
2552end:
2553 dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
2554 return hwndRelated;
2555}
2556//******************************************************************************
2557//******************************************************************************
2558HWND Win32BaseWindow::SetActiveWindow()
2559{
2560 HWND hwndActive;
2561 Win32BaseWindow *win32wnd;
2562 ULONG magic;
2563
2564 dprintf(("SetActiveWindow %x", getWindowHandle()));
2565 hwndActive = OSLibWinSetActiveWindow(OS2HwndFrame);
2566 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32WNDPTR);
2567 magic = OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32PM_MAGIC);
2568 if(CheckMagicDword(magic) && win32wnd)
2569 {
2570 return win32wnd->getWindowHandle();
2571 }
2572 return windowDesktop->getWindowHandle(); //pretend the desktop was active
2573}
2574//******************************************************************************
2575//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
2576//******************************************************************************
2577BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
2578{
2579 return OSLibWinEnableWindow(OS2HwndFrame, fEnable);
2580}
2581//******************************************************************************
2582//******************************************************************************
2583BOOL Win32BaseWindow::CloseWindow()
2584{
2585 return OSLibWinMinimizeWindow(OS2HwndFrame);
2586}
2587//******************************************************************************
2588//******************************************************************************
2589HWND Win32BaseWindow::GetActiveWindow()
2590{
2591 HWND hwndActive;
2592 Win32BaseWindow *win32wnd;
2593 ULONG magic;
2594
2595 hwndActive = OSLibWinQueryActiveWindow();
2596
2597 return OS2ToWin32Handle(hwndActive);
2598}
2599//******************************************************************************
2600//******************************************************************************
2601BOOL Win32BaseWindow::IsWindowEnabled()
2602{
2603 return OSLibWinIsWindowEnabled(OS2HwndFrame);
2604}
2605//******************************************************************************
2606//******************************************************************************
2607BOOL Win32BaseWindow::IsWindowVisible()
2608{
2609#if 1
2610 return (dwStyle & WS_VISIBLE) == WS_VISIBLE;
2611#else
2612 return OSLibWinIsWindowVisible(OS2HwndFrame);
2613#endif
2614}
2615//******************************************************************************
2616//******************************************************************************
2617BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
2618{
2619 INT len = GetWindowTextLength();
2620 BOOL res;
2621
2622 if (wndname == NULL)
2623 return (len == 0);
2624
2625 len++;
2626 if (fUnicode)
2627 {
2628 WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR));
2629
2630 GetWindowTextW(text,len);
2631 res = (lstrcmpW(text,(LPWSTR)wndname) == 0);
2632 free(text);
2633 } else
2634 {
2635 CHAR *text = (CHAR*)malloc(len*sizeof(CHAR));
2636
2637 GetWindowTextA(text,len);
2638 res = (strcmp(text,wndname) == 0);
2639 free(text);
2640 }
2641
2642 return res;
2643}
2644//******************************************************************************
2645//******************************************************************************
2646CHAR *Win32BaseWindow::getWindowNamePtrA()
2647{
2648 INT len = GetWindowTextLength();
2649 CHAR *text;
2650
2651 if (len == 0) return NULL;
2652 len++;
2653 text = (CHAR*)malloc(len*sizeof(CHAR));
2654 GetWindowTextA(text,len);
2655
2656 return text;
2657}
2658//******************************************************************************
2659//******************************************************************************
2660WCHAR *Win32BaseWindow::getWindowNamePtrW()
2661{
2662 INT len = GetWindowTextLength();
2663 WCHAR *text;
2664
2665 if (len == 0) return NULL;
2666 len++;
2667 text = (WCHAR*)malloc(len*sizeof(WCHAR));
2668 GetWindowTextW(text,len);
2669
2670 return text;
2671}
2672//******************************************************************************
2673//******************************************************************************
2674VOID Win32BaseWindow::freeWindowNamePtr(PVOID namePtr)
2675{
2676 if (namePtr) free(namePtr);
2677}
2678//******************************************************************************
2679//******************************************************************************
2680int Win32BaseWindow::GetWindowTextLength()
2681{
2682 return SendInternalMessageA(WM_GETTEXTLENGTH,0,0);
2683}
2684//******************************************************************************
2685//******************************************************************************
2686int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
2687{
2688 return SendInternalMessageA(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
2689}
2690//******************************************************************************
2691//******************************************************************************
2692int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
2693{
2694 return SendInternalMessageW(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
2695}
2696//******************************************************************************
2697//******************************************************************************
2698BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
2699{
2700 return SendInternalMessageA(WM_SETTEXT,0,(LPARAM)lpsz);
2701}
2702//******************************************************************************
2703//******************************************************************************
2704BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
2705{
2706 return SendInternalMessageW(WM_SETTEXT,0,(LPARAM)lpsz);
2707}
2708//******************************************************************************
2709//******************************************************************************
2710LONG Win32BaseWindow::SetWindowLongA(int index, ULONG value, BOOL fUnicode)
2711{
2712 LONG oldval;
2713
2714 dprintf2(("SetWindowLong%c %x %d %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
2715 switch(index) {
2716 case GWL_EXSTYLE:
2717 {
2718 STYLESTRUCT ss;
2719
2720 if(dwExStyle == value)
2721 return value;
2722
2723 ss.styleOld = dwExStyle;
2724 ss.styleNew = value;
2725 dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
2726 SendInternalMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
2727 setExStyle(ss.styleNew);
2728 SendInternalMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
2729 return ss.styleOld;
2730 }
2731 case GWL_STYLE:
2732 {
2733 STYLESTRUCT ss;
2734
2735 if(dwStyle == value)
2736 return value;
2737
2738 value &= ~(WS_VISIBLE | WS_CHILD); /* Some bits can't be changed this way (WINE) */
2739 ss.styleOld = getStyle();
2740 ss.styleNew = value | (ss.styleOld & (WS_VISIBLE | WS_CHILD));
2741 dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), ss.styleOld, ss.styleNew));
2742 SendInternalMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
2743 setStyle(ss.styleNew);
2744 SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
2745//// OSLibSetWindowStyle(getOS2FrameWindowHandle(), getStyle(), getExStyle(),
2746//// windowClass->getStyle() & CS_SAVEBITS);
2747#ifdef DEBUG
2748 PrintWindowStyle(ss.styleNew, 0);
2749#endif
2750 return ss.styleOld;
2751 }
2752 case GWL_WNDPROC:
2753 oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
2754 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, WINPROC_GetProcType(win32wndproc), WIN_PROC_WINDOW);
2755 return oldval;
2756
2757 case GWL_HINSTANCE:
2758 oldval = hInstance;
2759 hInstance = value;
2760 return oldval;
2761
2762 case GWL_HWNDPARENT:
2763 return SetParent((HWND)value);
2764
2765 case GWL_ID:
2766 oldval = getWindowId();
2767 setWindowId(value);
2768 return oldval;
2769
2770 case GWL_USERDATA:
2771 oldval = userData;
2772 userData = value;
2773 return oldval;
2774
2775 default:
2776 if(index >= 0 && index/4 < nrUserWindowLong)
2777 {
2778 oldval = userWindowLong[index/4];
2779 userWindowLong[index/4] = value;
2780 return oldval;
2781 }
2782 SetLastError(ERROR_INVALID_PARAMETER);
2783 return 0;
2784 }
2785}
2786//******************************************************************************
2787//******************************************************************************
2788ULONG Win32BaseWindow::GetWindowLongA(int index, BOOL fUnicode)
2789{
2790 ULONG value;
2791
2792 switch(index) {
2793 case GWL_EXSTYLE:
2794 value = dwExStyle;
2795 break;
2796 case GWL_STYLE:
2797 value = dwStyle;
2798 break;
2799 case GWL_WNDPROC:
2800 value = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
2801 break;
2802 case GWL_HINSTANCE:
2803 value = hInstance;
2804 break;
2805 case GWL_HWNDPARENT:
2806 if(getParent()) {
2807 value = getParent()->getWindowHandle();
2808 }
2809 else value = 0;
2810 break;
2811 case GWL_ID:
2812 value = getWindowId();
2813 break;
2814 case GWL_USERDATA:
2815 value = userData;
2816 break;
2817 default:
2818 if(index >= 0 && index/4 < nrUserWindowLong)
2819 {
2820 value = userWindowLong[index/4];
2821 break;
2822 }
2823 SetLastError(ERROR_INVALID_PARAMETER);
2824 return 0;
2825 }
2826 dprintf2(("GetWindowLongA %x %d %x", getWindowHandle(), index, value));
2827 return value;
2828}
2829//******************************************************************************
2830//******************************************************************************
2831WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
2832{
2833 WORD oldval;
2834
2835 if(index >= 0 && index/4 < nrUserWindowLong)
2836 {
2837 oldval = ((WORD *)userWindowLong)[index/2];
2838 ((WORD *)userWindowLong)[index/2] = value;
2839 return oldval;
2840 }
2841 SetLastError(ERROR_INVALID_PARAMETER);
2842 return 0;
2843}
2844//******************************************************************************
2845//******************************************************************************
2846WORD Win32BaseWindow::GetWindowWord(int index)
2847{
2848 if(index >= 0 && index/4 < nrUserWindowLong)
2849 {
2850 return ((WORD *)userWindowLong)[index/2];
2851 }
2852 SetLastError(ERROR_INVALID_PARAMETER);
2853 return 0;
2854}
2855//******************************************************************************
2856//******************************************************************************
2857void Win32BaseWindow::setWindowId(DWORD id)
2858{
2859 dwIDMenu = id;
2860}
2861//******************************************************************************
2862//******************************************************************************
2863Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
2864{
2865 Win32BaseWindow *window;
2866
2867 if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
2868 return window;
2869 }
2870// dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
2871 return NULL;
2872}
2873//******************************************************************************
2874//******************************************************************************
2875Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd)
2876{
2877 Win32BaseWindow *win32wnd;
2878 DWORD magic;
2879
2880 if(hwnd == OSLIB_HWND_DESKTOP)
2881 {
2882 return windowDesktop;
2883 }
2884
2885 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
2886 magic = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
2887
2888 if(win32wnd && CheckMagicDword(magic)) {
2889 return win32wnd;
2890 }
2891// dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwnd));
2892 return 0;
2893}
2894//******************************************************************************
2895//******************************************************************************
2896Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
2897{
2898 return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
2899}
2900//******************************************************************************
2901//******************************************************************************
2902HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd)
2903{
2904 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
2905
2906 if(window) {
2907 return window->getOS2WindowHandle();
2908 }
2909// dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
2910 return hwnd;
2911}
2912//******************************************************************************
2913//******************************************************************************
2914HWND Win32BaseWindow::Win32ToOS2FrameHandle(HWND hwnd)
2915{
2916 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
2917
2918 if(window) {
2919 return window->getOS2FrameWindowHandle();
2920 }
2921// dprintf2(("Win32BaseWindow::Win32ToOS2FrameHandle: not a win32 window %x", hwnd));
2922 return hwnd;
2923}
2924//******************************************************************************
2925//******************************************************************************
2926HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd)
2927{
2928 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
2929
2930 if(window) {
2931 return window->getWindowHandle();
2932 }
2933 window = GetWindowFromOS2FrameHandle(hwnd);
2934 if(window) {
2935 return window->getWindowHandle();
2936 }
2937// dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
2938 return 0;
2939// else return hwnd; //OS/2 window handle
2940}
2941//******************************************************************************
2942// GetNextDlgTabItem32 (USER32.276)
2943//******************************************************************************
2944HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
2945{
2946 Win32BaseWindow *child, *nextchild, *lastchild;
2947 HWND retvalue;
2948
2949 if (hwndCtrl)
2950 {
2951 child = GetWindowFromHandle(hwndCtrl);
2952 if (!child)
2953 {
2954 retvalue = 0;
2955 goto END;
2956 }
2957 /* Make sure hwndCtrl is a top-level child */
2958 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
2959 {
2960 child = child->getParent();
2961 if(child == NULL) break;
2962 }
2963
2964 if (!child || (child->getParent() != this))
2965 {
2966 retvalue = 0;
2967 goto END;
2968 }
2969 }
2970 else
2971 {
2972 /* No ctrl specified -> start from the beginning */
2973 child = (Win32BaseWindow *)getFirstChild();
2974 if (!child)
2975 {
2976 retvalue = 0;
2977 goto END;
2978 }
2979
2980 if (!fPrevious)
2981 {
2982 while (child->getNextChild())
2983 {
2984 child = (Win32BaseWindow *)child->getNextChild();
2985 }
2986 }
2987 }
2988
2989 lastchild = child;
2990 nextchild = (Win32BaseWindow *)child->getNextChild();
2991 while (TRUE)
2992 {
2993 if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild();
2994
2995 if (child == nextchild) break;
2996
2997 if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) &&
2998 !(nextchild->getStyle() & WS_DISABLED))
2999 {
3000 lastchild = nextchild;
3001 if (!fPrevious) break;
3002 }
3003 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
3004 }
3005 retvalue = lastchild->getWindowHandle();
3006
3007END:
3008 return retvalue;
3009}
3010//******************************************************************************
3011//******************************************************************************
3012HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
3013{
3014 Win32BaseWindow *child, *nextchild, *lastchild;
3015 HWND retvalue;
3016
3017 if (hwndCtrl)
3018 {
3019 child = GetWindowFromHandle(hwndCtrl);
3020 if (!child)
3021 {
3022 retvalue = 0;
3023 goto END;
3024 }
3025 /* Make sure hwndCtrl is a top-level child */
3026 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
3027 {
3028 child = child->getParent();
3029 if(child == NULL) break;
3030 }
3031
3032 if (!child || (child->getParent() != this))
3033 {
3034 retvalue = 0;
3035 goto END;
3036 }
3037 }
3038 else
3039 {
3040 /* No ctrl specified -> start from the beginning */
3041 child = (Win32BaseWindow *)getFirstChild();
3042 if (!child)
3043 {
3044 retvalue = 0;
3045 goto END;
3046 }
3047
3048 if (fPrevious)
3049 {
3050 while (child->getNextChild())
3051 {
3052 child = (Win32BaseWindow *)child->getNextChild();
3053 }
3054 }
3055 }
3056
3057 lastchild = child;
3058 nextchild = (Win32BaseWindow *)child->getNextChild();
3059 while (TRUE)
3060 {
3061 if (!nextchild || (nextchild->getStyle() & WS_GROUP))
3062 {
3063 /* Wrap-around to the beginning of the group */
3064 Win32BaseWindow *pWndTemp;
3065
3066 nextchild = (Win32BaseWindow *)getFirstChild();
3067
3068 for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild())
3069 {
3070 if (pWndTemp->getStyle() & WS_GROUP)
3071 nextchild = pWndTemp;
3072
3073 if (pWndTemp == child)
3074 break;
3075 }
3076
3077 }
3078 if (nextchild == child)
3079 break;
3080
3081 if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED))
3082 {
3083 lastchild = nextchild;
3084
3085 if (!fPrevious)
3086 break;
3087 }
3088
3089 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
3090 }
3091 retvalue = lastchild->getWindowHandle();
3092END:
3093 return retvalue;
3094}
3095//******************************************************************************
3096//******************************************************************************
3097#ifdef DEBUG
3098void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
3099{
3100 char style[256] = "";
3101 char exstyle[256] = "";
3102
3103 /* Window styles */
3104 if(dwStyle & WS_CHILD)
3105 strcat(style, "WS_CHILD ");
3106 if(dwStyle & WS_POPUP)
3107 strcat(style, "WS_POPUP ");
3108 if(dwStyle & WS_VISIBLE)
3109 strcat(style, "WS_VISIBLE ");
3110 if(dwStyle & WS_DISABLED)
3111 strcat(style, "WS_DISABLED ");
3112 if(dwStyle & WS_CLIPSIBLINGS)
3113 strcat(style, "WS_CLIPSIBLINGS ");
3114 if(dwStyle & WS_CLIPCHILDREN)
3115 strcat(style, "WS_CLIPCHILDREN ");
3116 if(dwStyle & WS_MAXIMIZE)
3117 strcat(style, "WS_MAXIMIZE ");
3118 if(dwStyle & WS_MINIMIZE)
3119 strcat(style, "WS_MINIMIZE ");
3120 if(dwStyle & WS_GROUP)
3121 strcat(style, "WS_GROUP ");
3122 if(dwStyle & WS_TABSTOP)
3123 strcat(style, "WS_TABSTOP ");
3124
3125 if((dwStyle & WS_CAPTION) == WS_CAPTION)
3126 strcat(style, "WS_CAPTION ");
3127 if(dwStyle & WS_DLGFRAME)
3128 strcat(style, "WS_DLGFRAME ");
3129 if(dwStyle & WS_BORDER)
3130 strcat(style, "WS_BORDER ");
3131
3132 if(dwStyle & WS_VSCROLL)
3133 strcat(style, "WS_VSCROLL ");
3134 if(dwStyle & WS_HSCROLL)
3135 strcat(style, "WS_HSCROLL ");
3136 if(dwStyle & WS_SYSMENU)
3137 strcat(style, "WS_SYSMENU ");
3138 if(dwStyle & WS_THICKFRAME)
3139 strcat(style, "WS_THICKFRAME ");
3140 if(dwStyle & WS_MINIMIZEBOX)
3141 strcat(style, "WS_MINIMIZEBOX ");
3142 if(dwStyle & WS_MAXIMIZEBOX)
3143 strcat(style, "WS_MAXIMIZEBOX ");
3144
3145 if(dwExStyle & WS_EX_DLGMODALFRAME)
3146 strcat(exstyle, "WS_EX_DLGMODALFRAME ");
3147 if(dwExStyle & WS_EX_ACCEPTFILES)
3148 strcat(exstyle, "WS_EX_ACCEPTFILES ");
3149 if(dwExStyle & WS_EX_NOPARENTNOTIFY)
3150 strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
3151 if(dwExStyle & WS_EX_TOPMOST)
3152 strcat(exstyle, "WS_EX_TOPMOST ");
3153 if(dwExStyle & WS_EX_TRANSPARENT)
3154 strcat(exstyle, "WS_EX_TRANSPARENT ");
3155
3156 if(dwExStyle & WS_EX_MDICHILD)
3157 strcat(exstyle, "WS_EX_MDICHILD ");
3158 if(dwExStyle & WS_EX_TOOLWINDOW)
3159 strcat(exstyle, "WS_EX_TOOLWINDOW ");
3160 if(dwExStyle & WS_EX_WINDOWEDGE)
3161 strcat(exstyle, "WS_EX_WINDOWEDGE ");
3162 if(dwExStyle & WS_EX_CLIENTEDGE)
3163 strcat(exstyle, "WS_EX_CLIENTEDGE ");
3164 if(dwExStyle & WS_EX_CONTEXTHELP)
3165 strcat(exstyle, "WS_EX_CONTEXTHELP ");
3166 if(dwExStyle & WS_EX_RIGHT)
3167 strcat(exstyle, "WS_EX_RIGHT ");
3168 if(dwExStyle & WS_EX_LEFT)
3169 strcat(exstyle, "WS_EX_LEFT ");
3170 if(dwExStyle & WS_EX_RTLREADING)
3171 strcat(exstyle, "WS_EX_RTLREADING ");
3172 if(dwExStyle & WS_EX_LTRREADING)
3173 strcat(exstyle, "WS_EX_LTRREADING ");
3174 if(dwExStyle & WS_EX_LEFTSCROLLBAR)
3175 strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
3176 if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
3177 strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
3178 if(dwExStyle & WS_EX_CONTROLPARENT)
3179 strcat(exstyle, "WS_EX_CONTROLPARENT ");
3180 if(dwExStyle & WS_EX_STATICEDGE)
3181 strcat(exstyle, "WS_EX_STATICEDGE ");
3182 if(dwExStyle & WS_EX_APPWINDOW)
3183 strcat(exstyle, "WS_EX_APPWINDOW ");
3184
3185 dprintf(("Window style: %x %s", dwStyle, style));
3186 dprintf(("Window exStyle: %x %s (FS = %x)", dwExStyle, exstyle, GetFS()));
3187}
3188#endif
3189//******************************************************************************
3190//******************************************************************************
3191
3192GenericObject *Win32BaseWindow::windows = NULL;
Note: See TracBrowser for help on using the repository browser.