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

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

menu and frame changes

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