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

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

refixed WM_WINDOWPOS*

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