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

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

DrawCaption performance improvements for window text updates

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