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

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

Lots of menu fixes

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