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

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

Client rectangle changes, GetDCEx bugfix (CS_OWNDC), scroll rectangle calculation fixes

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