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

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

fixed dialog rect

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