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

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

set style + mdi child creation fixes

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