source: trunk/src/user32/new/win32wbase.cpp@ 2435

Last change on this file since 2435 was 2435, checked in by sandervl, 26 years ago

Several window position bugfixes

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