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

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

fixed WM_CALCVALIDRECTS, added region for WM_NCPAINT

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