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

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

scrollbar support and many other things

File size: 138.2 KB
Line 
1/* $Id: win32wbase.cpp,v 1.26 2000-01-09 14:14:24 cbratschi Exp $ */
2/*
3 * Win32 Window Base Class for OS/2
4 *
5 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
6 * Copyright 1999 Daniela Engert (dani@ngrt.de)
7 *
8 * Parts based on Wine Windows code (windows\win.c)
9 *
10 * Copyright 1993, 1994, 1996 Alexandre Julliard
11 * 1995 Alex Korobka
12 *
13 * TODO: Not thread/process safe
14 *
15 * Project Odin Software License can be found in LICENSE.TXT
16 *
17 */
18#include <os2win.h>
19#include <win.h>
20#include <stdlib.h>
21#include <string.h>
22#include <stdarg.h>
23#include <assert.h>
24#include <misc.h>
25#include <heapstring.h>
26#include <win32wbase.h>
27#include <winres.h>
28#include "wndmsg.h"
29#include "oslibwin.h"
30#include "oslibmsg.h"
31#include "oslibutil.h"
32#include "oslibgdi.h"
33#include "oslibres.h"
34#include "oslibmenu.h"
35#include "oslibdos.h"
36#include "syscolor.h"
37#include "win32wndhandle.h"
38#include "dc.h"
39#include "pmframe.h"
40#include "win32wdesktop.h"
41#include "pmwindow.h"
42#include "controls.h"
43#include <wprocess.h>
44#include "winmouse.h"
45#include <win\hook.h>
46#include <shellapi.h>
47#define INCL_TIMERWIN32
48#include "timer.h"
49
50#define SC_ABOUTWINE (SC_SCREENSAVE+1)
51#define SC_PUTMARK (SC_SCREENSAVE+2)
52
53#define HAS_DLGFRAME(style,exStyle) \
54 (((exStyle) & WS_EX_DLGMODALFRAME) || \
55 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
56
57#define HAS_THICKFRAME(style,exStyle) \
58 (((style) & WS_THICKFRAME) && \
59 !((exStyle) & WS_EX_DLGMODALFRAME) && \
60 !((style) & WS_CHILD))
61
62#define HAS_THINFRAME(style) \
63 (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
64
65#define HAS_BIGFRAME(style,exStyle) \
66 (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
67 ((exStyle) & WS_EX_DLGMODALFRAME))
68
69#define HAS_ANYFRAME(style,exStyle) \
70 (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
71 ((exStyle) & WS_EX_DLGMODALFRAME) || \
72 !((style) & (WS_CHILD | WS_POPUP)))
73
74#define HAS_3DFRAME(exStyle) \
75 ((exStyle & WS_EX_CLIENTEDGE) || (exStyle & WS_EX_STATICEDGE) || (exStyle & WS_EX_WINDOWEDGE))
76
77#define HAS_BORDER(style, exStyle) \
78 ((style & WS_BORDER) || HAS_THICKFRAME(style) || HAS_DLGFRAME(style,exStyle))
79
80#define IS_OVERLAPPED(style) \
81 !(style & (WS_CHILD | WS_POPUP))
82
83#define HAS_MENU(w) (!((w)->getStyle() & WS_CHILD) && ((w)->getWindowId() != 0))
84
85/* bits in the dwKeyData */
86#define KEYDATA_ALT 0x2000
87#define KEYDATA_PREVSTATE 0x4000
88
89void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle);
90
91static fDestroyAll = FALSE;
92//For quick lookup of current process id
93static ULONG currentProcessId = -1;
94
95static HBITMAP hbitmapClose = 0;
96static HBITMAP hbitmapCloseD = 0;
97static HBITMAP hbitmapMinimize = 0;
98static HBITMAP hbitmapMinimizeD = 0;
99static HBITMAP hbitmapMaximize = 0;
100static HBITMAP hbitmapMaximizeD = 0;
101static HBITMAP hbitmapRestore = 0;
102static HBITMAP hbitmapRestoreD = 0;
103
104BYTE lpGrayMask[] = { 0xAA, 0xA0,
105 0x55, 0x50,
106 0xAA, 0xA0,
107 0x55, 0x50,
108 0xAA, 0xA0,
109 0x55, 0x50,
110 0xAA, 0xA0,
111 0x55, 0x50,
112 0xAA, 0xA0,
113 0x55, 0x50};
114
115//******************************************************************************
116//******************************************************************************
117Win32BaseWindow::Win32BaseWindow(DWORD objType) : GenericObject(&windows, objType)
118{
119 Init();
120}
121//******************************************************************************
122//******************************************************************************
123Win32BaseWindow::Win32BaseWindow(HWND os2Handle,VOID* win32WndProc) : GenericObject(&windows,OBJTYPE_WINDOW)
124{
125 Init();
126 OS2Hwnd = OS2HwndFrame = os2Handle;
127 dwStyle = WS_VISIBLE;
128 setWindowProc((WNDPROC)win32WndProc);
129 fIsSubclassedOS2Wnd = TRUE;
130 fFirstShow = FALSE;
131 fCreated = TRUE;
132
133 SetLastError(0);
134
135 //CB: replace by a secure method
136
137 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
138 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
139 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
140 return;
141 }
142 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
143 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
144 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
145 return;
146 }
147
148 OSLibWinQueryWindowRect(OS2Hwnd,&rectClient,RELATIVE_TO_WINDOW);
149 OSLibWinQueryWindowRect(OS2Hwnd,&rectWindow,RELATIVE_TO_SCREEN);
150
151 setOldWndProc(SubclassWithDefHandler(OS2Hwnd));
152}
153//******************************************************************************
154//******************************************************************************
155Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
156 : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
157{
158 Init();
159 this->isUnicode = isUnicode;
160 CreateWindowExA(lpCreateStructA, classAtom);
161}
162//******************************************************************************
163//******************************************************************************
164void Win32BaseWindow::Init()
165{
166 isUnicode = FALSE;
167 fIsSubclassedOS2Wnd = FALSE;
168 fFirstShow = TRUE;
169 fIsDialog = FALSE;
170 fIsModalDialogOwner = FALSE;
171 OS2HwndModalDialog = 0;
172 fInternalMsg = FALSE;
173 fNoSizeMsg = FALSE;
174 fIsDestroyed = FALSE;
175 fDestroyWindowCalled = FALSE;
176 fCreated = FALSE;
177 fTaskList = FALSE;
178 fParentDC = FALSE;
179
180 windowNameA = NULL;
181 windowNameW = NULL;
182 wndNameLength = 0;
183
184 userWindowLong = NULL;;
185 nrUserWindowLong = 0;
186
187 magic = WIN32PM_MAGIC;
188 OS2Hwnd = 0;
189 OS2HwndFrame = 0;
190 hMenu = 0;
191 hSysMenu = 0;
192 Win32Hwnd = 0;
193
194 if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE)
195 {
196 dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
197 DebugInt3();
198 }
199
200 posx = posy = 0;
201 width = height = 0;
202
203 dwExStyle = 0;
204 dwStyle = 0;
205 win32wndproc = 0;
206 hInstance = 0;
207 windowId = 0xFFFFFFFF; //default = -1
208 userData = 0;
209 contextHelpId = 0;
210
211 pOldFrameProc = NULL;
212 borderWidth = 0;
213 borderHeight = 0;
214
215 hwndLinkAfter = HWND_BOTTOM;
216 flags = 0;
217 isIcon = FALSE;
218 lastHitTestVal = HTOS_NORMAL;
219 fIgnoreHitTest = FALSE;
220 owner = NULL;
221 windowClass = 0;
222
223 iconResource = NULL;
224
225 EraseBkgndFlag = TRUE;
226 PSEraseFlag = FALSE;
227 SuppressEraseFlag = FALSE;
228
229 horzScrollInfo = NULL;
230 vertScrollInfo = NULL;
231
232 ownDC = 0;
233 hWindowRegion = 0;
234
235 if(currentProcessId == -1)
236 {
237 currentProcessId = GetCurrentProcessId();
238 }
239 dwThreadId = GetCurrentThreadId();
240 dwProcessId = currentProcessId;
241}
242//******************************************************************************
243//todo get rid of resources (menu, icon etc)
244//******************************************************************************
245Win32BaseWindow::~Win32BaseWindow()
246{
247 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
248 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
249
250 if(!fDestroyAll && getParent() && getParent()->getFirstChild() == this && getNextChild() == NULL)
251 {
252 //if we're the last child that's being destroyed and our
253 //parent window was also destroyed, then we delete the parent object
254 if(getParent()->IsWindowDestroyed())
255 {
256 dprintf(("Last Child (%x) destroyed, get rid of our parent window (%x)", getWindowHandle(), getParent()->getWindowHandle()));
257 delete getParent();
258 setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
259 }
260 }
261 else
262 if(fDestroyAll) {
263 dprintf(("Destroying window %x %s", getWindowHandle(), windowNameA));
264 setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
265 }
266
267 if (isOwnDC())
268 releaseOwnDC (ownDC);
269
270 if(Win32Hwnd)
271 HwFreeWindowHandle(Win32Hwnd);
272
273 if(userWindowLong)
274 free(userWindowLong);
275 if(windowNameA) {
276 free(windowNameA);
277 windowNameA = NULL;
278 }
279 if(windowNameW) {
280 free(windowNameW);
281 windowNameW = NULL;
282 }
283 if(vertScrollInfo) {
284 free(vertScrollInfo);
285 vertScrollInfo = NULL;
286 }
287 if(horzScrollInfo) {
288 free(horzScrollInfo);
289 horzScrollInfo = NULL;
290 }
291}
292//******************************************************************************
293//******************************************************************************
294void Win32BaseWindow::DestroyAll()
295{
296 fDestroyAll = TRUE;
297 GenericObject::DestroyAll(windows);
298}
299//******************************************************************************
300//******************************************************************************
301BOOL Win32BaseWindow::isChild()
302{
303 return ((dwStyle & WS_CHILD) != 0);
304}
305//******************************************************************************
306//******************************************************************************
307BOOL Win32BaseWindow::IsWindowUnicode()
308{
309 dprintf2(("IsWindowUnicode %x %d", getWindowHandle(), WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W));
310 return (WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W);
311}
312//******************************************************************************
313//******************************************************************************
314BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom)
315{
316 char buffer[256];
317 POINT maxSize, maxPos, minTrack, maxTrack;
318
319#ifdef DEBUG
320 PrintWindowStyle(cs->style, cs->dwExStyle);
321#endif
322
323 sw = SW_SHOW;
324 SetLastError(0);
325
326 /* Find the parent window */
327 if (cs->hwndParent)
328 {
329 Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
330 if(!window) {
331 dprintf(("Bad parent %04x\n", cs->hwndParent ));
332 SetLastError(ERROR_INVALID_PARAMETER);
333 return FALSE;
334 }
335 /* Make sure parent is valid */
336 if (!window->IsWindow() )
337 {
338 dprintf(("Bad parent %04x\n", cs->hwndParent ));
339 SetLastError(ERROR_INVALID_PARAMETER);
340 return FALSE;
341 }
342 }
343 else
344 if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
345 dprintf(("No parent for child window\n" ));
346 SetLastError(ERROR_INVALID_PARAMETER);
347 return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
348 }
349
350 /* Find the window class */
351 windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
352 if (!windowClass)
353 {
354 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
355 dprintf(("Bad class '%s'\n", buffer ));
356 SetLastError(ERROR_INVALID_PARAMETER);
357 return 0;
358 }
359#ifdef DEBUG
360 if(HIWORD(cs->lpszClass))
361 {
362 char *astring;
363
364 if(isUnicode) astring = UnicodeToAsciiString((LPWSTR)cs->lpszClass);
365 else astring = (char *)cs->lpszClass;
366
367 dprintf(("Window class %s", astring));
368 if(isUnicode) FreeAsciiString(astring);
369 }
370 else dprintf(("Window class %x", cs->lpszClass));
371#endif
372
373 /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
374 * with an atom as the class name, put some programs expect to have a *REAL* string in
375 * lpszClass when the CREATESTRUCT is sent with WM_CREATE
376 */
377 if (!HIWORD(cs->lpszClass) ) {
378 if (isUnicode) {
379 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
380 }
381 else {
382 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
383 }
384 cs->lpszClass = buffer;
385 }
386
387 /* Fix the coordinates */
388 if ((cs->x == CW_USEDEFAULT) || (cs->x == CW_USEDEFAULT16))
389 {
390// PDB *pdb = PROCESS_Current();
391
392 /* Never believe Microsoft's documentation... CreateWindowEx doc says
393 * that if an overlapped window is created with WS_VISIBLE style bit
394 * set and the x parameter is set to CW_USEDEFAULT, the system ignores
395 * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
396 * reveals that
397 *
398 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
399 * 2) it does not ignore the y parameter as the docs claim; instead, it
400 * uses it as second parameter to ShowWindow() unless y is either
401 * CW_USEDEFAULT or CW_USEDEFAULT16.
402 *
403 * The fact that we didn't do 2) caused bogus windows pop up when wine
404 * was running apps that were using this obscure feature. Example -
405 * calc.exe that comes with Win98 (only Win98, it's different from
406 * the one that comes with Win95 and NT)
407 */
408 if ((cs->y != CW_USEDEFAULT) && (cs->y != CW_USEDEFAULT16)) sw = cs->y;
409
410 /* We have saved cs->y, now we can trash it */
411#if 0
412 if ( !(cs->style & (WS_CHILD | WS_POPUP))
413 && (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
414 {
415 cs->x = pdb->env_db->startup_info->dwX;
416 cs->y = pdb->env_db->startup_info->dwY;
417 }
418#endif
419 cs->x = 0;
420 cs->y = 0;
421// }
422 }
423 if ((cs->cx == CW_USEDEFAULT) || (cs->cx == CW_USEDEFAULT16))
424 {
425#if 0
426 PDB *pdb = PROCESS_Current();
427 if ( !(cs->style & (WS_CHILD | WS_POPUP))
428 && (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )
429 {
430 cs->cx = pdb->env_db->startup_info->dwXSize;
431 cs->cy = pdb->env_db->startup_info->dwYSize;
432 }
433 else
434 {
435#endif
436 cs->cx = 600; /* FIXME */
437 cs->cy = 400;
438// }
439 }
440
441 if (cs->x < 0) cs->x = 0;
442 if (cs->y < 0) cs->y = 0;
443
444 //Allocate window words
445 nrUserWindowLong = windowClass->getExtraWndWords();
446 if(nrUserWindowLong) {
447 userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
448 memset(userWindowLong, 0, nrUserWindowLong);
449 }
450
451 if ((cs->style & WS_CHILD) && cs->hwndParent)
452 {
453 SetParent(cs->hwndParent);
454 owner = GetWindowFromHandle(cs->hwndParent);
455 if(owner == NULL)
456 {
457 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
458 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
459 return FALSE;
460 }
461 }
462 else
463 {
464 SetParent(0);
465 if (!cs->hwndParent || (cs->hwndParent == windowDesktop->getWindowHandle())) {
466 owner = NULL;
467 }
468 else
469 {
470 owner = GetWindowFromHandle(cs->hwndParent)->GetTopParent();
471 if(owner == NULL)
472 {
473 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
474 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
475 return FALSE;
476 }
477 }
478 }
479
480 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc(), WINPROC_GetProcType(windowClass->getWindowProc()), WIN_PROC_WINDOW);
481 hInstance = cs->hInstance;
482 dwStyle = cs->style & ~WS_VISIBLE;
483 dwExStyle = cs->dwExStyle;
484
485 hwndLinkAfter = HWND_TOP;
486 if(CONTROLS_IsControl(this, BUTTON_CONTROL) && ((dwStyle & 0x0f) == BS_GROUPBOX))
487 {
488 hwndLinkAfter = HWND_BOTTOM;
489 dwStyle |= WS_CLIPSIBLINGS;
490 }
491 else
492 if(CONTROLS_IsControl(this, STATIC_CONTROL) && !(dwStyle & WS_GROUP)) {
493 dwStyle |= WS_CLIPSIBLINGS;
494 }
495
496 /* Increment class window counter */
497 windowClass->IncreaseWindowCount();
498
499 if (HOOK_IsHooked( WH_CBT ))
500 {
501 CBT_CREATEWNDA cbtc;
502 LRESULT ret;
503
504 cbtc.lpcs = cs;
505 cbtc.hwndInsertAfter = hwndLinkAfter;
506 ret = HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc);
507 if(ret)
508 {
509 dprintf(("CBT-hook returned 0!!"));
510 SetLastError(ERROR_CAN_NOT_COMPLETE); //todo: wrong error
511 return FALSE;
512 }
513 }
514
515 /* Correct the window style */
516 if (!(cs->style & WS_CHILD))
517 {
518 dwStyle |= WS_CLIPSIBLINGS;
519 if (!(cs->style & WS_POPUP))
520 {
521 dwStyle |= WS_CAPTION;
522 flags |= WIN_NEED_SIZE;
523 }
524 }
525 if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
526
527 if (cs->style & WS_HSCROLL)
528 {
529 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
530 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
531 horzScrollInfo->MaxVal = 100;
532 horzScrollInfo->flags = ESB_ENABLE_BOTH;
533 }
534
535 if (cs->style & WS_VSCROLL)
536 {
537 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
538 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
539 vertScrollInfo->MaxVal = 100;
540 vertScrollInfo->flags = ESB_ENABLE_BOTH;
541 }
542
543 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
544 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
545 {
546 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
547 if (maxSize.x < cs->cx) cs->cx = maxSize.x;
548 if (maxSize.y < cs->cy) cs->cy = maxSize.y;
549 if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
550 if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
551 }
552
553 if(cs->style & WS_CHILD)
554 {
555 if(cs->cx < 0) cs->cx = 0;
556 if(cs->cy < 0) cs->cy = 0;
557 }
558 else
559 {
560 if (cs->cx <= 0) cs->cx = 1;
561 if (cs->cy <= 0) cs->cy = 1;
562 }
563
564 if(((dwStyle & 0xC0000000) == WS_OVERLAPPED) && ((dwStyle & WS_CAPTION) == WS_CAPTION) && owner == NULL
565 && dwStyle & WS_SYSMENU)
566 {
567 fTaskList = TRUE;
568 }
569
570 DWORD dwOSWinStyle, dwOSFrameStyle;
571
572 OSLibWinConvertStyle(dwStyle, &dwExStyle, &dwOSWinStyle, &dwOSFrameStyle, &borderWidth, &borderHeight);
573
574 if(HIWORD(cs->lpszName))
575 {
576 if (!isUnicode)
577 {
578 wndNameLength = strlen(cs->lpszName);
579 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
580 strcpy(windowNameA,cs->lpszName);
581 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
582 lstrcpyAtoW(windowNameW,windowNameA);
583 windowNameA[wndNameLength] = 0;
584 windowNameW[wndNameLength] = 0;
585 }
586 else
587 {
588 wndNameLength = lstrlenW((LPWSTR)cs->lpszName);
589 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
590 lstrcpyWtoA(windowNameA,(LPWSTR)cs->lpszName);
591 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
592 lstrcpyW(windowNameW,(LPWSTR)cs->lpszName);
593 windowNameA[wndNameLength] = 0;
594 windowNameW[wndNameLength] = 0;
595 }
596 }
597
598 //copy pointer of CREATESTRUCT for usage in MsgCreate method
599 tmpcs = cs;
600
601 //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it
602 THDB *thdb = GetThreadTHDB();
603
604 if(thdb == NULL) {
605 dprintf(("Window creation failed - thdb == NULL")); //this is VERY bad
606 ExitProcess(666);
607 return FALSE;
608 }
609
610 thdb->newWindow = (ULONG)this;
611
612 OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
613 dwOSWinStyle,(char *)windowNameA,
614 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
615 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
616 &OS2HwndFrame, 0, fTaskList);
617 if(OS2Hwnd == 0) {
618 dprintf(("Window creation failed!!"));
619 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
620 return FALSE;
621 }
622
623 SetLastError(0);
624 return TRUE;
625}
626//******************************************************************************
627//******************************************************************************
628BOOL Win32BaseWindow::MsgCreate(HWND hwndFrame, HWND hwndClient)
629{
630 POINT maxPos;
631 CREATESTRUCTA *cs = tmpcs; //pointer to CREATESTRUCT used in CreateWindowExA method
632
633 OS2Hwnd = hwndClient;
634 OS2HwndFrame = hwndFrame;
635
636 fNoSizeMsg = TRUE;
637
638 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
639 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
640 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
641 return FALSE;
642 }
643 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
644 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
645 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
646 return FALSE;
647 }
648
649 OSLibWinSetOwner(OS2Hwnd, OS2HwndFrame);
650
651 fakeWinBase.hwndThis = OS2Hwnd;
652 fakeWinBase.pWindowClass = windowClass;
653
654 //Set icon from class
655 if(windowClass->getIcon())
656 SetIcon(windowClass->getIcon());
657 /* Get class or window DC if needed */
658 if(windowClass->getStyle() & CS_OWNDC) {
659 dprintf(("Class with CS_OWNDC style"));
660// ownDC = GetWindowDC(getWindowHandle());
661 }
662 else
663 if (windowClass->getStyle() & CS_PARENTDC) {
664 dprintf(("WARNING: Class with CS_PARENTDC style!"));
665 fParentDC = TRUE;
666 ownDC = 0;
667 }
668 else
669 if (windowClass->getStyle() & CS_CLASSDC) {
670 dprintf(("WARNING: Class with CS_CLASSDC style!"));
671 ownDC = 0;
672 }
673 /* Set the window menu */
674 if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
675 {
676#if 0 //CB: todo
677 if (cs->hMenu) {
678 SetMenu(cs->hMenu);
679 }
680 else {
681 if (windowClass->getMenuNameA()) {
682 cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
683 if (cs->hMenu) SetMenu(cs->hMenu );
684 }
685 }
686#endif
687 }
688 else
689 {
690 setWindowId((DWORD)cs->hMenu);
691 }
692
693 // Subclass frame
694 pOldFrameProc = FrameSubclassFrameWindow(this);
695 //if (isChild()) FrameSetBorderSize(this,TRUE);
696
697 //preset rects
698 rectWindow.left = cs->x;
699 rectWindow.right = cs->x+cs->cx;
700 rectWindow.top = cs->y;
701 rectWindow.bottom = cs->y+cs->cy;
702 rectClient = rectWindow; //dummy client rect
703 if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow);
704 /* Send the WM_CREATE message
705 * Perhaps we shouldn't allow width/height changes as well.
706 * See p327 in "Internals".
707 */
708 maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
709
710 //Note: Solitaire crashes when receiving WM_SIZE messages before WM_CREATE
711 //fNoSizeMsg = FALSE;
712 fCreated = TRUE;
713
714 if (SendInternalMessageA(WM_NCCREATE,0,(LPARAM)cs))
715 {
716 //update rect
717 rectWindow.left = cs->x;
718 rectWindow.right = cs->x+cs->cx;
719 rectWindow.top = cs->y;
720 rectWindow.bottom = cs->y+cs->cy;
721 if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow);
722 OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
723 rectClient = rectWindow;
724 if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rectClient);
725 //set the window size and update the client
726 SetWindowPos(hwndLinkAfter,rectClient.left,rectClient.top,rectClient.right-rectClient.left,rectClient.bottom-rectClient.top,SWP_NOACTIVATE | SWP_NOREDRAW | SWP_FRAMECHANGED);
727 fNoSizeMsg = FALSE;
728 if (cs->style & WS_VISIBLE) dwStyle |= WS_VISIBLE; //program could change position in WM_CREATE
729 if( (SendInternalMessageA(WM_CREATE, 0, (LPARAM)cs )) != -1 )
730 {
731 if(!(flags & WIN_NEED_SIZE)) {
732 SendInternalMessageA(WM_SIZE, SIZE_RESTORED,
733 MAKELONG(rectClient.right-rectClient.left,
734 rectClient.bottom-rectClient.top));
735 SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
736 }
737
738 if( (getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
739 {
740 /* Notify the parent window only */
741 SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle());
742 if(!::IsWindow(getWindowHandle()))
743 {
744 dprintf(("Createwindow: WM_PARENTNOTIFY destroyed window"));
745 goto end;
746 }
747 }
748
749 if (cs->style & WS_VISIBLE) ShowWindow(sw);
750
751 /* Call WH_SHELL hook */
752 if (!(getStyle() & WS_CHILD) && !owner)
753 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWCREATED, getWindowHandle(), 0 );
754
755 SetLastError(0);
756 return TRUE;
757 }
758 }
759 dprintf(("Window creation FAILED (NCCREATE cancelled creation)"));
760 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
761end:
762 return FALSE;
763}
764//******************************************************************************
765//******************************************************************************
766ULONG Win32BaseWindow::MsgQuit()
767{
768 return SendInternalMessageA(WM_QUIT, 0, 0);
769}
770//******************************************************************************
771//******************************************************************************
772ULONG Win32BaseWindow::MsgClose()
773{
774 return SendInternalMessageA(WM_CLOSE,0,0);
775}
776//******************************************************************************
777//******************************************************************************
778ULONG Win32BaseWindow::MsgDestroy()
779{
780 ULONG rc;
781 Win32BaseWindow *child;
782 HWND hwnd = getWindowHandle();
783
784 if (isSubclassedOS2Wnd) OSLibWinSubclassWindow(OS2Hwnd,pOldWndProc);
785
786 fIsDestroyed = TRUE;
787
788 if(fDestroyWindowCalled == FALSE)
789 {//this window was destroyed because DestroyWindow was called for it's parent
790 //so: send a WM_PARENTNOTIFY now as that hasn't happened yet
791 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
792 {
793 if(getParent())
794 {
795 /* Notify the parent window only */
796 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
797 }
798 else DebugInt3();
799 }
800 }
801 SendInternalMessageA(WM_DESTROY, 0, 0);
802 if(::IsWindow(hwnd) == FALSE) {
803 //object already destroyed, so return immediately
804 return 1;
805 }
806 SendInternalMessageA(WM_NCDESTROY, 0, 0);
807
808 TIMER_KillTimerFromWindow(OS2Hwnd);
809
810 if(getFirstChild() == NULL) {
811 delete this;
812 }
813 return 1;
814}
815//******************************************************************************
816//******************************************************************************
817ULONG Win32BaseWindow::MsgEnable(BOOL fEnable)
818{
819 if(fEnable) {
820 dwStyle &= ~WS_DISABLED;
821 }
822 else dwStyle |= WS_DISABLED;
823
824 return SendInternalMessageA(WM_ENABLE, fEnable, 0);
825}
826//******************************************************************************
827//TODO: SW_PARENTCLOSING/OPENING flag (lParam)
828//******************************************************************************
829ULONG Win32BaseWindow::MsgShow(BOOL fShow)
830{
831 if(fNoSizeMsg) {
832 return 1;
833 }
834
835 if(fShow) {
836 setStyle(getStyle() | WS_VISIBLE);
837 }
838 else setStyle(getStyle() & ~WS_VISIBLE);
839
840 return SendInternalMessageA(WM_SHOWWINDOW, fShow, 0);
841}
842//******************************************************************************
843//******************************************************************************
844ULONG Win32BaseWindow::MsgPosChanging(LPARAM lp)
845{
846 //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
847 // a WM_WINDOWPOSCHANGED msg -> crash)
848 if(fNoSizeMsg || fDestroyWindowCalled)
849 return 1;
850
851 return SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, lp);
852}
853//******************************************************************************
854//******************************************************************************
855ULONG Win32BaseWindow::MsgPosChanged(LPARAM lp)
856{
857 //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
858 // a WM_WINDOWPOSCHANGED msg -> crash)
859 if(fNoSizeMsg || fDestroyWindowCalled)
860 return 1;
861
862 return SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, lp);
863}
864//******************************************************************************
865//******************************************************************************
866#if 0
867ULONG Win32BaseWindow::MsgMinMax()
868{
869
870}
871#endif
872//******************************************************************************
873//******************************************************************************
874ULONG Win32BaseWindow::MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos)
875{
876 //According to the SDK docs, the scrollbar handle (lParam) is 0 when the standard
877 //window scrollbars send these messages
878 return SendInternalMessageA(msg, MAKELONG(scrollCode, scrollPos), 0);
879}
880//******************************************************************************
881//******************************************************************************
882ULONG Win32BaseWindow::MsgHitTest(MSG *msg)
883{
884 lastHitTestVal = SendInternalMessageA(WM_NCHITTEST,msg->wParam,msg->lParam);
885 dprintf2(("MsgHitTest returned %x", lastHitTestVal));
886
887 if (lastHitTestVal == HTERROR)
888 return HTOS_ERROR;
889
890#if 0 //CB: problems with groupboxes, internal handling is better
891 if (lastHitTestVal == HTTRANSPARENT)
892 return HTOS_TRANSPARENT;
893#endif
894
895 return HTOS_NORMAL;
896}
897//******************************************************************************
898//******************************************************************************
899ULONG Win32BaseWindow::MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd)
900{
901 ULONG rc, curprocid, procidhwnd = -1, threadidhwnd = 0;
902
903
904 //According to SDK docs, if app returns FALSE & window is being deactivated,
905 //default processing is cancelled
906 //TODO: According to Wine we should proceed anyway if window is sysmodal
907 if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
908 {
909 return 0;
910 }
911 rc = SendInternalMessageA(WM_ACTIVATE, MAKELONG((fActivate) ? WA_ACTIVE : WA_INACTIVE, fMinimized), hwnd);
912
913 curprocid = GetCurrentProcessId();
914 if(hwnd) {
915 threadidhwnd = GetWindowThreadProcessId(hwnd, &procidhwnd);
916 }
917
918 if(curprocid != procidhwnd && fActivate) {
919 SendInternalMessageA(WM_ACTIVATEAPP, 1, threadidhwnd);
920 }
921 return rc;
922}
923//******************************************************************************
924//TODO: Is this correct and complete?
925//Add print screen, break & numlock
926//******************************************************************************
927void Win32BaseWindow::setExtendedKey(ULONG virtualkey, ULONG *lParam)
928{
929 switch(virtualkey) {
930 case VK_DOWN:
931 case VK_UP:
932 case VK_PRIOR:
933 case VK_NEXT:
934 case VK_END:
935 case VK_DIVIDE:
936 case VK_DELETE:
937 case VK_EXECUTE: //Numeric enter key?
938 case VK_HOME:
939 case VK_INSERT:
940 case VK_RCONTROL:
941 case VK_RMENU: //is this the right alt???
942 *lParam = *lParam | (1<<24);
943 }
944}
945//******************************************************************************
946//******************************************************************************
947ULONG Win32BaseWindow::DispatchMsgA(MSG *msg)
948{
949 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
950}
951//******************************************************************************
952//******************************************************************************
953ULONG Win32BaseWindow::DispatchMsgW(MSG *msg)
954{
955 return SendInternalMessageW(msg->message, msg->wParam, msg->lParam);
956}
957//******************************************************************************
958//******************************************************************************
959ULONG Win32BaseWindow::MsgSetFocus(HWND hwnd)
960{
961 return SendInternalMessageA(WM_SETFOCUS, hwnd, 0);
962}
963//******************************************************************************
964//******************************************************************************
965ULONG Win32BaseWindow::MsgKillFocus(HWND hwnd)
966{
967 return SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
968}
969//******************************************************************************
970//******************************************************************************
971ULONG Win32BaseWindow::MsgButton(MSG *msg)
972{
973 BOOL fClick = FALSE;
974
975 dprintf(("MsgButton at (%d,%d)", msg->pt.x, msg->pt.y));
976 switch(msg->message) {
977 case WM_LBUTTONDBLCLK:
978 case WM_RBUTTONDBLCLK:
979 case WM_MBUTTONDBLCLK:
980 case WM_NCLBUTTONDBLCLK:
981 case WM_NCRBUTTONDBLCLK:
982 case WM_NCMBUTTONDBLCLK:
983 if (!(windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS) && (msg->message != WM_NCLBUTTONDBLCLK))
984 {
985 msg->message = msg->message - (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); //dblclick -> down
986 MsgButton(msg);
987 msg->message++; //button-up
988 return MsgButton(msg);
989 }
990 break;
991 case WM_LBUTTONDOWN:
992 case WM_RBUTTONDOWN:
993 case WM_MBUTTONDOWN:
994 case WM_NCLBUTTONDOWN:
995 case WM_NCRBUTTONDOWN:
996 case WM_NCMBUTTONDOWN:
997 fClick = TRUE;
998 break;
999 }
1000
1001 if(ISMOUSE_CAPTURED())
1002 {
1003 if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_BUTTON, msg->pt.x, msg->pt.y))
1004 return 0;
1005 }
1006
1007 if(fClick)
1008 {
1009 HWND hwndTop;
1010
1011 /* Activate the window if needed */
1012 if(isSubclassedOS2Wnd()) {
1013 Win32BaseWindow *parentwnd = GetWindowFromOS2FrameHandle(OSLibWinQueryWindow(OS2Hwnd, QWOS_PARENT));
1014 if(parentwnd) {
1015 hwndTop = (parentwnd->GetTopParent()) ? parentwnd->GetTopParent()->getWindowHandle() : 0;
1016 }
1017 else hwndTop = 0;
1018 }
1019 else hwndTop = (GetTopParent()) ? GetTopParent()->getWindowHandle() : 0;
1020
1021 HWND hwndActive = GetActiveWindow();
1022 if (hwndTop && (getWindowHandle() != hwndActive))
1023 {
1024 LONG ret = SendInternalMessageA(WM_MOUSEACTIVATE, hwndTop,
1025 MAKELONG( lastHitTestVal, msg->message) );
1026
1027#if 0
1028 if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
1029 eatMsg = TRUE;
1030#endif
1031 if(((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT))
1032 && hwndTop != GetForegroundWindow() )
1033 {
1034 ::SetActiveWindow(hwndTop);
1035 }
1036 }
1037 }
1038
1039 SendInternalMessageA(WM_SETCURSOR, getWindowHandle(), MAKELONG(lastHitTestVal, msg->message));
1040
1041 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
1042}
1043//******************************************************************************
1044//******************************************************************************
1045ULONG Win32BaseWindow::MsgPaint(ULONG tmp1, BOOL select)
1046{
1047 if (select && isIcon)
1048 return SendInternalMessageA(WM_PAINTICON, 0, 0);
1049 else
1050 return SendInternalMessageA(WM_PAINT, 0, 0);
1051}
1052//******************************************************************************
1053//TODO: Is the clipper region of the window DC equal to the invalidated rectangle?
1054// (or are we simply erasing too much here)
1055//******************************************************************************
1056ULONG Win32BaseWindow::MsgEraseBackGround(HDC hdc)
1057{
1058 ULONG rc;
1059 HDC hdcErase = hdc;
1060
1061 if (hdcErase == 0)
1062 hdcErase = O32_GetDC(OS2Hwnd);
1063
1064 if(isIcon)
1065 rc = SendInternalMessageA(WM_ICONERASEBKGND, hdcErase, 0);
1066 else
1067 rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0);
1068 if (hdc == 0)
1069 O32_ReleaseDC(OS2Hwnd, hdcErase);
1070 return (rc);
1071}
1072//******************************************************************************
1073//******************************************************************************
1074ULONG Win32BaseWindow::MsgMouseMove(MSG *msg)
1075{
1076 if(ISMOUSE_CAPTURED()) {
1077 if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_MOVE, msg->pt.x, msg->pt.y))
1078 return 0;
1079 }
1080
1081 //TODO: hiword should be 0 if window enters menu mode (SDK docs)
1082 SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, msg->message));
1083
1084 //translated message == WM_(NC)MOUSEMOVE
1085 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
1086}
1087//******************************************************************************
1088//TODO: Depending on menu type, we should send WM_INITMENU or WM_INITPOPUPMENU
1089//TODO: PM sends it for each submenu that gets activated; Windows only for the first
1090// submenu; once the menu bar is active, moving the cursor doesn't generate other
1091// WM_INITMENU msgs. Not really a problem, but might need to fix this later on.
1092//******************************************************************************
1093ULONG Win32BaseWindow::MsgInitMenu(MSG *msg)
1094{
1095 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
1096}
1097//******************************************************************************
1098//******************************************************************************
1099ULONG Win32BaseWindow::MsgNCPaint()
1100{
1101 RECT rect;
1102
1103 if (GetOS2UpdateRect(OS2HwndFrame,&rect))
1104 {
1105 HRGN hrgn;
1106 ULONG rc;
1107 RECT client = rectClient;
1108
1109//CB: bug in dc.cpp!!!
1110 if ((rect.left == rect.right) || (rect.bottom == rect.top)) return 0;
1111 mapWin32Rect(getParent() ? getParent()->getOS2WindowHandle():OSLIB_HWND_DESKTOP,OS2HwndFrame,&client);
1112 if ((rect.left >= client.left) && (rect.left < client.right) &&
1113 (rect.right >= client.left) && (rect.right < client.right) &&
1114 (rect.top >= client.top) && (rect.top < client.bottom) &&
1115 (rect.bottom >= client.top) && (rect.bottom < client.bottom))
1116 return 0;
1117 hrgn = CreateRectRgnIndirect(&rect);
1118 if (!hrgn) return 0;
1119//CB: bug in GetDCEx with region!!!
1120 rc = SendInternalMessageA(WM_NCPAINT,/*hrgn*/0,0);
1121//dprintf(("CB: %d %d %d %d",rect.left,rect.top,rect.bottom,rect.right));
1122 DeleteObject(hrgn);
1123 //CB: todo: check if intersection with client
1124
1125 return rc;
1126 } else return 0;
1127}
1128//******************************************************************************
1129//******************************************************************************
1130ULONG Win32BaseWindow::MsgFormatFrame()
1131{
1132 RECT window = rectWindow,client = rectClient,rect;
1133 WINDOWPOS wndPos;
1134
1135 wndPos.hwnd = Win32Hwnd;
1136 wndPos.hwndInsertAfter = 0;
1137 rect = rectWindow;
1138 if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rect);
1139 wndPos.x = rect.left;
1140 wndPos.y = rect.top;
1141 wndPos.cx = rect.right-rect.left;
1142 wndPos.cy = rect.bottom-rect.top;
1143 wndPos.flags = 0; //dummy
1144
1145 return SendNCCalcSize(TRUE,&window,&window,&client,&wndPos,&rectClient);
1146}
1147//******************************************************************************
1148//******************************************************************************
1149ULONG Win32BaseWindow::MsgSetText(LPSTR lpsz, LONG cch)
1150{
1151 return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
1152}
1153//******************************************************************************
1154//******************************************************************************
1155ULONG Win32BaseWindow::MsgGetTextLength()
1156{
1157 return SendInternalMessageA(WM_GETTEXTLENGTH, 0, 0);
1158}
1159//******************************************************************************
1160//******************************************************************************
1161char *Win32BaseWindow::MsgGetText()
1162{
1163 SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA);
1164 return windowNameA;
1165}
1166//******************************************************************************
1167//******************************************************************************
1168ULONG Win32BaseWindow::MsgContextMenu(ULONG x,ULONG y)
1169{
1170 return SendInternalMessageA(WM_CONTEXTMENU,Win32Hwnd,MAKELPARAM(x,y));
1171}
1172//******************************************************************************
1173//******************************************************************************
1174BOOL Win32BaseWindow::isMDIClient()
1175{
1176 return FALSE;
1177}
1178//******************************************************************************
1179//******************************************************************************
1180BOOL Win32BaseWindow::isMDIChild()
1181{
1182 return FALSE;
1183}
1184//******************************************************************************
1185//TODO: Not complete
1186//******************************************************************************
1187BOOL Win32BaseWindow::isFrameWindow()
1188{
1189// if(isMDIChild() || IsDialog() || (getParent() == NULL || getParent() == windowDesktop) && ((dwStyle & WS_CAPTION) == WS_CAPTION))
1190 if((dwStyle & WS_CAPTION) == WS_CAPTION || dwStyle & (WS_VSCROLL|WS_HSCROLL))
1191 return TRUE;
1192
1193 return FALSE;
1194}
1195//******************************************************************************
1196//******************************************************************************
1197SCROLLBAR_INFO *Win32BaseWindow::getScrollInfo(int nBar)
1198{
1199 switch(nBar)
1200 {
1201 case SB_HORZ:
1202 if (!horzScrollInfo)
1203 {
1204 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
1205 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
1206 horzScrollInfo->MaxVal = 100;
1207 horzScrollInfo->flags = ESB_ENABLE_BOTH;
1208 }
1209 return horzScrollInfo;
1210
1211 case SB_VERT:
1212 if (!vertScrollInfo)
1213 {
1214 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
1215 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
1216 vertScrollInfo->MaxVal = 100;
1217 vertScrollInfo->flags = ESB_ENABLE_BOTH;
1218 }
1219 return vertScrollInfo;
1220 }
1221
1222 return NULL;
1223}
1224//******************************************************************************
1225//******************************************************************************
1226LONG Win32BaseWindow::HandleNCActivate(WPARAM wParam)
1227{
1228 WORD wStateChange;
1229
1230 if( wParam ) wStateChange = !(flags & WIN_NCACTIVATED);
1231 else wStateChange = flags & WIN_NCACTIVATED;
1232
1233 if( wStateChange )
1234 {
1235 if (wParam) flags |= WIN_NCACTIVATED;
1236 else flags &= ~WIN_NCACTIVATED;
1237
1238 if(!(dwStyle & WS_MINIMIZE))
1239 DoNCPaint((HRGN)1,FALSE);
1240 }
1241
1242 return TRUE;
1243}
1244//******************************************************************************
1245//******************************************************************************
1246VOID Win32BaseWindow::TrackMinMaxBox(WORD wParam)
1247{
1248 MSG msg;
1249 HDC hdc;
1250 BOOL pressed = TRUE;
1251 UINT state;
1252
1253 if (wParam == HTMINBUTTON)
1254 {
1255 /* If the style is not present, do nothing */
1256 if (!(dwStyle & WS_MINIMIZEBOX))
1257 return;
1258 /* Check if the sysmenu item for minimize is there */
1259#if 0 //CB: todo
1260 state = GetMenuState(hSysMenu,SC_MINIMIZE,MF_BYCOMMAND);
1261#endif
1262 } else
1263 {
1264 /* If the style is not present, do nothing */
1265 if (!(dwStyle & WS_MAXIMIZEBOX))
1266 return;
1267 /* Check if the sysmenu item for maximize is there */
1268#if 0 //CB: todo
1269 state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
1270#endif
1271 }
1272 SetCapture(Win32Hwnd);
1273 hdc = GetWindowDC(Win32Hwnd);
1274 if (wParam == HTMINBUTTON)
1275 DrawMinButton(hdc,TRUE,FALSE);
1276 else
1277 DrawMaxButton(hdc,TRUE,FALSE);
1278 do
1279 {
1280 BOOL oldstate = pressed;
1281
1282 GetMessageA(&msg,Win32Hwnd,0,0);
1283 pressed = (HandleNCHitTest(msg.pt) == wParam);
1284 if (pressed != oldstate)
1285 {
1286 if (wParam == HTMINBUTTON)
1287 DrawMinButton(hdc,pressed,FALSE);
1288 else
1289 DrawMaxButton(hdc,pressed,FALSE);
1290 }
1291 } while (msg.message != WM_LBUTTONUP);
1292 if (wParam == HTMINBUTTON)
1293 DrawMinButton(hdc,FALSE,FALSE);
1294 else
1295 DrawMaxButton(hdc,FALSE,FALSE);
1296 ReleaseCapture();
1297 ReleaseDC(Win32Hwnd,hdc);
1298 /* If the item minimize or maximize of the sysmenu are not there */
1299 /* or if the style is not present, do nothing */
1300 if ((!pressed) || (state == 0xFFFFFFFF))
1301 return;
1302 if (wParam == HTMINBUTTON)
1303 SendInternalMessageA(WM_SYSCOMMAND,SC_MINIMIZE,*(LPARAM*)&msg.pt);
1304 else
1305 SendInternalMessageA(WM_SYSCOMMAND,IsZoomed(Win32Hwnd) ? SC_RESTORE:SC_MAXIMIZE,*(LPARAM*)&msg.pt);
1306}
1307//******************************************************************************
1308//******************************************************************************
1309VOID Win32BaseWindow::TrackCloseButton(WORD wParam)
1310{
1311 MSG msg;
1312 HDC hdc;
1313 BOOL pressed = TRUE;
1314 UINT state;
1315
1316#if 0 //CB: todo
1317 if (hSysMenu == 0)
1318 return;
1319 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
1320#else
1321state = 0;
1322#endif
1323 /* If the item close of the sysmenu is disabled or not there do nothing */
1324 if((state & MF_DISABLED) || (state & MF_GRAYED) || (state == 0xFFFFFFFF))
1325 return;
1326 hdc = GetWindowDC(Win32Hwnd);
1327 SetCapture(Win32Hwnd);
1328 DrawCloseButton(hdc,TRUE,FALSE);
1329 do
1330 {
1331 BOOL oldstate = pressed;
1332
1333 GetMessageA(&msg,Win32Hwnd,0,0);
1334 pressed = (HandleNCHitTest(msg.pt) == wParam);
1335 if (pressed != oldstate)
1336 DrawCloseButton(hdc, pressed, FALSE);
1337 } while (msg.message != WM_LBUTTONUP);
1338 DrawCloseButton(hdc,FALSE,FALSE);
1339 ReleaseCapture();
1340 ReleaseDC(Win32Hwnd,hdc);
1341 if (!pressed) return;
1342 SendInternalMessageA(WM_SYSCOMMAND,SC_CLOSE,*(LPARAM*)&msg.pt);
1343}
1344//******************************************************************************
1345//******************************************************************************
1346VOID Win32BaseWindow::TrackScrollBar(WPARAM wParam,POINT pt)
1347{
1348 INT scrollbar;
1349 MSG msg;
1350
1351 if ((wParam & 0xfff0) == SC_HSCROLL)
1352 {
1353 if ((wParam & 0x0f) != HTHSCROLL) return;
1354 scrollbar = SB_HORZ;
1355 } else /* SC_VSCROLL */
1356 {
1357 if ((wParam & 0x0f) != HTVSCROLL) return;
1358 scrollbar = SB_VERT;
1359 }
1360
1361 pt.x -= rectWindow.left;
1362 pt.y -= rectWindow.top;
1363 SCROLL_HandleScrollEvent(Win32Hwnd,0,MAKELONG(pt.x,pt.y),scrollbar,WM_LBUTTONDOWN);
1364 if (GetCapture() != Win32Hwnd) return;
1365 do
1366 {
1367 GetMessageA(&msg,Win32Hwnd,0,0);
1368 switch(msg.message)
1369 {
1370 case WM_LBUTTONUP:
1371 case WM_MOUSEMOVE:
1372 pt.x = msg.pt.x-rectWindow.left;
1373 pt.y = msg.pt.y-rectWindow.top;
1374 msg.lParam = MAKELONG(pt.x,pt.y);
1375 case WM_SYSTIMER:
1376 SCROLL_HandleScrollEvent(Win32Hwnd,msg.wParam,msg.lParam,scrollbar,msg.message);
1377 break;
1378
1379 default:
1380 TranslateMessage(&msg);
1381 DispatchMessageA(&msg);
1382 break;
1383 }
1384 if (!IsWindow())
1385 {
1386 ReleaseCapture();
1387 break;
1388 }
1389 } while (msg.message != WM_LBUTTONUP);
1390}
1391//******************************************************************************
1392//******************************************************************************
1393LONG Win32BaseWindow::HandleNCLButtonDown(WPARAM wParam,LPARAM lParam)
1394{
1395 switch(wParam) /* Hit test */
1396 {
1397 case HTCAPTION:
1398 SetActiveWindow();
1399 if (GetActiveWindow() == Win32Hwnd)
1400 SendInternalMessageA(WM_SYSCOMMAND,SC_MOVE+HTCAPTION,lParam);
1401 break;
1402
1403 case HTSYSMENU:
1404 if(dwStyle & WS_SYSMENU )
1405 {
1406 if( !(dwStyle & WS_MINIMIZE) )
1407 {
1408 HDC hDC = GetWindowDC(Win32Hwnd);
1409 DrawSysButton(hDC,TRUE);
1410 ReleaseDC(Win32Hwnd,hDC);
1411 }
1412 SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTSYSMENU,lParam);
1413 }
1414 break;
1415
1416 case HTMENU:
1417 SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU,lParam);
1418 break;
1419
1420 case HTHSCROLL:
1421 SendInternalMessageA(WM_SYSCOMMAND,SC_HSCROLL+HTHSCROLL,lParam);
1422 break;
1423
1424 case HTVSCROLL:
1425 SendInternalMessageA(WM_SYSCOMMAND,SC_VSCROLL+HTVSCROLL,lParam);
1426 break;
1427
1428 case HTMINBUTTON:
1429 case HTMAXBUTTON:
1430 TrackMinMaxBox(wParam);
1431 break;
1432
1433 case HTCLOSE:
1434 TrackCloseButton(wParam);
1435 break;
1436
1437 case HTLEFT:
1438 case HTRIGHT:
1439 case HTTOP:
1440 case HTTOPLEFT:
1441 case HTTOPRIGHT:
1442 case HTBOTTOM:
1443 case HTBOTTOMLEFT:
1444 case HTBOTTOMRIGHT:
1445 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
1446 SendInternalMessageA(WM_SYSCOMMAND,SC_SIZE+wParam-2,lParam);
1447 break;
1448 case HTBORDER:
1449 break;
1450 }
1451
1452 return 0;
1453}
1454//******************************************************************************
1455//******************************************************************************
1456BOOL Win32BaseWindow::WindowNeedsWMBorder()
1457{
1458 if (!(dwStyle & WS_CHILD) &&
1459 //Options.managed && //CB: to check
1460 !(dwExStyle & WS_EX_TOOLWINDOW) &&
1461 ( ((dwStyle & WS_CAPTION) == WS_CAPTION) ||
1462 (dwStyle & WS_THICKFRAME)))
1463 return TRUE;
1464 if (dwExStyle & WS_EX_TRAYWINDOW)
1465 return TRUE;
1466 return FALSE;
1467}
1468//******************************************************************************
1469//******************************************************************************
1470VOID Win32BaseWindow::AdjustRectOuter(LPRECT rect,BOOL menu)
1471{
1472 if(dwStyle & WS_ICONIC) return;
1473
1474 /* Decide if the window will be managed (see CreateWindowEx) */
1475 //if (!WindowNeedsWMBorder()) //CB: check Options.managed
1476 {
1477 if (HAS_THICKFRAME(dwStyle,dwExStyle ))
1478 InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
1479 else
1480 if (HAS_DLGFRAME( dwStyle, dwExStyle ))
1481 InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
1482 else
1483 if (HAS_THINFRAME( dwStyle ))
1484 InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
1485
1486 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
1487 {
1488 if (dwExStyle & WS_EX_TOOLWINDOW)
1489 rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
1490 else
1491 rect->top -= GetSystemMetrics(SM_CYCAPTION);
1492 }
1493 }
1494
1495 if (menu)
1496 rect->top -= GetSystemMetrics(SM_CYMENU);
1497}
1498//******************************************************************************
1499//******************************************************************************
1500VOID Win32BaseWindow::AdjustRectInner(LPRECT rect)
1501{
1502 if(dwStyle & WS_ICONIC) return;
1503
1504 if (dwExStyle & WS_EX_CLIENTEDGE)
1505 InflateRect (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
1506
1507 if (dwExStyle & WS_EX_STATICEDGE)
1508 InflateRect (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
1509
1510 if (dwStyle & WS_VSCROLL) rect->right += GetSystemMetrics(SM_CXVSCROLL);
1511 if (dwStyle & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
1512}
1513//******************************************************************************
1514//******************************************************************************
1515LONG Win32BaseWindow::HandleNCCalcSize(BOOL calcValidRects,RECT *winRect)
1516{
1517 RECT tmpRect = { 0, 0, 0, 0 },*clientRect;
1518 LONG result = WVR_ALIGNTOP | WVR_ALIGNLEFT;
1519 UINT style;
1520
1521 if (!calcValidRects) return 0;
1522
1523 style = (UINT) GetClassLongA(Win32Hwnd,GCL_STYLE);
1524
1525 if (style & CS_VREDRAW) result |= WVR_VREDRAW;
1526 if (style & CS_HREDRAW) result |= WVR_HREDRAW;
1527
1528 clientRect = &((NCCALCSIZE_PARAMS*)winRect)->rgrc[2];
1529 *clientRect = rectWindow;
1530 if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),clientRect);
1531
1532 if(!(dwStyle & WS_MINIMIZE))
1533 {
1534 AdjustRectOuter(&tmpRect,FALSE); //CB: todo: menu
1535
1536 clientRect->left -= tmpRect.left;
1537 clientRect->top -= tmpRect.top;
1538 clientRect->right -= tmpRect.right;
1539 clientRect->bottom -= tmpRect.bottom;
1540
1541 if (HAS_MENU(this))
1542 {
1543#if 0 //CB: todo
1544 winRect->top +=
1545 MENU_GetMenuBarHeight(Win32Hwnd,
1546 winRect->right - winRect->left,
1547 -tmpRect.left, -tmpRect.top ) + 1;
1548#endif
1549 }
1550
1551 SetRect (&tmpRect, 0, 0, 0, 0);
1552 AdjustRectInner(&tmpRect);
1553 clientRect->left -= tmpRect.left;
1554 clientRect->top -= tmpRect.top;
1555 clientRect->right -= tmpRect.right;
1556 clientRect->bottom -= tmpRect.bottom;
1557 }
1558
1559 return result;
1560}
1561//******************************************************************************
1562//******************************************************************************
1563LONG Win32BaseWindow::HandleNCHitTest(POINT pt)
1564{
1565 RECT rect = rectWindow;
1566
1567 if (!PtInRect(&rect,pt)) return HTNOWHERE;
1568
1569 if (dwStyle & WS_MINIMIZE) return HTCAPTION;
1570
1571 if (!(flags & WIN_MANAGED))
1572 {
1573 /* Check borders */
1574 if (HAS_THICKFRAME(dwStyle,dwExStyle))
1575 {
1576 InflateRect(&rect,-GetSystemMetrics(SM_CXFRAME),-GetSystemMetrics(SM_CYFRAME));
1577 if (!PtInRect(&rect,pt))
1578 {
1579 /* Check top sizing border */
1580 if (pt.y < rect.top)
1581 {
1582 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
1583 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
1584 return HTTOP;
1585 }
1586 /* Check bottom sizing border */
1587 if (pt.y >= rect.bottom)
1588 {
1589 if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
1590 if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
1591 return HTBOTTOM;
1592 }
1593 /* Check left sizing border */
1594 if (pt.x < rect.left)
1595 {
1596 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
1597 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
1598 return HTLEFT;
1599 }
1600 /* Check right sizing border */
1601 if (pt.x >= rect.right)
1602 {
1603 if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
1604 if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
1605 return HTRIGHT;
1606 }
1607 }
1608 } else /* No thick frame */
1609 {
1610 if (HAS_DLGFRAME(dwStyle,dwExStyle))
1611 InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
1612 else if (HAS_THINFRAME(dwStyle ))
1613 InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
1614 if (!PtInRect( &rect, pt )) return HTBORDER;
1615 }
1616
1617 /* Check caption */
1618
1619 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
1620 {
1621 if (dwExStyle & WS_EX_TOOLWINDOW)
1622 rect.top += GetSystemMetrics(SM_CYSMCAPTION)-1;
1623 else
1624 rect.top += GetSystemMetrics(SM_CYCAPTION)-1;
1625 if (!PtInRect(&rect,pt))
1626 {
1627 /* Check system menu */
1628 if(dwStyle & WS_SYSMENU)
1629 {
1630 /* Check if there is an user icon */
1631 HICON hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
1632 if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
1633
1634 /* If there is an icon associated with the window OR */
1635 /* If there is no hIcon specified and this is not a modal dialog, */
1636 /* there is a system menu icon. */
1637 if((hIcon != 0) || (!(dwStyle & DS_MODALFRAME)))
1638 rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
1639 }
1640 if (pt.x < rect.left) return HTSYSMENU;
1641
1642 /* Check close button */
1643 if (dwStyle & WS_SYSMENU)
1644 rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
1645 if (pt.x > rect.right) return HTCLOSE;
1646
1647 /* Check maximize box */
1648 /* In win95 there is automatically a Maximize button when there is a minimize one*/
1649 if ((dwStyle & WS_MAXIMIZEBOX)|| (dwStyle & WS_MINIMIZEBOX))
1650 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1651 if (pt.x > rect.right) return HTMAXBUTTON;
1652
1653 /* Check minimize box */
1654 /* In win95 there is automatically a Maximize button when there is a Maximize one*/
1655 if ((dwStyle & WS_MINIMIZEBOX)||(dwStyle & WS_MAXIMIZEBOX))
1656 rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1657
1658 if (pt.x > rect.right) return HTMINBUTTON;
1659 return HTCAPTION;
1660 }
1661 }
1662 }
1663
1664 /* Check client area */
1665
1666 ScreenToClient(Win32Hwnd,&pt);
1667 getClientRect(&rect);
1668 if (PtInRect(&rect,pt)) return HTCLIENT;
1669
1670 /* Check vertical scroll bar */
1671
1672 if (dwStyle & WS_VSCROLL)
1673 {
1674 rect.right += GetSystemMetrics(SM_CXVSCROLL);
1675 if (PtInRect( &rect, pt )) return HTVSCROLL;
1676 }
1677
1678 /* Check horizontal scroll bar */
1679
1680 if (dwStyle & WS_HSCROLL)
1681 {
1682 rect.bottom += GetSystemMetrics(SM_CYHSCROLL);
1683 if (PtInRect( &rect, pt ))
1684 {
1685 /* Check size box */
1686 if ((dwStyle & WS_VSCROLL) &&
1687 (pt.x >= rect.right - GetSystemMetrics(SM_CXVSCROLL)))
1688 return (dwStyle & WS_CHILD) ? HTSIZE:HTBOTTOMRIGHT;
1689 return HTHSCROLL;
1690 }
1691 }
1692
1693 /* Check menu bar */
1694
1695 if (HAS_MENU(this))
1696 {
1697 if ((pt.y < 0) && (pt.x >= 0) && (pt.x < rect.right))
1698 return HTMENU;
1699 }
1700
1701 /* Should never get here */
1702 return HTERROR;
1703}
1704
1705//******************************************************************************
1706//******************************************************************************
1707VOID Win32BaseWindow::GetInsideRect(RECT *rect)
1708{
1709 rect->top = rect->left = 0;
1710 rect->right = rectWindow.right - rectWindow.left;
1711 rect->bottom = rectWindow.bottom - rectWindow.top;
1712
1713 if ((dwStyle & WS_ICONIC) || (flags & WIN_MANAGED)) return;
1714
1715 /* Remove frame from rectangle */
1716 if (HAS_THICKFRAME(dwStyle,dwExStyle))
1717 {
1718 InflateRect( rect, -GetSystemMetrics(SM_CXSIZEFRAME), -GetSystemMetrics(SM_CYSIZEFRAME) );
1719 }
1720 else if (HAS_DLGFRAME(dwStyle,dwExStyle ))
1721 {
1722 InflateRect( rect, -GetSystemMetrics(SM_CXFIXEDFRAME), -GetSystemMetrics(SM_CYFIXEDFRAME));
1723 }
1724 else if (HAS_THINFRAME(dwStyle))
1725 {
1726 InflateRect( rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER) );
1727 }
1728
1729 /* We have additional border information if the window
1730 * is a child (but not an MDI child) */
1731 if ( (dwStyle & WS_CHILD) &&
1732 ( (dwExStyle & WS_EX_MDICHILD) == 0 ) )
1733 {
1734 if (dwExStyle & WS_EX_CLIENTEDGE)
1735 InflateRect (rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
1736
1737 if (dwExStyle & WS_EX_STATICEDGE)
1738 InflateRect (rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
1739 }
1740}
1741//******************************************************************************
1742//******************************************************************************
1743VOID Win32BaseWindow::DrawFrame(HDC hdc,RECT *rect,BOOL dlgFrame,BOOL active)
1744{
1745 INT width, height;
1746 HBRUSH oldBrush;
1747
1748 if (dlgFrame)
1749 {
1750 width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
1751 height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
1752 } else
1753 {
1754 width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXEDGE);
1755 height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYEDGE);
1756 }
1757
1758 oldBrush = SelectObject(hdc,GetSysColorBrush(active ? COLOR_ACTIVEBORDER:COLOR_INACTIVEBORDER));
1759
1760 /* Draw frame */
1761
1762 PatBlt(hdc,rect->left,rect->top,rect->right-rect->left,height,PATCOPY);
1763 PatBlt(hdc,rect->left,rect->top,width,rect->bottom-rect->top,PATCOPY);
1764 PatBlt(hdc,rect->left,rect->bottom-1,rect->right-rect->left,-height,PATCOPY);
1765 PatBlt(hdc,rect->right-1,rect->top,-width,rect->bottom-rect->top,PATCOPY);
1766 SelectObject(hdc,oldBrush);
1767
1768 InflateRect(rect,-width,-height);
1769}
1770//******************************************************************************
1771//******************************************************************************
1772BOOL Win32BaseWindow::DrawSysButton(HDC hdc,BOOL down)
1773{
1774 if(!(flags & WIN_MANAGED))
1775 {
1776 HICON hIcon;
1777 RECT rect;
1778
1779 GetInsideRect(&rect);
1780
1781 hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
1782 if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
1783
1784 /* If there is no hIcon specified or this is not a modal dialog, */
1785 /* get the default one. */
1786 if(hIcon == 0)
1787 if (!(dwStyle & DS_MODALFRAME))
1788 hIcon = LoadImageA(0, MAKEINTRESOURCEA(OIC_ODINICON), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
1789
1790 if (hIcon)
1791 DrawIconEx (hdc, rect.left + 2, rect.top + 2, hIcon,
1792 GetSystemMetrics(SM_CXSMICON),
1793 GetSystemMetrics(SM_CYSMICON),
1794 0, 0, DI_NORMAL);
1795
1796 return (hIcon != 0);
1797 }
1798 return FALSE;
1799}
1800//******************************************************************************
1801//******************************************************************************
1802BOOL Win32BaseWindow::DrawGrayButton(HDC hdc,int x,int y)
1803{
1804 HBITMAP hMaskBmp;
1805 HDC hdcMask = CreateCompatibleDC (0);
1806 HBRUSH hOldBrush;
1807 hMaskBmp = CreateBitmap (12, 10, 1, 1, lpGrayMask);
1808
1809 if(hMaskBmp == 0)
1810 return FALSE;
1811
1812 SelectObject (hdcMask, hMaskBmp);
1813
1814 /* Draw the grayed bitmap using the mask */
1815 hOldBrush = SelectObject (hdc, RGB(128, 128, 128));
1816 BitBlt (hdc, x, y, 12, 10,
1817 hdcMask, 0, 0, 0xB8074A);
1818
1819 /* Clean up */
1820 SelectObject (hdc, hOldBrush);
1821 DeleteObject(hMaskBmp);
1822 DeleteDC (hdcMask);
1823
1824 return TRUE;
1825}
1826//******************************************************************************
1827//******************************************************************************
1828VOID Win32BaseWindow::DrawCloseButton(HDC hdc,BOOL down,BOOL bGrayed)
1829{
1830 RECT rect;
1831 HDC hdcMem;
1832
1833 if( !(flags & WIN_MANAGED) )
1834 {
1835 BITMAP bmp;
1836 HBITMAP hBmp, hOldBmp;
1837
1838 GetInsideRect(&rect);
1839
1840 hdcMem = CreateCompatibleDC( hdc );
1841 hBmp = down ? hbitmapCloseD : hbitmapClose;
1842 hOldBmp = SelectObject (hdcMem, hBmp);
1843 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
1844
1845 BitBlt (hdc, rect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
1846 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
1847 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
1848
1849 if(bGrayed)
1850 DrawGrayButton(hdc,rect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
1851 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
1852
1853 SelectObject (hdcMem, hOldBmp);
1854 DeleteDC (hdcMem);
1855 }
1856}
1857//******************************************************************************
1858//******************************************************************************
1859VOID Win32BaseWindow::DrawMaxButton(HDC hdc,BOOL down,BOOL bGrayed)
1860{
1861 RECT rect;
1862 HDC hdcMem;
1863
1864 if( !(flags & WIN_MANAGED))
1865 {
1866 BITMAP bmp;
1867 HBITMAP hBmp,hOldBmp;
1868
1869 GetInsideRect(&rect);
1870 hdcMem = CreateCompatibleDC( hdc );
1871 hBmp = IsZoomed(Win32Hwnd) ?
1872 (down ? hbitmapRestoreD : hbitmapRestore ) :
1873 (down ? hbitmapMaximizeD: hbitmapMaximize);
1874 hOldBmp=SelectObject( hdcMem, hBmp );
1875 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
1876
1877 if (dwStyle & WS_SYSMENU)
1878 rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
1879
1880 BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
1881 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
1882 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
1883
1884 if(bGrayed)
1885 DrawGrayButton(hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
1886 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
1887
1888
1889 SelectObject (hdcMem, hOldBmp);
1890 DeleteDC( hdcMem );
1891 }
1892}
1893//******************************************************************************
1894//******************************************************************************
1895VOID Win32BaseWindow::DrawMinButton(HDC hdc,BOOL down,BOOL bGrayed)
1896{
1897 RECT rect;
1898 HDC hdcMem;
1899
1900 if( !(flags & WIN_MANAGED))
1901
1902 {
1903 BITMAP bmp;
1904 HBITMAP hBmp,hOldBmp;
1905
1906 GetInsideRect(&rect);
1907
1908 hdcMem = CreateCompatibleDC( hdc );
1909 hBmp = down ? hbitmapMinimizeD : hbitmapMinimize;
1910 hOldBmp= SelectObject( hdcMem, hBmp );
1911 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
1912
1913 if (dwStyle & WS_SYSMENU)
1914 rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
1915
1916 /* In win 95 there is always a Maximize box when there is a Minimize one */
1917 if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
1918 rect.right += -1 - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2;
1919
1920 BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
1921 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
1922 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
1923
1924 if(bGrayed)
1925 DrawGrayButton(hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
1926 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
1927
1928
1929 SelectObject (hdcMem, hOldBmp);
1930 DeleteDC( hdcMem );
1931 }
1932}
1933//******************************************************************************
1934//******************************************************************************
1935VOID Win32BaseWindow::DrawCaption(HDC hdc,RECT *rect,BOOL active)
1936{
1937 RECT r = *rect;
1938 char buffer[256];
1939 HPEN hPrevPen;
1940 HMENU hSysMenu;
1941
1942 if (flags & WIN_MANAGED) return;
1943
1944 hPrevPen = SelectObject( hdc, GetSysColorPen(COLOR_3DFACE) );
1945 MoveToEx( hdc, r.left, r.bottom - 1, NULL );
1946 LineTo( hdc, r.right, r.bottom - 1 );
1947 SelectObject( hdc, hPrevPen );
1948 r.bottom--;
1949
1950 //CB: todo:
1951 //COLOR_GRADIENTACTIVECAPTION
1952 //COLOR_GRADIENTINACTIVECAPTION
1953
1954 FillRect(hdc,&r,GetSysColorBrush(active ? COLOR_ACTIVECAPTION:COLOR_INACTIVECAPTION));
1955
1956 if (!hbitmapClose)
1957 {
1958 if (!(hbitmapClose = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSE)))) return;
1959 hbitmapCloseD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSED));
1960 hbitmapMinimize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCE));
1961 hbitmapMinimizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCED));
1962 hbitmapMaximize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOM));
1963 hbitmapMaximizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOMD));
1964 hbitmapRestore = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORE));
1965 hbitmapRestoreD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORED));
1966 }
1967
1968 if ((dwStyle & WS_SYSMENU) && !(dwExStyle & WS_EX_TOOLWINDOW))
1969 {
1970 if (DrawSysButton(hdc,FALSE))
1971 r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
1972 }
1973
1974 if (dwStyle & WS_SYSMENU)
1975 {
1976 UINT state;
1977#if 0 //CB: todo
1978 /* Go get the sysmenu */
1979 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
1980#else
1981state = 0;
1982#endif
1983 /* Draw a grayed close button if disabled and a normal one if SC_CLOSE is not there */
1984 DrawCloseButton(hdc, FALSE,
1985 ((((state & MF_DISABLED) || (state & MF_GRAYED))) && (state != 0xFFFFFFFF)));
1986 r.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
1987
1988 if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
1989 {
1990 /* In win95 the two buttons are always there */
1991 /* But if the menu item is not in the menu they're disabled*/
1992
1993 DrawMaxButton(hdc, FALSE, (!(dwStyle & WS_MAXIMIZEBOX)));
1994 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1995
1996 DrawMinButton(hdc, FALSE, (!(dwStyle & WS_MINIMIZEBOX)));
1997 r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
1998 }
1999 }
2000
2001 if (GetWindowTextA(buffer, sizeof(buffer) ))
2002 {
2003 NONCLIENTMETRICSA nclm;
2004 HFONT hFont, hOldFont;
2005 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
2006 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
2007 if (dwExStyle & WS_EX_TOOLWINDOW)
2008 hFont = CreateFontIndirectA (&nclm.lfSmCaptionFont);
2009 else
2010 hFont = CreateFontIndirectA (&nclm.lfCaptionFont);
2011 hOldFont = SelectObject (hdc, hFont);
2012 if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
2013 else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
2014 SetBkMode( hdc, TRANSPARENT );
2015 r.left += 2;
2016 DrawTextA( hdc, buffer, -1, &r,
2017 DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT );
2018 DeleteObject (SelectObject (hdc, hOldFont));
2019 }
2020}
2021//******************************************************************************
2022//******************************************************************************
2023VOID Win32BaseWindow::DoNCPaint(HRGN clip,BOOL suppress_menupaint)
2024{
2025 BOOL active = flags & WIN_NCACTIVATED;
2026 HDC hdc;
2027 RECT rect,rectClip,rfuzz;
2028
2029 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
2030 the call to GetDCEx implying that it is allowed not to use it either.
2031 However, the suggested GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN)
2032 will cause clipRgn to be deleted after ReleaseDC().
2033 Now, how is the "system" supposed to tell what happened?
2034 */
2035
2036 if (!(hdc = GetDCEx( Win32Hwnd, (clip > 1) ? clip : 0, DCX_USESTYLE | DCX_WINDOW |
2037 ((clip > 1) ?(DCX_INTERSECTRGN /*| DCX_KEEPCLIPRGN*/) : 0) ))) return;
2038
2039 rect.top = rect.left = 0;
2040 rect.right = rectWindow.right - rectWindow.left;
2041 rect.bottom = rectWindow.bottom - rectWindow.top;
2042
2043 if( clip > 1 )
2044 GetRgnBox( clip, &rectClip );
2045 else
2046 {
2047 clip = 0;
2048 rectClip = rect;
2049 }
2050
2051 SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
2052
2053 if(!(flags & WIN_MANAGED))
2054 {
2055 if (HAS_BIGFRAME( dwStyle, dwExStyle))
2056 {
2057 DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT | BF_ADJUST);
2058 }
2059 if (HAS_THICKFRAME( dwStyle, dwExStyle ))
2060 DrawFrame(hdc, &rect, FALSE, active );
2061 else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
2062 DrawFrame( hdc, &rect, TRUE, active );
2063 else if (HAS_THINFRAME( dwStyle ))
2064 {
2065 SelectObject( hdc, GetStockObject(NULL_BRUSH) );
2066 Rectangle( hdc, 0, 0, rect.right, rect.bottom );
2067 }
2068
2069 if ((dwStyle & WS_CAPTION) == WS_CAPTION)
2070 {
2071 RECT r = rect;
2072 if (dwExStyle & WS_EX_TOOLWINDOW)
2073 {
2074 r.bottom = rect.top + GetSystemMetrics(SM_CYSMCAPTION);
2075 rect.top += GetSystemMetrics(SM_CYSMCAPTION);
2076 }
2077 else
2078 {
2079 r.bottom = rect.top + GetSystemMetrics(SM_CYCAPTION);
2080 rect.top += GetSystemMetrics(SM_CYCAPTION);
2081 }
2082 if( !clip || IntersectRect( &rfuzz, &r, &rectClip ) )
2083 DrawCaption(hdc, &r, active);
2084 }
2085 }
2086#if 0 //CB: todo
2087 if (HAS_MENU(wndPtr))
2088 {
2089 RECT r = rect;
2090 r.bottom = rect.top + GetSystemMetrics(SM_CYMENU);
2091
2092 rect.top += MENU_DrawMenuBar( hdc, &r, hwnd, suppress_menupaint ) + 1;
2093 }
2094#endif
2095
2096 if (dwExStyle & WS_EX_CLIENTEDGE)
2097 DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
2098
2099 if (dwExStyle & WS_EX_STATICEDGE)
2100 DrawEdge (hdc, &rect, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
2101
2102 /* Draw the scroll-bars */
2103 if (dwStyle & WS_VSCROLL)
2104 SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_VERT,TRUE,TRUE);
2105 if (dwStyle & WS_HSCROLL)
2106 SCROLL_DrawScrollBar(Win32Hwnd,hdc,SB_HORZ,TRUE,TRUE);
2107
2108 /* Draw the "size-box" */
2109 if ((dwStyle & WS_VSCROLL) && (dwStyle & WS_HSCROLL))
2110 {
2111 RECT r = rect;
2112 r.left = r.right - GetSystemMetrics(SM_CXVSCROLL) + 1;
2113 r.top = r.bottom - GetSystemMetrics(SM_CYHSCROLL) + 1;
2114 FillRect( hdc, &r, GetSysColorBrush(COLOR_SCROLLBAR) );
2115 if (!(dwStyle & WS_CHILD))
2116 {
2117 POINT p1,p2;
2118 HPEN penDark = GetSysColorPen(COLOR_3DSHADOW);
2119 HPEN penWhite = GetSysColorPen(COLOR_3DHILIGHT);
2120 HPEN oldPen = SelectObject(hdc,penDark);
2121 INT x;
2122
2123 p1.x = r.right-1;
2124 p1.y = r.bottom;
2125 p2.x = r.right;
2126 p2.y = r.bottom-1;
2127 for (x = 0;x < 3;x++)
2128 {
2129 SelectObject(hdc,penDark);
2130 MoveToEx(hdc,p1.x,p1.y,NULL);
2131 LineTo(hdc,p2.x,p2.y);
2132 p1.x--;
2133 p2.y--;
2134 MoveToEx(hdc,p1.x,p1.y,NULL);
2135 LineTo(hdc,p2.x,p2.y);
2136 SelectObject(hdc,penWhite);
2137 p1.x--;
2138 p2.y--;
2139 MoveToEx(hdc,p1.x,p1.y,NULL);
2140 LineTo(hdc,p2.x,p2.y);
2141 p1.x -= 2;
2142 p2.y -= 2;
2143 }
2144
2145 SelectObject(hdc,oldPen);
2146 }
2147 }
2148
2149 ReleaseDC(Win32Hwnd,hdc);
2150}
2151//******************************************************************************
2152//******************************************************************************
2153LONG Win32BaseWindow::HandleNCPaint(HRGN clip)
2154{
2155//CB: ignore it for now (SetWindowPos in WM_CREATE)
2156// if (!(dwStyle & WS_VISIBLE)) return 0;
2157
2158 if (dwStyle & WS_MINIMIZE) return 0;
2159
2160 DoNCPaint(clip,FALSE);
2161
2162 return 0;
2163}
2164/***********************************************************************
2165 * NC_HandleNCLButtonDblClk
2166 *
2167 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
2168 */
2169LONG Win32BaseWindow::HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam)
2170{
2171 /*
2172 * if this is an icon, send a restore since we are handling
2173 * a double click
2174 */
2175 if (dwStyle & WS_MINIMIZE)
2176 {
2177 SendInternalMessageA(WM_SYSCOMMAND,SC_RESTORE,lParam);
2178 return 0;
2179 }
2180
2181 switch(wParam) /* Hit test */
2182 {
2183 case HTCAPTION:
2184 /* stop processing if WS_MAXIMIZEBOX is missing */
2185 if (dwStyle & WS_MAXIMIZEBOX)
2186 SendInternalMessageA(WM_SYSCOMMAND,
2187 (dwStyle & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE,
2188 lParam);
2189 break;
2190
2191 case HTSYSMENU:
2192 if (!(GetClassWord(Win32Hwnd,GCW_STYLE) & CS_NOCLOSE))
2193 SendInternalMessageA(WM_SYSCOMMAND,SC_CLOSE,lParam);
2194 break;
2195
2196 case HTHSCROLL:
2197 SendInternalMessageA(WM_SYSCOMMAND,SC_HSCROLL+HTHSCROLL,lParam);
2198 break;
2199
2200 case HTVSCROLL:
2201 SendInternalMessageA(WM_SYSCOMMAND,SC_VSCROLL+HTVSCROLL,lParam);
2202 break;
2203 }
2204
2205 return 0;
2206}
2207/***********************************************************************
2208 * NC_HandleSysCommand
2209 *
2210 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
2211 *
2212 * TODO: Not done (see #if 0)
2213 */
2214LONG Win32BaseWindow::HandleSysCommand(WPARAM wParam,POINT *pt32)
2215{
2216 UINT uCommand = wParam & 0xFFF0;
2217
2218/* //CB: don't need this, perhaps recycle for menus
2219 if ((getStyle() & WS_CHILD) && (uCommand != SC_KEYMENU))
2220 ScreenToClient(getParent()->getWindowHandle(), pt32 );
2221*/
2222 switch (uCommand)
2223 {
2224
2225 case SC_SIZE:
2226 {
2227 DWORD flags = 0;
2228
2229 switch ((wParam & 0xF)+2)
2230 {
2231 case HTLEFT:
2232 flags = TFOS_LEFT;
2233 break;
2234
2235 case HTRIGHT:
2236 flags = TFOS_RIGHT;
2237 break;
2238
2239 case HTTOP:
2240 flags = TFOS_TOP;
2241 break;
2242
2243 case HTTOPLEFT:
2244 flags = TFOS_TOP | TFOS_LEFT;
2245 break;
2246
2247 case HTTOPRIGHT:
2248 flags = TFOS_TOP | TFOS_RIGHT;
2249 break;
2250
2251 case HTBOTTOM:
2252 flags = TFOS_BOTTOM;
2253 break;
2254
2255 case HTBOTTOMLEFT:
2256 flags = TFOS_BOTTOM | TFOS_LEFT;
2257 break;
2258
2259 case HTBOTTOMRIGHT:
2260 flags = TFOS_BOTTOM | TFOS_RIGHT;
2261 break;
2262 }
2263 if (flags) FrameTrackFrame(this,flags);
2264 break;
2265 }
2266
2267 case SC_MOVE:
2268 FrameTrackFrame(this,TFOS_MOVE);
2269 break;
2270
2271 case SC_MINIMIZE:
2272 ShowWindow(SW_MINIMIZE);
2273 break;
2274
2275 case SC_MAXIMIZE:
2276 ShowWindow(SW_MAXIMIZE);
2277 break;
2278
2279 case SC_RESTORE:
2280 ShowWindow(SW_RESTORE);
2281 break;
2282
2283 case SC_CLOSE:
2284 return SendInternalMessageA(WM_CLOSE,0,0);
2285
2286 case SC_VSCROLL:
2287 case SC_HSCROLL:
2288 TrackScrollBar(wParam,*pt32);
2289 break;
2290#if 0
2291 case SC_MOUSEMENU:
2292 MENU_TrackMouseMenuBar( wndPtr, wParam & 0x000F, pt32 );
2293 break;
2294
2295 case SC_KEYMENU:
2296 MENU_TrackKbdMenuBar( wndPtr , wParam , pt.x );
2297 break;
2298#endif
2299 case SC_TASKLIST:
2300 WinExec("taskman.exe",SW_SHOWNORMAL);
2301 break;
2302
2303 case SC_SCREENSAVE:
2304 if (wParam == SC_ABOUTWINE)
2305 ShellAboutA(Win32Hwnd,"Odin","Odin alpha release compiled with IBM VAC++",0);
2306 else
2307 if (wParam == SC_PUTMARK)
2308 dprintf(("Mark requested by user\n"));
2309 break;
2310
2311 case SC_HOTKEY:
2312 case SC_ARRANGE:
2313 case SC_NEXTWINDOW:
2314 case SC_PREVWINDOW:
2315 break;
2316 }
2317 return 0;
2318}
2319//******************************************************************************
2320//******************************************************************************
2321LRESULT Win32BaseWindow::DefWndControlColor(UINT ctlType, HDC hdc)
2322{
2323 //SvL: Set background color to default button color (not window (white))
2324 if(ctlType == CTLCOLOR_BTN)
2325 {
2326 SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
2327 SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
2328 return GetSysColorBrush(COLOR_BTNFACE);
2329 }
2330 //SvL: Set background color to default dialog color if window is dialog
2331 if((ctlType == CTLCOLOR_DLG || ctlType == CTLCOLOR_STATIC) && IsDialog()) {
2332 SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
2333 SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
2334 return GetSysColorBrush(COLOR_BTNFACE);
2335 }
2336
2337 if( ctlType == CTLCOLOR_SCROLLBAR)
2338 {
2339 HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
2340 COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
2341 SetTextColor( hdc, GetSysColor(COLOR_3DFACE));
2342 SetBkColor( hdc, bk);
2343
2344//TODO?
2345#if 0
2346 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
2347 * we better use 0x55aa bitmap brush to make scrollbar's background
2348 * look different from the window background.
2349 */
2350 if (bk == GetSysColor(COLOR_WINDOW)) {
2351 return CACHE_GetPattern55AABrush();
2352 }
2353#endif
2354 UnrealizeObject( hb );
2355 return (LRESULT)hb;
2356 }
2357
2358 SetTextColor( hdc, GetSysColor(COLOR_WINDOWTEXT));
2359
2360 if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
2361 {
2362 SetBkColor( hdc, GetSysColor(COLOR_WINDOW) );
2363 }
2364 else
2365 {
2366 SetBkColor( hdc, GetSysColor(COLOR_3DFACE) );
2367 return (LRESULT)GetSysColorBrush(COLOR_3DFACE);
2368 }
2369 return (LRESULT)GetSysColorBrush(COLOR_WINDOW);
2370}
2371//******************************************************************************
2372//******************************************************************************
2373LRESULT Win32BaseWindow::DefWndPrint(HDC hdc,ULONG uFlags)
2374{
2375 /*
2376 * Visibility flag.
2377 */
2378 if ( (uFlags & PRF_CHECKVISIBLE) &&
2379 !IsWindowVisible() )
2380 return 0;
2381
2382 /*
2383 * Unimplemented flags.
2384 */
2385 if ( (uFlags & PRF_CHILDREN) ||
2386 (uFlags & PRF_OWNED) ||
2387 (uFlags & PRF_NONCLIENT) )
2388 {
2389 dprintf(("WM_PRINT message with unsupported flags\n"));
2390 }
2391
2392 /*
2393 * Background
2394 */
2395 if ( uFlags & PRF_ERASEBKGND)
2396 SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
2397
2398 /*
2399 * Client area
2400 */
2401 if ( uFlags & PRF_CLIENT)
2402 SendInternalMessageA(WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
2403
2404
2405 return 0;
2406}
2407//******************************************************************************
2408//******************************************************************************
2409LRESULT Win32BaseWindow::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam)
2410{
2411 switch(Msg)
2412 {
2413 case WM_CLOSE:
2414 dprintf(("DefWindowProcA: WM_CLOSE %x", getWindowHandle()));
2415 DestroyWindow();
2416 return 0;
2417
2418 case WM_GETTEXTLENGTH:
2419 return wndNameLength;
2420
2421 case WM_GETTEXT:
2422 if (!lParam || !wParam) return 0;
2423 if (!windowNameA) ((LPSTR)lParam)[0] = 0;
2424 else lstrcpynA((LPSTR)lParam, windowNameA, wParam);
2425 return min(wndNameLength, wParam);
2426
2427 case WM_SETTEXT:
2428 {
2429 LPCSTR lpsz = (LPCSTR)lParam;
2430
2431 if(windowNameA) free(windowNameA);
2432 if(windowNameW) free(windowNameW);
2433
2434 if (lParam)
2435 {
2436 wndNameLength = strlen(lpsz);
2437 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
2438 strcpy(windowNameA, lpsz);
2439 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
2440 lstrcpyAtoW(windowNameW, windowNameA);
2441 }
2442 else
2443 {
2444 windowNameA = NULL;
2445 windowNameW = NULL;
2446 wndNameLength = 0;
2447 }
2448 dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, lParam));
2449 if (dwStyle & WS_CAPTION)
2450 {
2451 //CB: optimize!
2452 HandleNCPaint(0);
2453 }
2454/* //CB: endless loop in trackbar.exe -> to fix
2455 if(OS2HwndFrame && (dwStyle & WS_CAPTION) == WS_CAPTION)
2456 return OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
2457*/
2458 return TRUE;
2459 }
2460
2461 case WM_SETREDRAW:
2462 {
2463 if (wParam)
2464 {
2465 setStyle(getStyle() | WS_VISIBLE);
2466 OSLibWinEnableWindowUpdate(OS2HwndFrame,TRUE);
2467 } else
2468 {
2469 if (getStyle() & WS_VISIBLE)
2470 {
2471 setStyle(getStyle() & ~WS_VISIBLE);
2472 OSLibWinEnableWindowUpdate(OS2HwndFrame,FALSE);
2473 }
2474 }
2475 return 0;
2476 }
2477
2478 case WM_NCPAINT:
2479 return HandleNCPaint((HRGN)wParam);
2480
2481 case WM_NCACTIVATE:
2482 return HandleNCActivate(wParam);
2483
2484 case WM_NCCREATE:
2485 return(TRUE);
2486
2487 case WM_NCDESTROY:
2488 return 0;
2489
2490 case WM_NCCALCSIZE:
2491 return HandleNCCalcSize((BOOL)wParam,(RECT*)lParam);
2492
2493 case WM_CTLCOLORMSGBOX:
2494 case WM_CTLCOLOREDIT:
2495 case WM_CTLCOLORLISTBOX:
2496 case WM_CTLCOLORBTN:
2497 case WM_CTLCOLORDLG:
2498 case WM_CTLCOLORSTATIC:
2499 case WM_CTLCOLORSCROLLBAR:
2500 return DefWndControlColor(Msg - WM_CTLCOLORMSGBOX, (HDC)wParam);
2501
2502 case WM_CTLCOLOR:
2503 return DefWndControlColor(HIWORD(lParam), (HDC)wParam);
2504
2505 case WM_VKEYTOITEM:
2506 case WM_CHARTOITEM:
2507 return -1;
2508
2509 case WM_PARENTNOTIFY:
2510 return 0;
2511
2512 case WM_MOUSEACTIVATE:
2513 {
2514 dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
2515 if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
2516 {
2517 if(getParent()) {
2518 LRESULT rc = getParent()->SendInternalMessageA(WM_MOUSEACTIVATE, wParam, lParam );
2519 if(rc) return rc;
2520 }
2521 }
2522 return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
2523 }
2524
2525 case WM_ACTIVATE:
2526 return 0;
2527
2528 case WM_SETCURSOR:
2529 {
2530 dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
2531 if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
2532 {
2533 if(getParent()) {
2534 LRESULT rc = getParent()->SendInternalMessageA(WM_SETCURSOR, wParam, lParam);
2535 if(rc) return rc;
2536 }
2537 }
2538 if (wParam == Win32Hwnd)
2539 {
2540 HCURSOR hCursor;
2541
2542 switch(LOWORD(lParam))
2543 {
2544 case HTLEFT:
2545 case HTRIGHT:
2546 hCursor = LoadCursorA(0,IDC_SIZEWEA);
2547 break;
2548
2549 case HTTOP:
2550 case HTBOTTOM:
2551 hCursor = LoadCursorA(0,IDC_SIZENSA);
2552 break;
2553
2554 case HTTOPLEFT:
2555 case HTBOTTOMRIGHT:
2556 hCursor = LoadCursorA(0,IDC_SIZENWSEA);
2557 break;
2558
2559 case HTTOPRIGHT:
2560 case HTBOTTOMLEFT:
2561 hCursor = LoadCursorA(0,IDC_SIZENESWA);
2562 break;
2563
2564 default:
2565 hCursor = windowClass ? windowClass->getCursor():LoadCursorA(0,IDC_ARROWA);
2566 break;
2567 }
2568
2569 if (hCursor)
2570 {
2571 SetCursor(hCursor);
2572 return 1;
2573 } else return 0;
2574 } else return 0;
2575 }
2576
2577 case WM_MOUSEMOVE:
2578 return 0;
2579
2580 case WM_WINDOWPOSCHANGED:
2581 {
2582
2583/* undocumented SWP flags - from SDK 3.1 */
2584#define SWP_NOCLIENTSIZE 0x0800
2585#define SWP_NOCLIENTMOVE 0x1000
2586
2587 PWINDOWPOS wpos = (PWINDOWPOS)lParam;
2588 WPARAM wp = SIZE_RESTORED;
2589
2590 if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE))
2591 SendInternalMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
2592
2593 if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE))
2594 {
2595 if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
2596 else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
2597
2598 SendInternalMessageA(WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left,
2599 rectClient.bottom - rectClient.top));
2600 }
2601 return 0;
2602 }
2603 case WM_WINDOWPOSCHANGING:
2604 return HandleWindowPosChanging((WINDOWPOS *)lParam);
2605
2606 case WM_ERASEBKGND:
2607 case WM_ICONERASEBKGND:
2608 {
2609 RECT rect;
2610 int rc;
2611
2612 if (!windowClass || !windowClass->getBackgroundBrush()) return 0;
2613
2614 rc = GetClipBox( (HDC)wParam, &rect );
2615 if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
2616 {
2617 HBRUSH hBrush = windowClass->getBackgroundBrush();
2618
2619 if (hBrush <= (HBRUSH)(SYSCOLOR_GetLastColor()+1)) hBrush = GetSysColorBrush(hBrush-1);
2620
2621 FillRect( (HDC)wParam, &rect, hBrush);
2622 }
2623
2624 return 1;
2625 }
2626
2627 case WM_PRINT:
2628 return DefWndPrint(wParam,lParam);
2629
2630 case WM_PAINTICON:
2631 case WM_PAINT:
2632 {
2633 PAINTSTRUCT ps;
2634 HDC hdc = BeginPaint(getWindowHandle(), &ps );
2635 if( hdc )
2636 {
2637 if( (getStyle() & WS_MINIMIZE) && getWindowClass()->getIcon())
2638 {
2639 int x = (rectWindow.right - rectWindow.left - GetSystemMetrics(SM_CXICON))/2;
2640 int y = (rectWindow.bottom - rectWindow.top - GetSystemMetrics(SM_CYICON))/2;
2641 dprintf(("Painting class icon: vis rect=(%i,%i - %i,%i)\n", ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ));
2642 DrawIcon(hdc, x, y, getWindowClass()->getIcon() );
2643 }
2644 EndPaint(getWindowHandle(), &ps );
2645 }
2646 return 0;
2647 }
2648
2649 case WM_GETDLGCODE:
2650 return 0;
2651
2652 case WM_NCLBUTTONDOWN:
2653 return HandleNCLButtonDown(wParam,lParam);
2654
2655 case WM_LBUTTONDBLCLK:
2656 case WM_NCLBUTTONDBLCLK:
2657 return HandleNCLButtonDblClk(wParam,lParam);
2658
2659 case WM_NCRBUTTONDOWN:
2660 case WM_NCRBUTTONDBLCLK:
2661 case WM_NCMBUTTONDOWN:
2662 case WM_NCMBUTTONDBLCLK:
2663 if (lastHitTestVal == HTERROR) MessageBeep(MB_ICONEXCLAMATION);
2664 return 0;
2665
2666 case WM_NCRBUTTONUP:
2667 case WM_NCMBUTTONUP:
2668 return 0;
2669
2670 case WM_NCHITTEST:
2671 {
2672 POINT point;
2673
2674 point.x = (SHORT)LOWORD(lParam);
2675 point.y = (SHORT)HIWORD(lParam);
2676
2677 return HandleNCHitTest(point);
2678 }
2679
2680 case WM_SYSCOMMAND:
2681 {
2682 POINT point;
2683
2684 point.x = LOWORD(lParam);
2685 point.y = HIWORD(lParam);
2686 return HandleSysCommand(wParam,&point);
2687 }
2688
2689 case WM_SYSKEYDOWN:
2690 if(wParam == VK_F4) /* try to close the window */
2691 {
2692 Win32BaseWindow *window = GetTopParent();
2693 if(window && !(window->getClass()->getStyle() & CS_NOCLOSE))
2694 PostMessageA(getWindowHandle(), WM_SYSCOMMAND, SC_CLOSE, 0);
2695 }
2696
2697 Win32BaseWindow *siblingWindow;
2698 HWND sibling;
2699 char nameBuffer [40], mnemonic;
2700 int nameLength;
2701
2702 GetWindowTextA (nameBuffer, 40);
2703
2704 // search all sibling to see it this key is their mnemonic
2705 sibling = GetWindow (GW_HWNDFIRST);
2706 while (sibling != 0) {
2707 siblingWindow = GetWindowFromHandle (sibling);
2708 nameLength = siblingWindow->GetWindowTextA (nameBuffer, 40);
2709
2710 // find the siblings mnemonic
2711 mnemonic = '\0';
2712 for (int i=0 ; i<nameLength ; i++) {
2713 if (nameBuffer [i] == '&') {
2714 mnemonic = nameBuffer [i+1];
2715 if ((mnemonic >= 'a') && (mnemonic <= 'z'))
2716 mnemonic -= 32; // make it uppercase
2717 break; // stop searching
2718 }
2719 }
2720
2721 // key matches siblings mnemonic, send mouseclick
2722 if (mnemonic == (char) wParam) {
2723 siblingWindow->SendInternalMessageA (BM_CLICK, 0, 0);
2724 }
2725
2726 sibling = siblingWindow->GetNextWindow (GW_HWNDNEXT);
2727 }
2728
2729 return 0;
2730
2731 case WM_SHOWWINDOW:
2732 if (!lParam) return 0; /* sent from ShowWindow */
2733 if (!(dwStyle & WS_POPUP) || !owner) return 0;
2734 if ((dwStyle & WS_VISIBLE) && wParam) return 0;
2735 else if (!(dwStyle & WS_VISIBLE) && !wParam) return 0;
2736 ShowWindow(wParam ? SW_SHOWNOACTIVATE : SW_HIDE);
2737 return 0;
2738
2739 case WM_CANCELMODE:
2740 //if (getParent() == windowDesktop) EndMenu();
2741 if (GetCapture() == Win32Hwnd) ReleaseCapture();
2742 return 0;
2743
2744 case WM_DROPOBJECT:
2745 return DRAG_FILE;
2746
2747 case WM_QUERYDROPOBJECT:
2748 if (dwExStyle & WS_EX_ACCEPTFILES) return 1;
2749 return 0;
2750
2751 case WM_QUERYDRAGICON:
2752 {
2753 HICON hIcon = windowClass->getCursor();
2754 UINT len;
2755
2756 if(hIcon) return (LRESULT)hIcon;
2757 for(len = 1; len < 64; len++)
2758 {
2759 hIcon = LoadIconA(hInstance,MAKEINTRESOURCEA(len));
2760 if(hIcon)
2761 return (LRESULT)hIcon;
2762 }
2763 return (LRESULT)LoadIconA(0,IDI_APPLICATIONA);
2764 }
2765
2766 case WM_QUERYOPEN:
2767 case WM_QUERYENDSESSION:
2768 return 1;
2769
2770 case WM_NOTIFYFORMAT:
2771 if (IsWindowUnicode()) return NFR_UNICODE;
2772 else return NFR_ANSI;
2773
2774 case WM_SETICON:
2775 case WM_GETICON:
2776 {
2777 LRESULT result = 0;
2778 if (!windowClass) return result;
2779 int index = GCL_HICON;
2780
2781 if (wParam == ICON_SMALL)
2782 index = GCL_HICONSM;
2783
2784 result = windowClass->getClassLongA(index);
2785
2786 if (Msg == WM_SETICON)
2787 windowClass->setClassLongA(index, lParam);
2788
2789 return result;
2790 }
2791
2792 case WM_NOTIFY:
2793 return 0; //comctl32 controls expect this
2794
2795 default:
2796 if(Msg > WM_USER) {
2797 return 0;
2798 }
2799 return 1; //CB: shouldn't this be 0?
2800 }
2801}
2802//******************************************************************************
2803//******************************************************************************
2804LRESULT Win32BaseWindow::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam)
2805{
2806 switch(Msg)
2807 {
2808 case WM_GETTEXTLENGTH:
2809 return wndNameLength;
2810
2811 case WM_GETTEXT:
2812 if (!lParam || !wParam) return 0;
2813 if (!windowNameW) ((LPWSTR)lParam)[0] = 0;
2814 else lstrcpynW((LPWSTR)lParam,windowNameW,wParam);
2815 return min(wndNameLength,wParam);
2816
2817 case WM_SETTEXT:
2818 {
2819 LPWSTR lpsz = (LPWSTR)lParam;
2820
2821 if(windowNameA) free(windowNameA);
2822 if(windowNameW) free(windowNameW);
2823
2824 if (lParam)
2825 {
2826 wndNameLength = lstrlenW(lpsz);
2827 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
2828 lstrcpyWtoA(windowNameA,lpsz);
2829 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
2830 lstrcpyW(windowNameW,lpsz);
2831 }
2832 else
2833 {
2834 windowNameA = NULL;
2835 windowNameW = NULL;
2836 wndNameLength = 0;
2837 }
2838
2839 if(OS2HwndFrame && (dwStyle & WS_CAPTION) == WS_CAPTION)
2840 return OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
2841
2842 return TRUE;
2843 }
2844
2845 default:
2846 return DefWindowProcA(Msg, wParam, lParam);
2847 }
2848}
2849//******************************************************************************
2850//******************************************************************************
2851LRESULT Win32BaseWindow::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
2852{
2853 //if the destination window is created by this process & thread, call window proc directly
2854 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
2855 return SendInternalMessageA(Msg, wParam, lParam);
2856 }
2857 //otherwise use WinSendMsg to send it to the right process/thread
2858 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, FALSE);
2859}
2860//******************************************************************************
2861//******************************************************************************
2862LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
2863{
2864 //if the destination window is created by this process & thread, call window proc directly
2865 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
2866 return SendInternalMessageW(Msg, wParam, lParam);
2867 }
2868 //otherwise use WinSendMsg to send it to the right process/thread
2869 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, TRUE);
2870}
2871//******************************************************************************
2872//Called as a result of an OS/2 message or called from a class method
2873//******************************************************************************
2874LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
2875{
2876 LRESULT rc;
2877 BOOL fInternalMsgBackup = fInternalMsg;
2878
2879 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE);
2880
2881 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, FALSE);
2882
2883 fInternalMsg = TRUE;
2884 switch(Msg)
2885 {
2886 case WM_CREATE:
2887 {
2888 if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
2889 dprintf(("WM_CREATE returned -1\n"));
2890 rc = -1; //don't create window
2891 break;
2892 }
2893 rc = 0;
2894 break;
2895 }
2896 case WM_LBUTTONDOWN:
2897 case WM_MBUTTONDOWN:
2898 case WM_RBUTTONDOWN:
2899 {
2900 if (getParent())
2901 {
2902 POINTS pt = MAKEPOINTS(lParam);
2903 POINT point;
2904
2905 point.x = pt.x;
2906 point.y = pt.y;
2907 mapWin32Point(OS2Hwnd,getParent()->getOS2WindowHandle(),(OSLIBPOINT*)&point);
2908 NotifyParent(Msg,wParam,MAKELPARAM(point.x,point.y));
2909 }
2910 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
2911 break;
2912 }
2913
2914 case WM_DESTROY:
2915 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
2916 break;
2917
2918 default:
2919 rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
2920 break;
2921 }
2922 fInternalMsg = fInternalMsgBackup;
2923 return rc;
2924}
2925//******************************************************************************
2926//Called as a result of an OS/2 message or called from a class method
2927//******************************************************************************
2928LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
2929{
2930 LRESULT rc;
2931 BOOL fInternalMsgBackup = fInternalMsg;
2932
2933 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE);
2934
2935 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, TRUE);
2936
2937 fInternalMsg = TRUE;
2938 switch(Msg)
2939 {
2940 case WM_CREATE:
2941 {
2942 if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
2943 dprintf(("WM_CREATE returned -1\n"));
2944 rc = -1; //don't create window
2945 break;
2946 }
2947 rc = 0;
2948 break;
2949 }
2950 case WM_LBUTTONDOWN:
2951 case WM_MBUTTONDOWN:
2952 case WM_RBUTTONDOWN:
2953 NotifyParent(Msg, wParam, lParam);
2954 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
2955 break;
2956
2957 case WM_DESTROY:
2958 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
2959 break;
2960 default:
2961 rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
2962 break;
2963 }
2964 fInternalMsg = fInternalMsgBackup;
2965 return rc;
2966}
2967//******************************************************************************
2968//******************************************************************************
2969void Win32BaseWindow::CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
2970{
2971 CWPSTRUCT cwp;
2972
2973 cwp.lParam = lParam;
2974 cwp.wParam = wParam;
2975 cwp.message = Msg;
2976 cwp.hwnd = getWindowHandle();
2977
2978 switch(hooktype) {
2979 case WH_CALLWNDPROC:
2980 if(fUnicode) {
2981 HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
2982 }
2983 else HOOK_CallHooksA(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
2984 break;
2985 }
2986}
2987//******************************************************************************
2988//******************************************************************************
2989//******************************************************************************
2990//TODO: Do this more efficiently
2991//******************************************************************************
2992LRESULT Win32BaseWindow::BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam)
2993{
2994 Win32BaseWindow *window;
2995 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
2996
2997 dprintf(("BroadCastMessageA %x %x %x", msg, wParam, lParam, GetFS()));
2998
2999 for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
3000 window = GetWindowFromHandle(hwnd++);
3001 if(window) {
3002 if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
3003 {
3004
3005 if(type == BROADCAST_SEND) {
3006 window->SendInternalMessageA(msg, wParam, lParam);
3007 }
3008 else PostMessageA(window->getWindowHandle(), msg, wParam, lParam);
3009 }
3010 }
3011 }
3012 return 0;
3013}
3014//******************************************************************************
3015//TODO: Do this more efficiently
3016//******************************************************************************
3017LRESULT Win32BaseWindow::BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam)
3018{
3019 Win32BaseWindow *window;
3020 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
3021
3022 dprintf(("BroadCastMessageW %x %x %x", msg, wParam, lParam));
3023
3024 for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
3025 window = GetWindowFromHandle(hwnd++);
3026 if(window) {
3027 if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
3028 {
3029
3030 if(type == BROADCAST_SEND) {
3031 window->SendInternalMessageW(msg, wParam, lParam);
3032 }
3033 else PostMessageW(window->getWindowHandle(), msg, wParam, lParam);
3034 }
3035 }
3036 }
3037 return 0;
3038}
3039//******************************************************************************
3040//******************************************************************************
3041void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
3042{
3043 Win32BaseWindow *window = this;
3044 Win32BaseWindow *parentwindow;
3045
3046 while(window)
3047 {
3048 if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
3049 {
3050 /* Notify the parent window only */
3051 parentwindow = window->getParent();
3052 if(parentwindow) {
3053 parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam );
3054 }
3055 }
3056 else break;
3057
3058 window = parentwindow;
3059 }
3060}
3061//******************************************************************************
3062//******************************************************************************
3063BOOL Win32BaseWindow::SetIcon(HICON hIcon)
3064{
3065 dprintf(("Win32BaseWindow::SetIcon %x", hIcon));
3066 if(OSLibWinSetIcon(OS2HwndFrame, hIcon) == TRUE) {
3067//TODO: Wine does't send these. Correct?
3068// SendInternalMessageA(WM_SETICON, ICON_BIG, hIcon);
3069 return TRUE;
3070 }
3071 return FALSE;
3072}
3073//******************************************************************************
3074//******************************************************************************
3075BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow)
3076{
3077 ULONG showstate = 0;
3078 HWND hWinAfter;
3079
3080 dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
3081#if 1
3082 if (flags & WIN_NEED_SIZE)
3083 {
3084 /* should happen only in CreateWindowEx() */
3085 int wParam = SIZE_RESTORED;
3086
3087 flags &= ~WIN_NEED_SIZE;
3088 if (dwStyle & WS_MAXIMIZE)
3089 wParam = SIZE_MAXIMIZED;
3090 else
3091 if (dwStyle & WS_MINIMIZE)
3092 wParam = SIZE_MINIMIZED;
3093
3094 SendInternalMessageA(WM_SIZE, wParam,
3095 MAKELONG(rectClient.right-rectClient.left,
3096 rectClient.bottom-rectClient.top));
3097 SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
3098 }
3099#else
3100 if(fFirstShow) {
3101 if(isFrameWindow() && IS_OVERLAPPED(getStyle()) && !isChild()) {
3102 SendInternalMessageA(WM_SIZE, SIZE_RESTORED,
3103 MAKELONG(rectClient.right-rectClient.left,
3104 rectClient.bottom-rectClient.top));
3105 SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
3106
3107 }
3108 fFirstShow = FALSE;
3109 }
3110#endif
3111 switch(nCmdShow)
3112 {
3113 case SW_SHOW:
3114 case SW_SHOWDEFAULT: //todo
3115 showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
3116 break;
3117 case SW_HIDE:
3118 showstate = SWPOS_HIDE;
3119 break;
3120 case SW_RESTORE:
3121 showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
3122 break;
3123 case SW_MINIMIZE:
3124 showstate = SWPOS_MINIMIZE;
3125 break;
3126 case SW_SHOWMAXIMIZED:
3127 showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
3128 break;
3129 case SW_SHOWMINIMIZED:
3130 showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
3131 break;
3132 case SW_SHOWMINNOACTIVE:
3133 showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
3134 break;
3135 case SW_SHOWNA:
3136 showstate = SWPOS_SHOW;
3137 break;
3138 case SW_SHOWNOACTIVATE:
3139 showstate = SWPOS_SHOW;
3140 break;
3141 case SW_SHOWNORMAL:
3142 showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
3143 break;
3144 }
3145
3146 /* We can't activate a child window (WINE) */
3147 if(getStyle() & WS_CHILD)
3148 showstate &= ~SWPOS_ACTIVATE;
3149
3150 if(showstate & SWPOS_SHOW) {
3151 setStyle(getStyle() | WS_VISIBLE);
3152 }
3153 else setStyle(getStyle() & ~WS_VISIBLE);
3154
3155 BOOL rc = OSLibWinShowWindow(OS2HwndFrame, showstate);
3156
3157 return rc;
3158}
3159//******************************************************************************
3160//******************************************************************************
3161BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
3162{
3163 BOOL rc = FALSE;
3164 Win32BaseWindow *window;
3165 HWND hParent = 0;
3166
3167 dprintf (("SetWindowPos %x %x (%d,%d)(%d,%d) %x", Win32Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
3168
3169 if (fuFlags &
3170 ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
3171 SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED |
3172 SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS |
3173 SWP_NOOWNERZORDER))
3174 {
3175 return FALSE;
3176 }
3177
3178 WINDOWPOS wpos;
3179 SWP swp, swpOld;
3180
3181 wpos.flags = fuFlags;
3182 wpos.cy = cy;
3183 wpos.cx = cx;
3184 wpos.x = x;
3185 wpos.y = y;
3186 wpos.hwndInsertAfter = hwndInsertAfter;
3187 wpos.hwnd = getWindowHandle();
3188
3189 if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
3190 {
3191 if (isChild())
3192 {
3193 Win32BaseWindow *windowParent = getParent();
3194 if(windowParent) {
3195 hParent = getParent()->getOS2WindowHandle();
3196 }
3197 else dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
3198 }
3199 OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
3200 }
3201
3202 OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame);
3203 if (swp.fl == 0)
3204 return TRUE;
3205
3206// if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
3207 if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
3208 {
3209 Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
3210 if(wndBehind) {
3211 swp.hwndInsertBehind = wndBehind->getOS2FrameWindowHandle();
3212 }
3213 else {
3214 dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
3215 swp.hwndInsertBehind = 0;
3216 }
3217 }
3218//CB: todo
3219 #if 0
3220 if (isFrameWindow())
3221 {
3222 if (!isChild())
3223 {
3224 POINT maxSize, maxPos, minTrack, maxTrack;
3225
3226 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
3227
3228 if (swp.cx > maxTrack.x) swp.cx = maxTrack.x;
3229 if (swp.cy > maxTrack.y) swp.cy = maxTrack.y;
3230 if (swp.cx < minTrack.x) swp.cx = minTrack.x;
3231 if (swp.cy < minTrack.y) swp.cy = minTrack.y;
3232 }
3233 swp.hwnd = OS2HwndFrame;
3234 }
3235 else
3236#endif
3237 swp.hwnd = OS2HwndFrame;
3238
3239 dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
3240
3241 rc = OSLibWinSetMultWindowPos(&swp, 1);
3242
3243 if (rc == FALSE)
3244 {
3245 dprintf(("OSLibWinSetMultWindowPos failed! Error %x",OSLibWinGetLastError()));
3246 }
3247
3248 if (fuFlags == SWP_FRAMECHANGED)
3249 {
3250 //CB: optimize: if frame size has changed not necessary!
3251 FrameUpdateFrame(this,0);
3252 }
3253
3254 return (rc);
3255}
3256//******************************************************************************
3257//TODO: WPF_RESTOREMAXIMIZED
3258//******************************************************************************
3259BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *winpos)
3260{
3261 if(isFrameWindow())
3262 {
3263 // Set the minimized position
3264 if (winpos->flags & WPF_SETMINPOSITION)
3265 {
3266 OSLibSetWindowMinPos(OS2HwndFrame, winpos->ptMinPosition.x, winpos->ptMinPosition.y);
3267 }
3268
3269 //TODO: Max position
3270
3271 // Set the new restore position.
3272 OSLibSetWindowRestoreRect(OS2HwndFrame, &winpos->rcNormalPosition);
3273 }
3274
3275 return ShowWindow(winpos->showCmd);
3276}
3277//******************************************************************************
3278//Also destroys all the child windows (destroy children first, parent last)
3279//******************************************************************************
3280BOOL Win32BaseWindow::DestroyWindow()
3281{
3282 /* Call hooks */
3283 if(HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, getWindowHandle(), 0L))
3284 {
3285 return FALSE;
3286 }
3287
3288 if(!(getStyle() & WS_CHILD) && getOwner() == NULL)
3289 {
3290 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWDESTROYED, getWindowHandle(), 0L);
3291 /* FIXME: clean up palette - see "Internals" p.352 */
3292 }
3293
3294 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
3295 {
3296 if(getParent())
3297 {
3298 /* Notify the parent window only */
3299 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
3300 if( !::IsWindow(getWindowHandle()) )
3301 {
3302 return TRUE;
3303 }
3304 }
3305 else DebugInt3();
3306 }
3307 fDestroyWindowCalled = TRUE;
3308 return OSLibWinDestroyWindow(OS2HwndFrame);
3309}
3310//******************************************************************************
3311//******************************************************************************
3312Win32BaseWindow *Win32BaseWindow::getParent()
3313{
3314 Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::GetParent();
3315 return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
3316}
3317//******************************************************************************
3318//******************************************************************************
3319HWND Win32BaseWindow::GetParent()
3320{
3321 Win32BaseWindow *wndparent;
3322
3323 if ((!(getStyle() & (WS_POPUP|WS_CHILD))))
3324 {
3325 return 0;
3326 }
3327 wndparent = ((getStyle() & WS_CHILD) ? getParent() : getOwner());
3328
3329 return (wndparent) ? wndparent->getWindowHandle() : 0;
3330}
3331//******************************************************************************
3332//******************************************************************************
3333HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
3334{
3335 HWND oldhwnd;
3336 Win32BaseWindow *newparent;
3337
3338 if(getParent()) {
3339 oldhwnd = getParent()->getWindowHandle();
3340 getParent()->RemoveChild(this);
3341 }
3342 else oldhwnd = 0;
3343
3344 newparent = GetWindowFromHandle(hwndNewParent);
3345 if(newparent)
3346 {
3347 setParent(newparent);
3348 getParent()->AddChild(this);
3349 OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
3350 return oldhwnd;
3351 }
3352 else {
3353 setParent(windowDesktop);
3354 windowDesktop->AddChild(this);
3355 OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
3356 return oldhwnd;
3357 }
3358}
3359//******************************************************************************
3360//******************************************************************************
3361BOOL Win32BaseWindow::IsChild(HWND hwndParent)
3362{
3363 if(getParent()) {
3364 return getParent()->getWindowHandle() == hwndParent;
3365 }
3366 else return 0;
3367}
3368//******************************************************************************
3369//******************************************************************************
3370HWND Win32BaseWindow::GetTopWindow()
3371{
3372 return GetWindow(GW_CHILD);
3373}
3374//******************************************************************************
3375// Get the top-level parent for a child window.
3376//******************************************************************************
3377Win32BaseWindow *Win32BaseWindow::GetTopParent()
3378{
3379 Win32BaseWindow *window = this;
3380
3381 while(window && (window->getStyle() & WS_CHILD))
3382 {
3383 window = window->getParent();
3384 }
3385 return window;
3386}
3387//******************************************************************************
3388//Don't call WinUpdateWindow as that one also updates the child windows
3389//Also need to send WM_PAINT directly to the window procedure, which doesn't
3390//always happen with WinUpdateWindow (could be posted if thread doesn't own window)
3391//******************************************************************************
3392BOOL Win32BaseWindow::UpdateWindow()
3393{
3394 RECT rect;
3395
3396 if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect))
3397 {//update region not empty
3398 HDC hdc;
3399
3400 hdc = O32_GetDC(OS2Hwnd);
3401 if (isIcon)
3402 {
3403 SendInternalMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
3404 SendInternalMessageA(WM_PAINTICON, 0, 0);
3405 }
3406 else
3407 {
3408 SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
3409 SendInternalMessageA(WM_PAINT, 0, 0);
3410 }
3411 O32_ReleaseDC(OS2Hwnd, hdc);
3412 }
3413 return TRUE;
3414}
3415//******************************************************************************
3416//******************************************************************************
3417BOOL Win32BaseWindow::IsIconic()
3418{
3419 return OSLibWinIsIconic(OS2Hwnd);
3420}
3421//******************************************************************************
3422//TODO: Should not enumerate children that are created during the enumeration!
3423//******************************************************************************
3424BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
3425{
3426 BOOL rc = TRUE;
3427 HWND hwnd;
3428 Win32BaseWindow *prevchild = 0, *child = 0;
3429
3430 dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
3431 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
3432 {
3433 dprintf(("EnumChildWindows: enumerating child %x", child->getWindowHandle()));
3434 hwnd = child->getWindowHandle();
3435 if(child->getOwner()) {
3436 continue; //shouldn't have an owner (Wine)
3437 }
3438 if(lpfn(hwnd, lParam) == FALSE)
3439 {
3440 rc = FALSE;
3441 break;
3442 }
3443 //check if the window still exists
3444 if(!::IsWindow(hwnd))
3445 {
3446 child = prevchild;
3447 continue;
3448 }
3449 if(child->getFirstChild() != NULL)
3450 {
3451 dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle()));
3452 if(child->EnumChildWindows(lpfn, lParam) == FALSE)
3453 {
3454 rc = FALSE;
3455 break;
3456 }
3457 }
3458 prevchild = child;
3459 }
3460 return rc;
3461}
3462//******************************************************************************
3463//Enumerate first-level children only and check thread id
3464//******************************************************************************
3465BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
3466{
3467 Win32BaseWindow *child = 0;
3468 ULONG tid, pid;
3469 BOOL rc;
3470 HWND hwnd;
3471
3472 dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam));
3473
3474 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
3475 {
3476 OSLibWinQueryWindowProcess(child->getOS2WindowHandle(), &pid, &tid);
3477
3478 if(dwThreadId == tid) {
3479 dprintf2(("EnumThreadWindows: Found Window %x", child->getWindowHandle()));
3480 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
3481 break;
3482 }
3483 }
3484 }
3485 return TRUE;
3486}
3487//******************************************************************************
3488//Enumerate first-level children only
3489//******************************************************************************
3490BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
3491{
3492 Win32BaseWindow *child = 0;
3493 BOOL rc;
3494 HWND hwnd;
3495
3496 dprintf(("EnumWindows %x %x", lpfn, lParam));
3497
3498 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
3499 {
3500 hwnd = child->getWindowHandle();
3501
3502 dprintf2(("EnumWindows: Found Window %x", child->getWindowHandle()));
3503 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
3504 break;
3505 }
3506 }
3507 return TRUE;
3508}
3509//******************************************************************************
3510//******************************************************************************
3511Win32BaseWindow *Win32BaseWindow::FindWindowById(int id)
3512{
3513 for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
3514 {
3515 if (child->getWindowId() == id)
3516 {
3517 return child;
3518 }
3519 }
3520 return 0;
3521}
3522//******************************************************************************
3523//TODO:
3524//We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
3525//the current process owns them.
3526//******************************************************************************
3527HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
3528 BOOL fUnicode)
3529{
3530 Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
3531 Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
3532
3533 if((hwndParent != OSLIB_HWND_DESKTOP && !parent) ||
3534 (hwndChildAfter != 0 && !child) ||
3535 (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0))
3536 {
3537 dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
3538 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
3539 return 0;
3540 }
3541 if(hwndParent != OSLIB_HWND_DESKTOP)
3542 {//if the current process owns the window, just do a quick search
3543 child = (Win32BaseWindow *)parent->getFirstChild();
3544 if(hwndChildAfter != 0)
3545 {
3546 while(child)
3547 {
3548 if(child->getWindowHandle() == hwndChildAfter)
3549 {
3550 child = (Win32BaseWindow *)child->getNextChild();
3551 break;
3552 }
3553 child = (Win32BaseWindow *)child->getNextChild();
3554 }
3555 }
3556 while(child)
3557 {
3558 if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
3559 (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
3560 {
3561 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
3562 return child->getWindowHandle();
3563 }
3564 child = (Win32BaseWindow *)child->getNextChild();
3565 }
3566 }
3567 else {
3568 Win32BaseWindow *wnd;
3569 HWND henum, hwnd;
3570
3571 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
3572 hwnd = OSLibWinGetNextWindow(henum);
3573
3574 while(hwnd)
3575 {
3576 wnd = GetWindowFromOS2Handle(hwnd);
3577 if(wnd == NULL) {
3578 hwnd = OSLibWinQueryClientWindow(hwnd);
3579 if(hwnd) wnd = GetWindowFromOS2Handle(hwnd);
3580 if(!hwnd) wnd = GetWindowFromOS2FrameHandle(hwnd);
3581 }
3582
3583 if(wnd) {
3584 if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
3585 (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
3586 {
3587 OSLibWinEndEnumWindows(henum);
3588 dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
3589 return wnd->getWindowHandle();
3590 }
3591 }
3592 hwnd = OSLibWinGetNextWindow(henum);
3593 }
3594 OSLibWinEndEnumWindows(henum);
3595 }
3596 SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
3597 return 0;
3598}
3599//******************************************************************************
3600//******************************************************************************
3601HWND Win32BaseWindow::GetWindow(UINT uCmd)
3602{
3603 HWND hwndRelated = 0;
3604 Win32BaseWindow *window;
3605
3606 switch(uCmd)
3607 {
3608 case GW_HWNDFIRST:
3609 if(getParent()) {
3610 window = (Win32BaseWindow *)getParent()->getFirstChild();
3611 hwndRelated = window->getWindowHandle();
3612 }
3613 break;
3614
3615 case GW_HWNDLAST:
3616 if(!getParent())
3617 {
3618 goto end;
3619 }
3620
3621 window = this;
3622 while(window->getNextChild())
3623 {
3624 window = (Win32BaseWindow *)window->getNextChild();
3625 }
3626 hwndRelated = window->getWindowHandle();
3627 break;
3628
3629 case GW_HWNDNEXT:
3630 window = (Win32BaseWindow *)getNextChild();
3631 if(window) {
3632 hwndRelated = window->getWindowHandle();
3633 }
3634 break;
3635
3636 case GW_HWNDPREV:
3637 if(!getParent())
3638 {
3639 goto end;
3640 }
3641 window = (Win32BaseWindow *)(getParent()->getFirstChild()); /* First sibling */
3642 if(window == this)
3643 {
3644 hwndRelated = 0; /* First in list */
3645 goto end;
3646 }
3647 while(window->getNextChild())
3648 {
3649 if (window->getNextChild() == this)
3650 {
3651 hwndRelated = window->getWindowHandle();
3652 goto end;
3653 }
3654 window = (Win32BaseWindow *)window->getNextChild();
3655 }
3656 break;
3657
3658 case GW_OWNER:
3659 if(getOwner()) {
3660 hwndRelated = getOwner()->getWindowHandle();
3661 }
3662 break;
3663
3664 case GW_CHILD:
3665 if(getFirstChild()) {
3666 hwndRelated = ((Win32BaseWindow *)getFirstChild())->getWindowHandle();
3667 }
3668 break;
3669 }
3670end:
3671 dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
3672 return hwndRelated;
3673}
3674//******************************************************************************
3675//******************************************************************************
3676HWND Win32BaseWindow::SetActiveWindow()
3677{
3678 HWND hwndActive;
3679 Win32BaseWindow *win32wnd;
3680 ULONG magic;
3681
3682 hwndActive = OSLibWinSetActiveWindow(OS2HwndFrame);
3683 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32WNDPTR);
3684 magic = OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32PM_MAGIC);
3685 if(CheckMagicDword(magic) && win32wnd)
3686 {
3687 return win32wnd->getWindowHandle();
3688 }
3689 return 0;
3690}
3691//******************************************************************************
3692//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
3693//******************************************************************************
3694BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
3695{
3696 return OSLibWinEnableWindow(OS2HwndFrame, fEnable);
3697}
3698//******************************************************************************
3699//******************************************************************************
3700BOOL Win32BaseWindow::CloseWindow()
3701{
3702 return OSLibWinMinimizeWindow(OS2HwndFrame);
3703}
3704//******************************************************************************
3705//******************************************************************************
3706HWND Win32BaseWindow::GetActiveWindow()
3707{
3708 HWND hwndActive;
3709 Win32BaseWindow *win32wnd;
3710 ULONG magic;
3711
3712 hwndActive = OSLibWinQueryActiveWindow();
3713
3714 return OS2ToWin32Handle(hwndActive);
3715}
3716//******************************************************************************
3717//******************************************************************************
3718BOOL Win32BaseWindow::IsWindowEnabled()
3719{
3720 return OSLibWinIsWindowEnabled(OS2HwndFrame);
3721}
3722//******************************************************************************
3723//******************************************************************************
3724BOOL Win32BaseWindow::IsWindowVisible()
3725{
3726#if 1
3727 return (dwStyle & WS_VISIBLE) == WS_VISIBLE;
3728#else
3729 return OSLibWinIsWindowVisible(OS2HwndFrame);
3730#endif
3731}
3732//******************************************************************************
3733//******************************************************************************
3734BOOL Win32BaseWindow::GetWindowRect(PRECT pRect)
3735{
3736 return OSLibWinQueryWindowRect(OS2HwndFrame, pRect, RELATIVE_TO_SCREEN);
3737}
3738//******************************************************************************
3739//******************************************************************************
3740BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
3741{
3742 INT len = GetWindowTextLength();
3743 BOOL res;
3744
3745 if (wndname == NULL)
3746 return (len == 0);
3747
3748 len++;
3749 if (fUnicode)
3750 {
3751 WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR));
3752
3753 GetWindowTextW(text,len);
3754 res = (lstrcmpW(text,(LPWSTR)wndname) == 0);
3755 free(text);
3756 } else
3757 {
3758 CHAR *text = (CHAR*)malloc(len*sizeof(CHAR));
3759
3760 GetWindowTextA(text,len);
3761 res = (strcmp(text,wndname) == 0);
3762 free(text);
3763 }
3764
3765 return res;
3766}
3767//******************************************************************************
3768//******************************************************************************
3769CHAR *Win32BaseWindow::getWindowNamePtrA()
3770{
3771 INT len = GetWindowTextLength();
3772 CHAR *text;
3773
3774 if (len == 0) return NULL;
3775 len++;
3776 text = (CHAR*)malloc(len*sizeof(CHAR));
3777 GetWindowTextA(text,len);
3778
3779 return text;
3780}
3781//******************************************************************************
3782//******************************************************************************
3783WCHAR *Win32BaseWindow::getWindowNamePtrW()
3784{
3785 INT len = GetWindowTextLength();
3786 WCHAR *text;
3787
3788 if (len == 0) return NULL;
3789 len++;
3790 text = (WCHAR*)malloc(len*sizeof(WCHAR));
3791 GetWindowTextW(text,len);
3792
3793 return text;
3794}
3795//******************************************************************************
3796//******************************************************************************
3797VOID Win32BaseWindow::freeWindowNamePtr(PVOID namePtr)
3798{
3799 if (namePtr) free(namePtr);
3800}
3801//******************************************************************************
3802//******************************************************************************
3803int Win32BaseWindow::GetWindowTextLength()
3804{
3805 return SendInternalMessageA(WM_GETTEXTLENGTH,0,0);
3806}
3807//******************************************************************************
3808//******************************************************************************
3809int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
3810{
3811 return SendInternalMessageA(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
3812}
3813//******************************************************************************
3814//******************************************************************************
3815int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
3816{
3817 return SendInternalMessageW(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
3818}
3819//******************************************************************************
3820//******************************************************************************
3821BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
3822{
3823 return SendInternalMessageA(WM_SETTEXT,0,(LPARAM)lpsz);
3824}
3825//******************************************************************************
3826//******************************************************************************
3827BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
3828{
3829 return SendInternalMessageW(WM_SETTEXT,0,(LPARAM)lpsz);
3830}
3831//******************************************************************************
3832//******************************************************************************
3833VOID Win32BaseWindow::updateWindowStyle(DWORD oldExStyle,DWORD oldStyle)
3834{
3835 if(IsWindowDestroyed()) return;
3836
3837 //CB: todo: dwExStyle, creating new frame controls, destroy not used controls, WS_VISIBLE, WS_CHILD, ...
3838 // write test cases
3839 if ((dwStyle & 0xFFFF0000) != (oldStyle & 0xFFFF0000))
3840 {
3841 //dprintf(("updateWindowStyle: %x %x",oldStyle,dwStyle));
3842 OSLibSetWindowStyle(OS2HwndFrame, dwStyle, fTaskList);
3843 }
3844}
3845//******************************************************************************
3846//******************************************************************************
3847LONG Win32BaseWindow::SetWindowLongA(int index, ULONG value, BOOL fUnicode)
3848{
3849 LONG oldval;
3850
3851 dprintf2(("SetWindowLong%c %x %d %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
3852 switch(index) {
3853 case GWL_EXSTYLE:
3854 {
3855 STYLESTRUCT ss;
3856
3857 if(dwExStyle == value)
3858 return value;
3859
3860 ss.styleOld = dwExStyle;
3861 ss.styleNew = value;
3862 dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
3863 SendInternalMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
3864 setExStyle(ss.styleNew);
3865 updateWindowStyle(ss.styleOld,getStyle());
3866 SendInternalMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
3867 return ss.styleOld;
3868 }
3869 case GWL_STYLE:
3870 {
3871 STYLESTRUCT ss;
3872
3873 if(dwStyle == value)
3874 return value;
3875
3876 value &= ~(WS_VISIBLE | WS_CHILD); /* Some bits can't be changed this way (WINE) */
3877 ss.styleOld = getStyle();
3878 ss.styleNew = value | (ss.styleOld & (WS_VISIBLE | WS_CHILD));
3879 dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), ss.styleOld, ss.styleNew));
3880 SendInternalMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
3881 setStyle(ss.styleNew);
3882 updateWindowStyle(dwExStyle,ss.styleOld);
3883 SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
3884#ifdef DEBUG
3885 PrintWindowStyle(ss.styleNew, 0);
3886#endif
3887 return ss.styleOld;
3888 }
3889 case GWL_WNDPROC:
3890 oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
3891 //WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A, WIN_PROC_WINDOW);
3892 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, WINPROC_GetProcType(win32wndproc), WIN_PROC_WINDOW);
3893 return oldval;
3894 case GWL_HINSTANCE:
3895 oldval = hInstance;
3896 hInstance = value;
3897 return oldval;
3898 case GWL_HWNDPARENT:
3899 return SetParent((HWND)value);
3900 case GWL_ID:
3901 oldval = getWindowId();
3902 setWindowId(value);
3903 return oldval;
3904 case GWL_USERDATA:
3905 oldval = userData;
3906 userData = value;
3907 return oldval;
3908 default:
3909 if(index >= 0 && index/4 < nrUserWindowLong)
3910 {
3911 oldval = userWindowLong[index/4];
3912 userWindowLong[index/4] = value;
3913 return oldval;
3914 }
3915 SetLastError(ERROR_INVALID_PARAMETER);
3916 return 0;
3917 }
3918}
3919//******************************************************************************
3920//******************************************************************************
3921ULONG Win32BaseWindow::GetWindowLongA(int index, BOOL fUnicode)
3922{
3923 ULONG value;
3924
3925 switch(index) {
3926 case GWL_EXSTYLE:
3927 value = dwExStyle;
3928 break;
3929 case GWL_STYLE:
3930 value = dwStyle;
3931 break;
3932 case GWL_WNDPROC:
3933 value = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
3934 break;
3935 case GWL_HINSTANCE:
3936 value = hInstance;
3937 break;
3938 case GWL_HWNDPARENT:
3939 if(getParent()) {
3940 value = getParent()->getWindowHandle();
3941 }
3942 else value = 0;
3943 break;
3944 case GWL_ID:
3945 value = getWindowId();
3946 break;
3947 case GWL_USERDATA:
3948 value = userData;
3949 break;
3950 default:
3951 if(index >= 0 && index/4 < nrUserWindowLong)
3952 {
3953 value = userWindowLong[index/4];
3954 break;
3955 }
3956 SetLastError(ERROR_INVALID_PARAMETER);
3957 return 0;
3958 }
3959 dprintf2(("GetWindowLongA %x %d %x", getWindowHandle(), index, value));
3960 return value;
3961}
3962//******************************************************************************
3963//******************************************************************************
3964WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
3965{
3966 WORD oldval;
3967
3968 if(index >= 0 && index/4 < nrUserWindowLong)
3969 {
3970 oldval = ((WORD *)userWindowLong)[index/2];
3971 ((WORD *)userWindowLong)[index/2] = value;
3972 return oldval;
3973 }
3974 SetLastError(ERROR_INVALID_PARAMETER);
3975 return 0;
3976}
3977//******************************************************************************
3978//******************************************************************************
3979WORD Win32BaseWindow::GetWindowWord(int index)
3980{
3981 if(index >= 0 && index/4 < nrUserWindowLong)
3982 {
3983 return ((WORD *)userWindowLong)[index/2];
3984 }
3985 SetLastError(ERROR_INVALID_PARAMETER);
3986 return 0;
3987}
3988//******************************************************************************
3989//******************************************************************************
3990void Win32BaseWindow::setWindowId(DWORD id)
3991{
3992 windowId = id;
3993 dprintf(("Set window ID to %x", id));
3994 OSLibSetWindowID(OS2HwndFrame, id);
3995}
3996//******************************************************************************
3997//******************************************************************************
3998Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
3999{
4000 Win32BaseWindow *window;
4001
4002 if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
4003 return window;
4004 }
4005// dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
4006 return NULL;
4007}
4008//******************************************************************************
4009//******************************************************************************
4010Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd)
4011{
4012 Win32BaseWindow *win32wnd;
4013 DWORD magic;
4014
4015 if(hwnd == OSLIB_HWND_DESKTOP)
4016 {
4017 return windowDesktop;
4018 }
4019
4020 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
4021 magic = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
4022
4023 if(win32wnd && CheckMagicDword(magic)) {
4024 return win32wnd;
4025 }
4026// dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwnd));
4027 return 0;
4028}
4029//******************************************************************************
4030//******************************************************************************
4031Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
4032{
4033 return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
4034}
4035//******************************************************************************
4036//******************************************************************************
4037HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd)
4038{
4039 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
4040
4041 if(window) {
4042 return window->getOS2WindowHandle();
4043 }
4044// dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
4045 return hwnd;
4046}
4047//******************************************************************************
4048//******************************************************************************
4049HWND Win32BaseWindow::Win32ToOS2FrameHandle(HWND hwnd)
4050{
4051 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
4052
4053 if(window) {
4054 return window->getOS2FrameWindowHandle();
4055 }
4056// dprintf2(("Win32BaseWindow::Win32ToOS2FrameHandle: not a win32 window %x", hwnd));
4057 return hwnd;
4058}
4059//******************************************************************************
4060//******************************************************************************
4061HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd)
4062{
4063 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
4064
4065 if(window) {
4066 return window->getWindowHandle();
4067 }
4068 window = GetWindowFromOS2FrameHandle(hwnd);
4069 if(window) {
4070 return window->getWindowHandle();
4071 }
4072// dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
4073 return 0;
4074// else return hwnd; //OS/2 window handle
4075}
4076//******************************************************************************
4077// GetNextDlgTabItem32 (USER32.276)
4078//******************************************************************************
4079HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
4080{
4081 Win32BaseWindow *child, *nextchild, *lastchild;
4082 HWND retvalue;
4083
4084 if (hwndCtrl)
4085 {
4086 child = GetWindowFromHandle(hwndCtrl);
4087 if (!child)
4088 {
4089 retvalue = 0;
4090 goto END;
4091 }
4092 /* Make sure hwndCtrl is a top-level child */
4093 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
4094 {
4095 child = child->getParent();
4096 if(child == NULL) break;
4097 }
4098
4099 if (!child || (child->getParent() != this))
4100 {
4101 retvalue = 0;
4102 goto END;
4103 }
4104 }
4105 else
4106 {
4107 /* No ctrl specified -> start from the beginning */
4108 child = (Win32BaseWindow *)getFirstChild();
4109 if (!child)
4110 {
4111 retvalue = 0;
4112 goto END;
4113 }
4114
4115 if (!fPrevious)
4116 {
4117 while (child->getNextChild())
4118 {
4119 child = (Win32BaseWindow *)child->getNextChild();
4120 }
4121 }
4122 }
4123
4124 lastchild = child;
4125 nextchild = (Win32BaseWindow *)child->getNextChild();
4126 while (TRUE)
4127 {
4128 if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild();
4129
4130 if (child == nextchild) break;
4131
4132 if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) &&
4133 !(nextchild->getStyle() & WS_DISABLED))
4134 {
4135 lastchild = nextchild;
4136 if (!fPrevious) break;
4137 }
4138 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
4139 }
4140 retvalue = lastchild->getWindowHandle();
4141
4142END:
4143 return retvalue;
4144}
4145//******************************************************************************
4146//******************************************************************************
4147HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
4148{
4149 Win32BaseWindow *child, *nextchild, *lastchild;
4150 HWND retvalue;
4151
4152 if (hwndCtrl)
4153 {
4154 child = GetWindowFromHandle(hwndCtrl);
4155 if (!child)
4156 {
4157 retvalue = 0;
4158 goto END;
4159 }
4160 /* Make sure hwndCtrl is a top-level child */
4161 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
4162 {
4163 child = child->getParent();
4164 if(child == NULL) break;
4165 }
4166
4167 if (!child || (child->getParent() != this))
4168 {
4169 retvalue = 0;
4170 goto END;
4171 }
4172 }
4173 else
4174 {
4175 /* No ctrl specified -> start from the beginning */
4176 child = (Win32BaseWindow *)getFirstChild();
4177 if (!child)
4178 {
4179 retvalue = 0;
4180 goto END;
4181 }
4182
4183 if (fPrevious)
4184 {
4185 while (child->getNextChild())
4186 {
4187 child = (Win32BaseWindow *)child->getNextChild();
4188 }
4189 }
4190 }
4191
4192 lastchild = child;
4193 nextchild = (Win32BaseWindow *)child->getNextChild();
4194 while (TRUE)
4195 {
4196 if (!nextchild || (nextchild->getStyle() & WS_GROUP))
4197 {
4198 /* Wrap-around to the beginning of the group */
4199 Win32BaseWindow *pWndTemp;
4200
4201 nextchild = (Win32BaseWindow *)getFirstChild();
4202
4203 for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild())
4204 {
4205 if (pWndTemp->getStyle() & WS_GROUP)
4206 nextchild = pWndTemp;
4207
4208 if (pWndTemp == child)
4209 break;
4210 }
4211
4212 }
4213 if (nextchild == child)
4214 break;
4215
4216 if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED))
4217 {
4218 lastchild = nextchild;
4219
4220 if (!fPrevious)
4221 break;
4222 }
4223
4224 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
4225 }
4226 retvalue = lastchild->getWindowHandle();
4227END:
4228 return retvalue;
4229}
4230//******************************************************************************
4231//******************************************************************************
4232#ifdef DEBUG
4233void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
4234{
4235 char style[256] = "";
4236 char exstyle[256] = "";
4237
4238 /* Window styles */
4239 if(dwStyle & WS_CHILD)
4240 strcat(style, "WS_CHILD ");
4241 if(dwStyle & WS_POPUP)
4242 strcat(style, "WS_POPUP ");
4243 if(dwStyle & WS_VISIBLE)
4244 strcat(style, "WS_VISIBLE ");
4245 if(dwStyle & WS_DISABLED)
4246 strcat(style, "WS_DISABLED ");
4247 if(dwStyle & WS_CLIPSIBLINGS)
4248 strcat(style, "WS_CLIPSIBLINGS ");
4249 if(dwStyle & WS_CLIPCHILDREN)
4250 strcat(style, "WS_CLIPCHILDREN ");
4251 if(dwStyle & WS_MAXIMIZE)
4252 strcat(style, "WS_MAXIMIZE ");
4253 if(dwStyle & WS_MINIMIZE)
4254 strcat(style, "WS_MINIMIZE ");
4255 if(dwStyle & WS_GROUP)
4256 strcat(style, "WS_GROUP ");
4257 if(dwStyle & WS_TABSTOP)
4258 strcat(style, "WS_TABSTOP ");
4259
4260 if((dwStyle & WS_CAPTION) == WS_CAPTION)
4261 strcat(style, "WS_CAPTION ");
4262 if(dwStyle & WS_DLGFRAME)
4263 strcat(style, "WS_DLGFRAME ");
4264 if(dwStyle & WS_BORDER)
4265 strcat(style, "WS_BORDER ");
4266
4267 if(dwStyle & WS_VSCROLL)
4268 strcat(style, "WS_VSCROLL ");
4269 if(dwStyle & WS_HSCROLL)
4270 strcat(style, "WS_HSCROLL ");
4271 if(dwStyle & WS_SYSMENU)
4272 strcat(style, "WS_SYSMENU ");
4273 if(dwStyle & WS_THICKFRAME)
4274 strcat(style, "WS_THICKFRAME ");
4275 if(dwStyle & WS_MINIMIZEBOX)
4276 strcat(style, "WS_MINIMIZEBOX ");
4277 if(dwStyle & WS_MAXIMIZEBOX)
4278 strcat(style, "WS_MAXIMIZEBOX ");
4279
4280 if(dwExStyle & WS_EX_DLGMODALFRAME)
4281 strcat(exstyle, "WS_EX_DLGMODALFRAME ");
4282 if(dwExStyle & WS_EX_ACCEPTFILES)
4283 strcat(exstyle, "WS_EX_ACCEPTFILES ");
4284 if(dwExStyle & WS_EX_NOPARENTNOTIFY)
4285 strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
4286 if(dwExStyle & WS_EX_TOPMOST)
4287 strcat(exstyle, "WS_EX_TOPMOST ");
4288 if(dwExStyle & WS_EX_TRANSPARENT)
4289 strcat(exstyle, "WS_EX_TRANSPARENT ");
4290
4291 if(dwExStyle & WS_EX_MDICHILD)
4292 strcat(exstyle, "WS_EX_MDICHILD ");
4293 if(dwExStyle & WS_EX_TOOLWINDOW)
4294 strcat(exstyle, "WS_EX_TOOLWINDOW ");
4295 if(dwExStyle & WS_EX_WINDOWEDGE)
4296 strcat(exstyle, "WS_EX_WINDOWEDGE ");
4297 if(dwExStyle & WS_EX_CLIENTEDGE)
4298 strcat(exstyle, "WS_EX_CLIENTEDGE ");
4299 if(dwExStyle & WS_EX_CONTEXTHELP)
4300 strcat(exstyle, "WS_EX_CONTEXTHELP ");
4301 if(dwExStyle & WS_EX_RIGHT)
4302 strcat(exstyle, "WS_EX_RIGHT ");
4303 if(dwExStyle & WS_EX_LEFT)
4304 strcat(exstyle, "WS_EX_LEFT ");
4305 if(dwExStyle & WS_EX_RTLREADING)
4306 strcat(exstyle, "WS_EX_RTLREADING ");
4307 if(dwExStyle & WS_EX_LTRREADING)
4308 strcat(exstyle, "WS_EX_LTRREADING ");
4309 if(dwExStyle & WS_EX_LEFTSCROLLBAR)
4310 strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
4311 if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
4312 strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
4313 if(dwExStyle & WS_EX_CONTROLPARENT)
4314 strcat(exstyle, "WS_EX_CONTROLPARENT ");
4315 if(dwExStyle & WS_EX_STATICEDGE)
4316 strcat(exstyle, "WS_EX_STATICEDGE ");
4317 if(dwExStyle & WS_EX_APPWINDOW)
4318 strcat(exstyle, "WS_EX_APPWINDOW ");
4319
4320 dprintf(("Window style: %x %s", dwStyle, style));
4321 dprintf(("Window exStyle: %x %s (FS = %x)", dwExStyle, exstyle, GetFS()));
4322}
4323#endif
4324//******************************************************************************
4325//******************************************************************************
4326
4327GenericObject *Win32BaseWindow::windows = NULL;
Note: See TracBrowser for help on using the repository browser.