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

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

Many bugfixes

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