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

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

WM_CONTEXTMENU, sysmenu changes

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