source: trunk/src/user32/win32wbase.cpp@ 2852

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

merged with Corel WINE 20000212, added WS_EX_CONTEXTHELP

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