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

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

export 55AA pattern for COMCTL32, edit EN_CHANGED fix

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