source: trunk/src/user32/new/win32wbase.cpp@ 2444

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

several nc changes

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