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

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

Don't call default frame handler for WM_ADJUSTWINDOWPOS

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