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

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

client positioning + scrollbar fixes

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