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

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

WM_EX_CONTEXTHELP

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