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

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

* empty log message *

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