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

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

* empty log message *

File size: 137.9 KB
Line 
1/* $Id: win32wbase.cpp,v 1.23 2000-01-06 17:05:52 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 RECT rect;
716
717 //update rect
718 rectWindow.left = cs->x;
719 rectWindow.right = cs->x+cs->cx;
720 rectWindow.top = cs->y;
721 rectWindow.bottom = cs->y+cs->cy;
722 rectClient = rectWindow;
723 if (getParent()) MapWindowPoints(getParent()->getWindowHandle(),0,(PPOINT)&rectWindow,2);
724 OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
725 //set the window size and update the client
726 rect = rectWindow;
727 if (getParent()) MapWindowPoints(0,getParent()->getWindowHandle(),(PPOINT)&rect,2);
728 SetWindowPos(hwndLinkAfter,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,SWP_NOACTIVATE | SWP_NOREDRAW | SWP_FRAMECHANGED);
729 fNoSizeMsg = FALSE;
730 if( (SendInternalMessageA(WM_CREATE, 0, (LPARAM)cs )) != -1 )
731 {
732 if(!(flags & WIN_NEED_SIZE)) {
733 SendInternalMessageA(WM_SIZE, SIZE_RESTORED,
734 MAKELONG(rectClient.right-rectClient.left,
735 rectClient.bottom-rectClient.top));
736 SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
737 }
738
739 if( (getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
740 {
741 /* Notify the parent window only */
742 SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle());
743 if(!::IsWindow(getWindowHandle()))
744 {
745 dprintf(("Createwindow: WM_PARENTNOTIFY destroyed window"));
746 goto end;
747 }
748 }
749
750 if (cs->style & WS_VISIBLE) ShowWindow( sw );
751
752 /* Call WH_SHELL hook */
753 if (!(getStyle() & WS_CHILD) && !owner)
754 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWCREATED, getWindowHandle(), 0 );
755
756 SetLastError(0);
757 return TRUE;
758 }
759 }
760 dprintf(("Window creation FAILED (NCCREATE cancelled creation)"));
761 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
762end:
763 return FALSE;
764}
765//******************************************************************************
766//******************************************************************************
767ULONG Win32BaseWindow::MsgQuit()
768{
769 return SendInternalMessageA(WM_QUIT, 0, 0);
770}
771//******************************************************************************
772//******************************************************************************
773ULONG Win32BaseWindow::MsgClose()
774{
775 return SendInternalMessageA(WM_CLOSE,0,0);
776}
777//******************************************************************************
778//******************************************************************************
779ULONG Win32BaseWindow::MsgDestroy()
780{
781 ULONG rc;
782 Win32BaseWindow *child;
783 HWND hwnd = getWindowHandle();
784
785 if (isSubclassedOS2Wnd) OSLibWinSubclassWindow(OS2Hwnd,pOldWndProc);
786
787 fIsDestroyed = TRUE;
788
789 if(fDestroyWindowCalled == FALSE)
790 {//this window was destroyed because DestroyWindow was called for it's parent
791 //so: send a WM_PARENTNOTIFY now as that hasn't happened yet
792 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
793 {
794 if(getParent())
795 {
796 /* Notify the parent window only */
797 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
798 }
799 else DebugInt3();
800 }
801 }
802 SendInternalMessageA(WM_DESTROY, 0, 0);
803 if(::IsWindow(hwnd) == FALSE) {
804 //object already destroyed, so return immediately
805 return 1;
806 }
807 SendInternalMessageA(WM_NCDESTROY, 0, 0);
808
809 if (hwndHorzScroll && (OSLibWinQueryWindow(hwndHorzScroll,QWOS_PARENT) == OSLibWinQueryObjectWindow())) OSLibWinDestroyWindow(hwndHorzScroll);
810 if (hwndVertScroll && (OSLibWinQueryWindow(hwndVertScroll,QWOS_PARENT) == OSLibWinQueryObjectWindow())) OSLibWinDestroyWindow(hwndVertScroll);
811
812 TIMER_KillTimerFromWindow(OS2Hwnd);
813
814 if(getFirstChild() == NULL) {
815 delete this;
816 }
817 return 1;
818}
819//******************************************************************************
820//******************************************************************************
821ULONG Win32BaseWindow::MsgEnable(BOOL fEnable)
822{
823 if(fEnable) {
824 dwStyle &= ~WS_DISABLED;
825 }
826 else dwStyle |= WS_DISABLED;
827
828 return SendInternalMessageA(WM_ENABLE, fEnable, 0);
829}
830//******************************************************************************
831//TODO: SW_PARENTCLOSING/OPENING flag (lParam)
832//******************************************************************************
833ULONG Win32BaseWindow::MsgShow(BOOL fShow)
834{
835 if(fNoSizeMsg) {
836 return 1;
837 }
838
839 if(fShow) {
840 setStyle(getStyle() | WS_VISIBLE);
841 }
842 else setStyle(getStyle() & ~WS_VISIBLE);
843
844 return SendInternalMessageA(WM_SHOWWINDOW, fShow, 0);
845}
846//******************************************************************************
847//******************************************************************************
848ULONG Win32BaseWindow::MsgPosChanging(LPARAM lp)
849{
850 //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
851 // a WM_WINDOWPOSCHANGED msg -> crash)
852 if(fNoSizeMsg || fDestroyWindowCalled)
853 return 1;
854
855 return SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, lp);
856}
857//******************************************************************************
858//******************************************************************************
859ULONG Win32BaseWindow::MsgPosChanged(LPARAM lp)
860{
861 //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
862 // a WM_WINDOWPOSCHANGED msg -> crash)
863 if(fNoSizeMsg || fDestroyWindowCalled)
864 return 1;
865
866 return SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, lp);
867}
868//******************************************************************************
869//******************************************************************************
870#if 0
871ULONG Win32BaseWindow::MsgMinMax()
872{
873
874}
875#endif
876//******************************************************************************
877//******************************************************************************
878ULONG Win32BaseWindow::MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos)
879{
880 //According to the SDK docs, the scrollbar handle (lParam) is 0 when the standard
881 //window scrollbars send these messages
882 return SendInternalMessageA(msg, MAKELONG(scrollCode, scrollPos), 0);
883}
884//******************************************************************************
885//******************************************************************************
886ULONG Win32BaseWindow::MsgHitTest(MSG *msg)
887{
888 lastHitTestVal = SendInternalMessageA(WM_NCHITTEST,msg->wParam,msg->lParam);
889 dprintf2(("MsgHitTest returned %x", lastHitTestVal));
890
891 if (lastHitTestVal == HTERROR)
892 return HTOS_ERROR;
893
894#if 0 //CB: problems with groupboxes, internal handling is better
895 if (lastHitTestVal == HTTRANSPARENT)
896 return HTOS_TRANSPARENT;
897#endif
898
899 return HTOS_NORMAL;
900}
901//******************************************************************************
902//******************************************************************************
903ULONG Win32BaseWindow::MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd)
904{
905 ULONG rc, curprocid, procidhwnd = -1, threadidhwnd = 0;
906
907
908 //According to SDK docs, if app returns FALSE & window is being deactivated,
909 //default processing is cancelled
910 //TODO: According to Wine we should proceed anyway if window is sysmodal
911 if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
912 {
913 return 0;
914 }
915 rc = SendInternalMessageA(WM_ACTIVATE, MAKELONG((fActivate) ? WA_ACTIVE : WA_INACTIVE, fMinimized), hwnd);
916
917 curprocid = GetCurrentProcessId();
918 if(hwnd) {
919 threadidhwnd = GetWindowThreadProcessId(hwnd, &procidhwnd);
920 }
921
922 if(curprocid != procidhwnd && fActivate) {
923 SendInternalMessageA(WM_ACTIVATEAPP, 1, threadidhwnd);
924 }
925 return rc;
926}
927//******************************************************************************
928//TODO: Is this correct and complete?
929//Add print screen, break & numlock
930//******************************************************************************
931void Win32BaseWindow::setExtendedKey(ULONG virtualkey, ULONG *lParam)
932{
933 switch(virtualkey) {
934 case VK_DOWN:
935 case VK_UP:
936 case VK_PRIOR:
937 case VK_NEXT:
938 case VK_END:
939 case VK_DIVIDE:
940 case VK_DELETE:
941 case VK_EXECUTE: //Numeric enter key?
942 case VK_HOME:
943 case VK_INSERT:
944 case VK_RCONTROL:
945 case VK_RMENU: //is this the right alt???
946 *lParam = *lParam | (1<<24);
947 }
948}
949//******************************************************************************
950//******************************************************************************
951ULONG Win32BaseWindow::DispatchMsgA(MSG *msg)
952{
953 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
954}
955//******************************************************************************
956//******************************************************************************
957ULONG Win32BaseWindow::DispatchMsgW(MSG *msg)
958{
959 return SendInternalMessageW(msg->message, msg->wParam, msg->lParam);
960}
961//******************************************************************************
962//******************************************************************************
963ULONG Win32BaseWindow::MsgSetFocus(HWND hwnd)
964{
965 return SendInternalMessageA(WM_SETFOCUS, hwnd, 0);
966}
967//******************************************************************************
968//******************************************************************************
969ULONG Win32BaseWindow::MsgKillFocus(HWND hwnd)
970{
971 return SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
972}
973//******************************************************************************
974//******************************************************************************
975ULONG Win32BaseWindow::MsgButton(MSG *msg)
976{
977 BOOL fClick = FALSE;
978
979 dprintf(("MsgButton at (%d,%d)", msg->pt.x, msg->pt.y));
980 switch(msg->message) {
981 case WM_LBUTTONDBLCLK:
982 case WM_RBUTTONDBLCLK:
983 case WM_MBUTTONDBLCLK:
984 case WM_NCLBUTTONDBLCLK:
985 case WM_NCRBUTTONDBLCLK:
986 case WM_NCMBUTTONDBLCLK:
987 if (!(windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS))
988 {
989 msg->message = msg->message - (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); //dblclick -> down
990 MsgButton(msg);
991 msg->message++; //button-up
992 return MsgButton(msg);
993 }
994 break;
995 case WM_LBUTTONDOWN:
996 case WM_RBUTTONDOWN:
997 case WM_MBUTTONDOWN:
998 case WM_NCLBUTTONDOWN:
999 case WM_NCRBUTTONDOWN:
1000 case WM_NCMBUTTONDOWN:
1001 fClick = TRUE;
1002 break;
1003 }
1004
1005 if(ISMOUSE_CAPTURED())
1006 {
1007 if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_BUTTON, msg->pt.x, msg->pt.y))
1008 return 0;
1009 }
1010
1011 if(fClick)
1012 {
1013 HWND hwndTop;
1014
1015 /* Activate the window if needed */
1016 if(isSubclassedOS2Wnd()) {
1017 Win32BaseWindow *parentwnd = GetWindowFromOS2FrameHandle(OSLibWinQueryWindow(OS2Hwnd, QWOS_PARENT));
1018 if(parentwnd) {
1019 hwndTop = (parentwnd->GetTopParent()) ? parentwnd->GetTopParent()->getWindowHandle() : 0;
1020 }
1021 else hwndTop = 0;
1022 }
1023 else hwndTop = (GetTopParent()) ? GetTopParent()->getWindowHandle() : 0;
1024
1025 HWND hwndActive = GetActiveWindow();
1026 if (hwndTop && (getWindowHandle() != hwndActive))
1027 {
1028 LONG ret = SendInternalMessageA(WM_MOUSEACTIVATE, hwndTop,
1029 MAKELONG( lastHitTestVal, msg->message) );
1030
1031#if 0
1032 if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
1033 eatMsg = TRUE;
1034#endif
1035 if(((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT))
1036 && hwndTop != GetForegroundWindow() )
1037 {
1038 ::SetActiveWindow(hwndTop);
1039 }
1040 }
1041 }
1042
1043 SendInternalMessageA(WM_SETCURSOR, getWindowHandle(), MAKELONG(lastHitTestVal, msg->message));
1044
1045 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
1046}
1047//******************************************************************************
1048//******************************************************************************
1049ULONG Win32BaseWindow::MsgPaint(ULONG tmp1, BOOL select)
1050{
1051 if (select && isIcon)
1052 return SendInternalMessageA(WM_PAINTICON, 0, 0);
1053 else
1054 return SendInternalMessageA(WM_PAINT, 0, 0);
1055}
1056//******************************************************************************
1057//TODO: Is the clipper region of the window DC equal to the invalidated rectangle?
1058// (or are we simply erasing too much here)
1059//******************************************************************************
1060ULONG Win32BaseWindow::MsgEraseBackGround(HDC hdc)
1061{
1062 ULONG rc;
1063 HDC hdcErase = hdc;
1064
1065 if (hdcErase == 0)
1066 hdcErase = O32_GetDC(OS2Hwnd);
1067
1068 if(isIcon)
1069 rc = SendInternalMessageA(WM_ICONERASEBKGND, hdcErase, 0);
1070 else
1071 rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0);
1072 if (hdc == 0)
1073 O32_ReleaseDC(OS2Hwnd, hdcErase);
1074 return (rc);
1075}
1076//******************************************************************************
1077//******************************************************************************
1078ULONG Win32BaseWindow::MsgMouseMove(MSG *msg)
1079{
1080 if(ISMOUSE_CAPTURED()) {
1081 if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_MOVE, msg->pt.x, msg->pt.y))
1082 return 0;
1083 }
1084
1085 //TODO: hiword should be 0 if window enters menu mode (SDK docs)
1086 SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, msg->message));
1087
1088 //translated message == WM_(NC)MOUSEMOVE
1089 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
1090}
1091//******************************************************************************
1092//TODO: Depending on menu type, we should send WM_INITMENU or WM_INITPOPUPMENU
1093//TODO: PM sends it for each submenu that gets activated; Windows only for the first
1094// submenu; once the menu bar is active, moving the cursor doesn't generate other
1095// WM_INITMENU msgs. Not really a problem, but might need to fix this later on.
1096//******************************************************************************
1097ULONG Win32BaseWindow::MsgInitMenu(MSG *msg)
1098{
1099 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
1100}
1101//******************************************************************************
1102//******************************************************************************
1103ULONG Win32BaseWindow::MsgNCPaint()
1104{
1105 HRGN hrgn;
1106
1107 hrgn = 0; //CB: todo: set to frame update region
1108 return SendInternalMessageA(WM_NCPAINT,hrgn,0);
1109}
1110//******************************************************************************
1111//******************************************************************************
1112ULONG Win32BaseWindow::MsgFormatFrame()
1113{
1114 RECT window = rectWindow,client = rectClient,rect;
1115 WINDOWPOS wndPos;
1116
1117 wndPos.hwnd = Win32Hwnd;
1118 wndPos.hwndInsertAfter = 0;
1119 rect = rectWindow;
1120 if (getParent()) MapWindowPoints(0,getParent()->getWindowHandle(),(PPOINT)&rect,2);
1121 wndPos.x = rect.left;
1122 wndPos.y = rect.top;
1123 wndPos.cx = rect.right-rect.left;
1124 wndPos.cy = rect.bottom-rect.top;
1125 wndPos.flags = 0;
1126
1127 return SendNCCalcSize(TRUE,&window,&window,&client,&wndPos,&rectClient);
1128}
1129//******************************************************************************
1130//******************************************************************************
1131ULONG Win32BaseWindow::MsgSetText(LPSTR lpsz, LONG cch)
1132{
1133 return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
1134}
1135//******************************************************************************
1136//******************************************************************************
1137ULONG Win32BaseWindow::MsgGetTextLength()
1138{
1139 return SendInternalMessageA(WM_GETTEXTLENGTH, 0, 0);
1140}
1141//******************************************************************************
1142//******************************************************************************
1143char *Win32BaseWindow::MsgGetText()
1144{
1145 SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA);
1146 return windowNameA;
1147}
1148//******************************************************************************
1149//******************************************************************************
1150ULONG Win32BaseWindow::MsgContextMenu(ULONG x,ULONG y)
1151{
1152 return SendInternalMessageA(WM_CONTEXTMENU,Win32Hwnd,MAKELPARAM(x,y));
1153}
1154//******************************************************************************
1155//******************************************************************************
1156BOOL Win32BaseWindow::isMDIClient()
1157{
1158 return FALSE;
1159}
1160//******************************************************************************
1161//******************************************************************************
1162BOOL Win32BaseWindow::isMDIChild()
1163{
1164 return FALSE;
1165}
1166//******************************************************************************
1167//TODO: Not complete
1168//******************************************************************************
1169BOOL Win32BaseWindow::isFrameWindow()
1170{
1171// if(isMDIChild() || IsDialog() || (getParent() == NULL || getParent() == windowDesktop) && ((dwStyle & WS_CAPTION) == WS_CAPTION))
1172 if((dwStyle & WS_CAPTION) == WS_CAPTION || dwStyle & (WS_VSCROLL|WS_HSCROLL))
1173 return TRUE;
1174
1175 return FALSE;
1176}
1177//******************************************************************************
1178//******************************************************************************
1179SCROLLBAR_INFO *Win32BaseWindow::getScrollInfo(int nBar)
1180{
1181 switch(nBar)
1182 {
1183 case SB_HORZ:
1184 return horzScrollInfo;
1185
1186 case SB_VERT:
1187 return vertScrollInfo;
1188 }
1189
1190 return NULL;
1191}
1192//******************************************************************************
1193//******************************************************************************
1194VOID Win32BaseWindow::subclassScrollBars(BOOL subHorz,BOOL subVert)
1195{
1196 SCROLL_SubclassScrollBars(subHorz ? hwndHorzScroll:0,subVert ? hwndVertScroll:0);
1197}
1198//******************************************************************************
1199//******************************************************************************
1200BOOL Win32BaseWindow::showScrollBars(BOOL changeHorz,BOOL changeVert,BOOL fShow)
1201{
1202 BOOL rc = TRUE;
1203 DWORD flags = 0;
1204
1205 if (fShow)
1206 {
1207 BOOL createHorz = FALSE,createVert = FALSE;
1208 BOOL showHorz = FALSE,showVert = FALSE;
1209
1210 if (changeHorz)
1211 {
1212 if (!hwndHorzScroll)
1213 createHorz = TRUE;
1214 else
1215 showHorz = TRUE;
1216 }
1217
1218 if (changeVert)
1219 {
1220 if (!hwndVertScroll)
1221 createVert = TRUE;
1222 else
1223 showVert = TRUE;
1224 }
1225
1226 if (createHorz || createVert)
1227 {
1228 if (createHorz && !horzScrollInfo)
1229 {
1230 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
1231 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
1232 horzScrollInfo->MaxVal = 100;
1233 horzScrollInfo->flags = ESB_ENABLE_BOTH;
1234 }
1235
1236 if (createVert && !vertScrollInfo)
1237 {
1238 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
1239 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
1240 vertScrollInfo->MaxVal = 100;
1241 vertScrollInfo->flags = ESB_ENABLE_BOTH;
1242 }
1243
1244 rc = FrameCreateScrollBars(this,createHorz,createVert,FALSE,&flags);
1245
1246 if (!rc) return FALSE;
1247 if (createHorz) dwStyle |= WS_HSCROLL;
1248 if (createVert) dwStyle |= WS_VSCROLL;
1249 }
1250
1251 if (showVert || showHorz)
1252 {
1253 DWORD newFlags;
1254
1255 rc = FrameShowScrollBars(this,showHorz,showVert,fShow,FALSE,&newFlags);
1256 flags |= newFlags;
1257 if (rc)
1258 {
1259 if (showHorz) dwStyle |= WS_HSCROLL;
1260 if (showVert) dwStyle |= WS_VSCROLL;
1261 }
1262 }
1263
1264 if (flags) FrameUpdateFrame(this,flags);
1265 } else
1266 {
1267 rc = FrameShowScrollBars(this,changeHorz && hwndHorzScroll,changeVert && hwndVertScroll,fShow,TRUE);
1268
1269 if (rc)
1270 {
1271 if (changeHorz) dwStyle &= ~WS_HSCROLL;
1272 if (changeVert) dwStyle &= ~WS_VSCROLL;
1273 }
1274 }
1275
1276 return rc;
1277}
1278//******************************************************************************
1279//******************************************************************************
1280LONG Win32BaseWindow::HandleNCActivate(WPARAM wParam)
1281{
1282 WORD wStateChange;
1283
1284 if( wParam ) wStateChange = !(flags & WIN_NCACTIVATED);
1285 else wStateChange = flags & WIN_NCACTIVATED;
1286
1287 if( wStateChange )
1288 {
1289 if (wParam) flags |= WIN_NCACTIVATED;
1290 else flags &= ~WIN_NCACTIVATED;
1291
1292 if(!(dwStyle & WS_MINIMIZE))
1293 DoNCPaint((HRGN)1,FALSE);
1294 }
1295
1296 return TRUE;
1297}
1298//******************************************************************************
1299//******************************************************************************
1300VOID Win32BaseWindow::TrackMinMaxBox(WORD wParam)
1301{
1302 MSG msg;
1303 HDC hdc;
1304 BOOL pressed = TRUE;
1305 UINT state;
1306
1307 if (wParam == HTMINBUTTON)
1308 {
1309 /* If the style is not present, do nothing */
1310 if (!(dwStyle & WS_MINIMIZEBOX))
1311 return;
1312 /* Check if the sysmenu item for minimize is there */
1313#if 0 //CB: todo
1314 state = GetMenuState(hSysMenu,SC_MINIMIZE,MF_BYCOMMAND);
1315#endif
1316 } else
1317 {
1318 /* If the style is not present, do nothing */
1319 if (!(dwStyle & WS_MAXIMIZEBOX))
1320 return;
1321 /* Check if the sysmenu item for maximize is there */
1322#if 0 //CB: todo
1323 state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
1324#endif
1325 }
1326 SetCapture(Win32Hwnd);
1327 hdc = GetWindowDC(Win32Hwnd);
1328 if (wParam == HTMINBUTTON)
1329 DrawMinButton(hdc,TRUE,FALSE);
1330 else
1331 DrawMaxButton(hdc,TRUE,FALSE);
1332 do
1333 {
1334 BOOL oldstate = pressed;
1335
1336 GetMessageA(&msg,Win32Hwnd,0,0);
1337 pressed = (HandleNCHitTest(msg.pt) == wParam);
1338 if (pressed != oldstate)
1339 {
1340 if (wParam == HTMINBUTTON)
1341 DrawMinButton(hdc,pressed,FALSE);
1342 else
1343 DrawMaxButton(hdc,pressed,FALSE);
1344 }
1345 } while (msg.message != WM_LBUTTONUP);
1346 if (wParam == HTMINBUTTON)
1347 DrawMinButton(hdc,FALSE,FALSE);
1348 else
1349 DrawMaxButton(hdc,FALSE,FALSE);
1350 ReleaseCapture();
1351 ReleaseDC(Win32Hwnd,hdc);
1352 /* If the item minimize or maximize of the sysmenu are not there */
1353 /* or if the style is not present, do nothing */
1354 if ((!pressed) || (state == 0xFFFFFFFF))
1355 return;
1356 if (wParam == HTMINBUTTON)
1357 SendInternalMessageA(WM_SYSCOMMAND,SC_MINIMIZE,*(LPARAM*)&msg.pt);
1358 else
1359 SendInternalMessageA(WM_SYSCOMMAND,IsZoomed(Win32Hwnd) ? SC_RESTORE:SC_MAXIMIZE,*(LPARAM*)&msg.pt);
1360}
1361//******************************************************************************
1362//******************************************************************************
1363VOID Win32BaseWindow::TrackCloseButton(WORD wParam)
1364{
1365 MSG msg;
1366 HDC hdc;
1367 BOOL pressed = TRUE;
1368 UINT state;
1369
1370#if 0 //CB: todo
1371 if (hSysMenu == 0)
1372 return;
1373 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
1374#endif
1375 /* If the item close of the sysmenu is disabled or not there do nothing */
1376 if((state & MF_DISABLED) || (state & MF_GRAYED) || (state == 0xFFFFFFFF))
1377 return;
1378 hdc = GetWindowDC(Win32Hwnd);
1379 SetCapture(Win32Hwnd);
1380 DrawCloseButton(hdc,TRUE,FALSE);
1381 do
1382 {
1383 BOOL oldstate = pressed;
1384
1385 GetMessageA(&msg,Win32Hwnd,0,0);
1386 pressed = (HandleNCHitTest(msg.pt) == wParam);
1387 if (pressed != oldstate)
1388 DrawCloseButton(hdc, pressed, FALSE);
1389 } while (msg.message != WM_LBUTTONUP);
1390 DrawCloseButton(hdc, FALSE, FALSE);
1391 ReleaseCapture();
1392 ReleaseDC(Win32Hwnd, hdc );
1393 if (!pressed) return;
1394 SendInternalMessageA(WM_SYSCOMMAND,SC_CLOSE,*(LPARAM*)&msg.pt);
1395}
1396//******************************************************************************
1397//******************************************************************************
1398LONG Win32BaseWindow::HandleNCLButtonDown(WPARAM wParam,LPARAM lParam)
1399{
1400 switch(wParam) /* Hit test */
1401 {
1402 case HTCAPTION:
1403 SetActiveWindow();
1404 if (GetActiveWindow() == Win32Hwnd)
1405 SendInternalMessageA(WM_SYSCOMMAND,SC_MOVE+HTCAPTION,lParam);
1406 break;
1407
1408 case HTSYSMENU:
1409 if(dwStyle & WS_SYSMENU )
1410 {
1411 if( !(dwStyle & WS_MINIMIZE) )
1412 {
1413 HDC hDC = GetWindowDC(Win32Hwnd);
1414 DrawSysButton(hDC,TRUE);
1415 ReleaseDC(Win32Hwnd,hDC);
1416 }
1417 SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU+HTSYSMENU,lParam);
1418 }
1419 break;
1420
1421 case HTMENU:
1422 SendInternalMessageA(WM_SYSCOMMAND,SC_MOUSEMENU,lParam);
1423 break;
1424
1425 case HTHSCROLL:
1426 SendInternalMessageA(WM_SYSCOMMAND,SC_HSCROLL+HTHSCROLL,lParam);
1427 break;
1428
1429 case HTVSCROLL:
1430 SendInternalMessageA(WM_SYSCOMMAND,SC_VSCROLL+HTVSCROLL,lParam);
1431 break;
1432
1433 case HTMINBUTTON:
1434 case HTMAXBUTTON:
1435 TrackMinMaxBox(wParam);
1436 break;
1437
1438 case HTCLOSE:
1439 TrackCloseButton(wParam);
1440 break;
1441
1442 case HTLEFT:
1443 case HTRIGHT:
1444 case HTTOP:
1445 case HTTOPLEFT:
1446 case HTTOPRIGHT:
1447 case HTBOTTOM:
1448 case HTBOTTOMLEFT:
1449 case HTBOTTOMRIGHT:
1450 /* make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU */
1451 SendInternalMessageA(WM_SYSCOMMAND,SC_SIZE+wParam-2,lParam);
1452 break;
1453 case HTBORDER:
1454 break;
1455 }
1456
1457 return 0;
1458}
1459//******************************************************************************
1460//******************************************************************************
1461LONG Win32BaseWindow::HandleNCLButtonUp(WPARAM wParam,LPARAM lParam)
1462{
1463 switch(wParam) /* Hit test */
1464 {
1465 case HTMINBUTTON:
1466 SendInternalMessageA(WM_SYSCOMMAND,SC_MINIMIZE,lParam);
1467 break;
1468
1469 case HTMAXBUTTON:
1470 SendInternalMessageA(WM_SYSCOMMAND,SC_MAXIMIZE,lParam);
1471 break;
1472
1473 case HTCLOSE:
1474 SendInternalMessageA(WM_SYSCOMMAND,SC_CLOSE,lParam);
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
1773 if (dlgFrame)
1774 {
1775 width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
1776 height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
1777 } else
1778 {
1779 width = GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXEDGE);
1780 height = GetSystemMetrics(SM_CYFRAME) - GetSystemMetrics(SM_CYEDGE);
1781 }
1782
1783 SelectObject( hdc, GetSysColorBrush(active ? COLOR_ACTIVEBORDER :
1784 COLOR_INACTIVEBORDER) );
1785
1786 /* Draw frame */
1787 PatBlt( hdc, rect->left, rect->top,
1788 rect->right - rect->left, height, PATCOPY );
1789 PatBlt( hdc, rect->left, rect->top,
1790 width, rect->bottom - rect->top, PATCOPY );
1791 PatBlt( hdc, rect->left, rect->bottom - 1,
1792 rect->right - rect->left, -height, PATCOPY );
1793 PatBlt( hdc, rect->right - 1, rect->top,
1794 -width, rect->bottom - rect->top, PATCOPY );
1795
1796 InflateRect( rect, -width, -height );
1797}
1798//******************************************************************************
1799//******************************************************************************
1800BOOL Win32BaseWindow::DrawSysButton(HDC hdc,BOOL down)
1801{
1802 if(!(flags & WIN_MANAGED))
1803 {
1804 HICON hIcon;
1805 RECT rect;
1806
1807 GetInsideRect(&rect);
1808
1809 hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
1810 if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
1811
1812 /* If there is no hIcon specified or this is not a modal dialog, */
1813 /* get the default one. */
1814 if(hIcon == 0)
1815 if (!(dwStyle & DS_MODALFRAME))
1816 hIcon = LoadImageA(0, MAKEINTRESOURCEA(OIC_WINEICON), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
1817
1818 if (hIcon)
1819 DrawIconEx (hdc, rect.left + 2, rect.top + 2, hIcon,
1820 GetSystemMetrics(SM_CXSMICON),
1821 GetSystemMetrics(SM_CYSMICON),
1822 0, 0, DI_NORMAL);
1823
1824 return (hIcon != 0);
1825 }
1826 return FALSE;
1827}
1828//******************************************************************************
1829//******************************************************************************
1830BOOL Win32BaseWindow::DrawGrayButton(HDC hdc,int x,int y)
1831{
1832 HBITMAP hMaskBmp;
1833 HDC hdcMask = CreateCompatibleDC (0);
1834 HBRUSH hOldBrush;
1835 hMaskBmp = CreateBitmap (12, 10, 1, 1, lpGrayMask);
1836
1837 if(hMaskBmp == 0)
1838 return FALSE;
1839
1840 SelectObject (hdcMask, hMaskBmp);
1841
1842 /* Draw the grayed bitmap using the mask */
1843 hOldBrush = SelectObject (hdc, RGB(128, 128, 128));
1844 BitBlt (hdc, x, y, 12, 10,
1845 hdcMask, 0, 0, 0xB8074A);
1846
1847 /* Clean up */
1848 SelectObject (hdc, hOldBrush);
1849 DeleteObject(hMaskBmp);
1850 DeleteDC (hdcMask);
1851
1852 return TRUE;
1853}
1854//******************************************************************************
1855//******************************************************************************
1856VOID Win32BaseWindow::DrawCloseButton(HDC hdc,BOOL down,BOOL bGrayed)
1857{
1858 RECT rect;
1859 HDC hdcMem;
1860
1861 if( !(flags & WIN_MANAGED) )
1862 {
1863 BITMAP bmp;
1864 HBITMAP hBmp, hOldBmp;
1865
1866 GetInsideRect(&rect);
1867
1868 hdcMem = CreateCompatibleDC( hdc );
1869 hBmp = down ? hbitmapCloseD : hbitmapClose;
1870 hOldBmp = SelectObject (hdcMem, hBmp);
1871 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
1872
1873 BitBlt (hdc, rect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
1874 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
1875 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
1876
1877 if(bGrayed)
1878 DrawGrayButton(hdc,rect.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
1879 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
1880
1881 SelectObject (hdcMem, hOldBmp);
1882 DeleteDC (hdcMem);
1883 }
1884}
1885//******************************************************************************
1886//******************************************************************************
1887VOID Win32BaseWindow::DrawMaxButton(HDC hdc,BOOL down,BOOL bGrayed)
1888{
1889 RECT rect;
1890 HDC hdcMem;
1891
1892 if( !(flags & WIN_MANAGED))
1893 {
1894 BITMAP bmp;
1895 HBITMAP hBmp,hOldBmp;
1896
1897 GetInsideRect(&rect);
1898 hdcMem = CreateCompatibleDC( hdc );
1899 hBmp = IsZoomed(Win32Hwnd) ?
1900 (down ? hbitmapRestoreD : hbitmapRestore ) :
1901 (down ? hbitmapMaximizeD: hbitmapMaximize);
1902 hOldBmp=SelectObject( hdcMem, hBmp );
1903 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
1904
1905 if (dwStyle & WS_SYSMENU)
1906 rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
1907
1908 BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
1909 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
1910 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
1911
1912 if(bGrayed)
1913 DrawGrayButton(hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
1914 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
1915
1916
1917 SelectObject (hdcMem, hOldBmp);
1918 DeleteDC( hdcMem );
1919 }
1920}
1921//******************************************************************************
1922//******************************************************************************
1923VOID Win32BaseWindow::DrawMinButton(HDC hdc,BOOL down,BOOL bGrayed)
1924{
1925 RECT rect;
1926 HDC hdcMem;
1927
1928 if( !(flags & WIN_MANAGED))
1929
1930 {
1931 BITMAP bmp;
1932 HBITMAP hBmp,hOldBmp;
1933
1934 GetInsideRect(&rect);
1935
1936 hdcMem = CreateCompatibleDC( hdc );
1937 hBmp = down ? hbitmapMinimizeD : hbitmapMinimize;
1938 hOldBmp= SelectObject( hdcMem, hBmp );
1939 GetObjectA (hBmp, sizeof(BITMAP), &bmp);
1940
1941 if (dwStyle & WS_SYSMENU)
1942 rect.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
1943
1944 /* In win 95 there is always a Maximize box when there is a Minimize one */
1945 if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
1946 rect.right += -1 - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2;
1947
1948 BitBlt( hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
1949 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
1950 bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY );
1951
1952 if(bGrayed)
1953 DrawGrayButton(hdc, rect.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2 + 2,
1954 rect.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
1955
1956
1957 SelectObject (hdcMem, hOldBmp);
1958 DeleteDC( hdcMem );
1959 }
1960}
1961//******************************************************************************
1962//******************************************************************************
1963VOID Win32BaseWindow::DrawCaption(HDC hdc,RECT *rect,BOOL active)
1964{
1965 RECT r = *rect;
1966 char buffer[256];
1967 HPEN hPrevPen;
1968 HMENU hSysMenu;
1969
1970 if (flags & WIN_MANAGED) return;
1971
1972 hPrevPen = SelectObject( hdc, GetSysColorPen(COLOR_3DFACE) );
1973 MoveToEx( hdc, r.left, r.bottom - 1, NULL );
1974 LineTo( hdc, r.right, r.bottom - 1 );
1975 SelectObject( hdc, hPrevPen );
1976 r.bottom--;
1977
1978 FillRect( hdc, &r, GetSysColorBrush(active ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION) );
1979
1980 if (!hbitmapClose)
1981 {
1982 if (!(hbitmapClose = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSE)))) return;
1983 hbitmapCloseD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_CLOSED));
1984 hbitmapMinimize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCE));
1985 hbitmapMinimizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_REDUCED));
1986 hbitmapMaximize = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOM));
1987 hbitmapMaximizeD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_ZOOMD));
1988 hbitmapRestore = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORE));
1989 hbitmapRestoreD = LoadBitmapA(0,MAKEINTRESOURCEA(OBM_RESTORED));
1990 }
1991
1992 if ((dwStyle & WS_SYSMENU) && !(dwExStyle & WS_EX_TOOLWINDOW))
1993 {
1994 if (DrawSysButton(hdc,FALSE))
1995 r.left += GetSystemMetrics(SM_CYCAPTION) - 1;
1996 }
1997
1998 if (dwStyle & WS_SYSMENU)
1999 {
2000 UINT state;
2001#if 0 //CB: todo
2002 /* Go get the sysmenu */
2003 state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
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 }
2140
2141 ReleaseDC(Win32Hwnd,hdc);
2142}
2143//******************************************************************************
2144//******************************************************************************
2145LONG Win32BaseWindow::HandleNCPaint(HRGN clip)
2146{
2147 if (!(dwStyle & WS_VISIBLE)) return 0;
2148
2149 if (dwStyle & WS_MINIMIZE) return 0; //CB: to check
2150
2151 DoNCPaint(clip,FALSE);
2152
2153 return 0;
2154}
2155/***********************************************************************
2156 * NC_HandleNCLButtonDblClk
2157 *
2158 * Handle a WM_NCLBUTTONDBLCLK message. Called from DefWindowProc().
2159 */
2160LONG Win32BaseWindow::HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam)
2161{
2162 /*
2163 * if this is an icon, send a restore since we are handling
2164 * a double click
2165 */
2166 if (dwStyle & WS_MINIMIZE)
2167 {
2168 SendInternalMessageA(WM_SYSCOMMAND,SC_RESTORE,lParam);
2169 return 0;
2170 }
2171
2172 switch(wParam) /* Hit test */
2173 {
2174 case HTCAPTION:
2175 /* stop processing if WS_MAXIMIZEBOX is missing */
2176 if (dwStyle & WS_MAXIMIZEBOX)
2177 SendInternalMessageA(WM_SYSCOMMAND,
2178 (dwStyle & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE,
2179 lParam);
2180 break;
2181
2182 case HTSYSMENU:
2183 if (!(GetClassWord(Win32Hwnd,GCW_STYLE) & CS_NOCLOSE))
2184 SendInternalMessageA(WM_SYSCOMMAND,SC_CLOSE,lParam);
2185 break;
2186
2187 case HTHSCROLL:
2188 SendInternalMessageA(WM_SYSCOMMAND,SC_HSCROLL+HTHSCROLL,lParam);
2189 break;
2190
2191 case HTVSCROLL:
2192 SendInternalMessageA(WM_SYSCOMMAND,SC_VSCROLL+HTVSCROLL,lParam);
2193 break;
2194 }
2195
2196 return 0;
2197}
2198/***********************************************************************
2199 * NC_HandleSysCommand
2200 *
2201 * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
2202 *
2203 * TODO: Not done (see #if 0)
2204 */
2205LONG Win32BaseWindow::HandleSysCommand(WPARAM wParam, POINT *pt32)
2206{
2207 UINT uCommand = wParam & 0xFFF0;
2208
2209 if ((getStyle() & WS_CHILD) && (uCommand != SC_KEYMENU))
2210 ScreenToClient(getParent()->getWindowHandle(), pt32 );
2211
2212 switch (uCommand)
2213 {
2214
2215 case SC_SIZE:
2216 {
2217 DWORD flags = 0;
2218
2219 switch ((wParam & 0xF)+2)
2220 {
2221 case HTLEFT:
2222 flags = TFOS_LEFT;
2223 break;
2224
2225 case HTRIGHT:
2226 flags = TFOS_RIGHT;
2227 break;
2228
2229 case HTTOP:
2230 flags = TFOS_TOP;
2231 break;
2232
2233 case HTTOPLEFT:
2234 flags = TFOS_TOP | TFOS_LEFT;
2235 break;
2236
2237 case HTTOPRIGHT:
2238 flags = TFOS_TOP | TFOS_RIGHT;
2239 break;
2240
2241 case HTBOTTOM:
2242 flags = TFOS_BOTTOM;
2243 break;
2244
2245 case HTBOTTOMLEFT:
2246 flags = TFOS_BOTTOM | TFOS_LEFT;
2247 break;
2248
2249 case HTBOTTOMRIGHT:
2250 flags = TFOS_BOTTOM | TFOS_RIGHT;
2251 break;
2252 }
2253 if (flags) FrameTrackFrame(this,flags);
2254 break;
2255 }
2256
2257 case SC_MOVE:
2258 FrameTrackFrame(this,TFOS_MOVE);
2259 break;
2260
2261 case SC_MINIMIZE:
2262 ShowWindow(SW_MINIMIZE);
2263 break;
2264
2265 case SC_MAXIMIZE:
2266 ShowWindow(SW_MAXIMIZE);
2267 break;
2268
2269 case SC_RESTORE:
2270 ShowWindow(SW_RESTORE);
2271 break;
2272
2273 case SC_CLOSE:
2274 return SendInternalMessageA(WM_CLOSE, 0, 0);
2275
2276#if 0
2277 case SC_VSCROLL:
2278 case SC_HSCROLL:
2279 NC_TrackScrollBar( hwnd, wParam, pt32 );
2280 break;
2281
2282 case SC_MOUSEMENU:
2283 MENU_TrackMouseMenuBar( wndPtr, wParam & 0x000F, pt32 );
2284 break;
2285
2286 case SC_KEYMENU:
2287 MENU_TrackKbdMenuBar( wndPtr , wParam , pt.x );
2288 break;
2289
2290 case SC_TASKLIST:
2291 WinExec( "taskman.exe", SW_SHOWNORMAL );
2292 break;
2293
2294 case SC_SCREENSAVE:
2295 if (wParam == SC_ABOUTWINE)
2296 ShellAboutA(hwnd, "Odin", WINE_RELEASE_INFO, 0);
2297 else
2298 if (wParam == SC_PUTMARK)
2299 dprintf(("Mark requested by user\n"));
2300 break;
2301
2302 case SC_HOTKEY:
2303 case SC_ARRANGE:
2304 case SC_NEXTWINDOW:
2305 case SC_PREVWINDOW:
2306 break;
2307#endif
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 return TRUE;
2471
2472 case WM_NCCREATE:
2473 return(TRUE);
2474
2475 case WM_NCDESTROY:
2476 return 0;
2477
2478 case WM_NCCALCSIZE:
2479 return HandleNCCalcSize((BOOL)wParam,(RECT*)lParam);
2480
2481 case WM_CTLCOLORMSGBOX:
2482 case WM_CTLCOLOREDIT:
2483 case WM_CTLCOLORLISTBOX:
2484 case WM_CTLCOLORBTN:
2485 case WM_CTLCOLORDLG:
2486 case WM_CTLCOLORSTATIC:
2487 case WM_CTLCOLORSCROLLBAR:
2488 return DefWndControlColor(Msg - WM_CTLCOLORMSGBOX, (HDC)wParam);
2489
2490 case WM_CTLCOLOR:
2491 return DefWndControlColor(HIWORD(lParam), (HDC)wParam);
2492
2493 case WM_VKEYTOITEM:
2494 case WM_CHARTOITEM:
2495 return -1;
2496
2497 case WM_PARENTNOTIFY:
2498 return 0;
2499
2500 case WM_MOUSEACTIVATE:
2501 {
2502 dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
2503 if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
2504 {
2505 if(getParent()) {
2506 LRESULT rc = getParent()->SendInternalMessageA(WM_MOUSEACTIVATE, wParam, lParam );
2507 if(rc) return rc;
2508 }
2509 }
2510 return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
2511 }
2512
2513 case WM_ACTIVATE:
2514 //CB: todo
2515 return 0;
2516
2517 case WM_SETCURSOR:
2518 {
2519 dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
2520 if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
2521 {
2522 if(getParent()) {
2523 LRESULT rc = getParent()->SendInternalMessageA(WM_SETCURSOR, wParam, lParam);
2524 if(rc) return rc;
2525 }
2526 }
2527 if (wParam == Win32Hwnd)
2528 {
2529 HCURSOR hCursor;
2530
2531 switch(LOWORD(lParam))
2532 {
2533 case HTLEFT:
2534 case HTRIGHT:
2535 hCursor = LoadCursorA(0,IDC_SIZEWEA);
2536 break;
2537
2538 case HTTOP:
2539 case HTBOTTOM:
2540 hCursor = LoadCursorA(0,IDC_SIZENSA);
2541 break;
2542
2543 case HTTOPLEFT:
2544 case HTBOTTOMRIGHT:
2545 hCursor = LoadCursorA(0,IDC_SIZENWSEA);
2546 break;
2547
2548 case HTTOPRIGHT:
2549 case HTBOTTOMLEFT:
2550 hCursor = LoadCursorA(0,IDC_SIZENESWA);
2551 break;
2552
2553 default:
2554 hCursor = windowClass ? windowClass->getCursor():LoadCursorA(0,IDC_ARROWA);
2555 break;
2556 }
2557
2558 if (hCursor)
2559 {
2560 SetCursor(hCursor);
2561 return 1;
2562 } else return 0;
2563 } else return 0;
2564 }
2565
2566 case WM_MOUSEMOVE:
2567 return 0;
2568
2569 case WM_WINDOWPOSCHANGED:
2570 {
2571
2572/* undocumented SWP flags - from SDK 3.1 */
2573#define SWP_NOCLIENTSIZE 0x0800
2574#define SWP_NOCLIENTMOVE 0x1000
2575
2576 PWINDOWPOS wpos = (PWINDOWPOS)lParam;
2577 WPARAM wp = SIZE_RESTORED;
2578
2579 if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE))
2580 SendInternalMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
2581
2582 if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE))
2583 {
2584 if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
2585 else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
2586
2587 SendInternalMessageA(WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left,
2588 rectClient.bottom - rectClient.top));
2589 }
2590 return 0;
2591 }
2592 case WM_WINDOWPOSCHANGING:
2593 return HandleWindowPosChanging((WINDOWPOS *)lParam);
2594
2595 case WM_ERASEBKGND:
2596 case WM_ICONERASEBKGND:
2597 {
2598 RECT rect;
2599 int rc;
2600
2601 if (!windowClass || !windowClass->getBackgroundBrush()) return 0;
2602
2603 rc = GetClipBox( (HDC)wParam, &rect );
2604 if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
2605 {
2606 HBRUSH hBrush = windowClass->getBackgroundBrush();
2607
2608 if (hBrush <= (HBRUSH)(SYSCOLOR_GetLastColor()+1)) hBrush = GetSysColorBrush(hBrush-1);
2609
2610 FillRect( (HDC)wParam, &rect, hBrush);
2611 }
2612
2613 return 1;
2614 }
2615
2616 case WM_PRINT:
2617 return DefWndPrint(wParam,lParam);
2618
2619 case WM_PAINTICON:
2620 case WM_PAINT:
2621 {
2622 PAINTSTRUCT ps;
2623 HDC hdc = BeginPaint(getWindowHandle(), &ps );
2624 if( hdc )
2625 {
2626 if( (getStyle() & WS_MINIMIZE) && getWindowClass()->getIcon())
2627 {
2628 int x = (rectWindow.right - rectWindow.left - GetSystemMetrics(SM_CXICON))/2;
2629 int y = (rectWindow.bottom - rectWindow.top - GetSystemMetrics(SM_CYICON))/2;
2630 dprintf(("Painting class icon: vis rect=(%i,%i - %i,%i)\n", ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ));
2631 DrawIcon(hdc, x, y, getWindowClass()->getIcon() );
2632 }
2633 EndPaint(getWindowHandle(), &ps );
2634 }
2635 return 0;
2636 }
2637
2638 case WM_GETDLGCODE:
2639 return 0;
2640
2641 case WM_NCLBUTTONDOWN:
2642 return HandleNCLButtonDown(wParam,lParam);
2643
2644 case WM_NCLBUTTONUP:
2645 return HandleNCLButtonUp(wParam,lParam);
2646
2647 case WM_NCLBUTTONDBLCLK:
2648 return HandleNCLButtonDblClk(wParam,lParam);
2649
2650 case WM_NCRBUTTONDOWN:
2651 case WM_NCRBUTTONDBLCLK:
2652 case WM_NCMBUTTONDOWN:
2653 case WM_NCMBUTTONDBLCLK:
2654 if (lastHitTestVal == HTERROR) MessageBeep(MB_ICONEXCLAMATION);
2655 return 0;
2656
2657 case WM_NCRBUTTONUP:
2658 case WM_NCMBUTTONUP:
2659 return 0;
2660
2661 case WM_NCHITTEST:
2662 {
2663 POINT point;
2664
2665 point.x = (SHORT)LOWORD(lParam);
2666 point.y = (SHORT)HIWORD(lParam);
2667
2668 return HandleNCHitTest(point);
2669 }
2670
2671 case WM_SYSCOMMAND:
2672 {
2673 POINT point;
2674
2675 point.x = LOWORD(lParam);
2676 point.y = HIWORD(lParam);
2677 return HandleSysCommand(wParam, &point);
2678 }
2679
2680 case WM_SYSKEYDOWN:
2681 if(wParam == VK_F4) /* try to close the window */
2682 {
2683 Win32BaseWindow *window = GetTopParent();
2684 if(window && !(window->getClass()->getStyle() & CS_NOCLOSE))
2685 PostMessageA(getWindowHandle(), WM_SYSCOMMAND, SC_CLOSE, 0);
2686 }
2687
2688 Win32BaseWindow *siblingWindow;
2689 HWND sibling;
2690 char nameBuffer [40], mnemonic;
2691 int nameLength;
2692
2693 GetWindowTextA (nameBuffer, 40);
2694
2695 // search all sibling to see it this key is their mnemonic
2696 sibling = GetWindow (GW_HWNDFIRST);
2697 while (sibling != 0) {
2698 siblingWindow = GetWindowFromHandle (sibling);
2699 nameLength = siblingWindow->GetWindowTextA (nameBuffer, 40);
2700
2701 // find the siblings mnemonic
2702 mnemonic = '\0';
2703 for (int i=0 ; i<nameLength ; i++) {
2704 if (nameBuffer [i] == '&') {
2705 mnemonic = nameBuffer [i+1];
2706 if ((mnemonic >= 'a') && (mnemonic <= 'z'))
2707 mnemonic -= 32; // make it uppercase
2708 break; // stop searching
2709 }
2710 }
2711
2712 // key matches siblings mnemonic, send mouseclick
2713 if (mnemonic == (char) wParam) {
2714 siblingWindow->SendInternalMessageA (BM_CLICK, 0, 0);
2715 }
2716
2717 sibling = siblingWindow->GetNextWindow (GW_HWNDNEXT);
2718 }
2719
2720 return 0;
2721
2722 case WM_SHOWWINDOW:
2723 if (!lParam) return 0; /* sent from ShowWindow */
2724 if (!(dwStyle & WS_POPUP) || !owner) return 0;
2725 if ((dwStyle & WS_VISIBLE) && wParam) return 0;
2726 else if (!(dwStyle & WS_VISIBLE) && !wParam) return 0;
2727 ShowWindow(wParam ? SW_SHOWNOACTIVATE : SW_HIDE);
2728 return 0;
2729
2730 case WM_CANCELMODE:
2731 //if (getParent() == windowDesktop) EndMenu();
2732 if (GetCapture() == Win32Hwnd) ReleaseCapture();
2733 return 0;
2734
2735 case WM_DROPOBJECT:
2736 return DRAG_FILE;
2737
2738 case WM_QUERYDROPOBJECT:
2739 if (dwExStyle & WS_EX_ACCEPTFILES) return 1;
2740 return 0;
2741
2742 case WM_QUERYDRAGICON:
2743 {
2744 HICON hIcon = windowClass->getCursor();
2745 UINT len;
2746
2747 if(hIcon) return (LRESULT)hIcon;
2748 for(len = 1; len < 64; len++)
2749 {
2750 hIcon = LoadIconA(hInstance,MAKEINTRESOURCEA(len));
2751 if(hIcon)
2752 return (LRESULT)hIcon;
2753 }
2754 return (LRESULT)LoadIconA(0,IDI_APPLICATIONA);
2755 }
2756
2757 case WM_QUERYOPEN:
2758 case WM_QUERYENDSESSION:
2759 return 1;
2760
2761 case WM_NOTIFYFORMAT:
2762 if (IsWindowUnicode()) return NFR_UNICODE;
2763 else return NFR_ANSI;
2764
2765 case WM_SETICON:
2766 case WM_GETICON:
2767 {
2768 LRESULT result = 0;
2769 if (!windowClass) return result;
2770 int index = GCL_HICON;
2771
2772 if (wParam == ICON_SMALL)
2773 index = GCL_HICONSM;
2774
2775 result = windowClass->getClassLongA(index);
2776
2777 if (Msg == WM_SETICON)
2778 windowClass->setClassLongA(index, lParam);
2779
2780 return result;
2781 }
2782
2783 case WM_NOTIFY:
2784 return 0; //comctl32 controls expect this
2785
2786 default:
2787 if(Msg > WM_USER) {
2788 return 0;
2789 }
2790 return 1; //CB: shouldn't this be 0?
2791 }
2792}
2793//******************************************************************************
2794//******************************************************************************
2795LRESULT Win32BaseWindow::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam)
2796{
2797 switch(Msg)
2798 {
2799 case WM_GETTEXTLENGTH:
2800 return wndNameLength;
2801
2802 case WM_GETTEXT:
2803 if (!lParam || !wParam) return 0;
2804 if (!windowNameW) ((LPWSTR)lParam)[0] = 0;
2805 else lstrcpynW((LPWSTR)lParam,windowNameW,wParam);
2806 return min(wndNameLength,wParam);
2807
2808 case WM_SETTEXT:
2809 {
2810 LPWSTR lpsz = (LPWSTR)lParam;
2811
2812 if(windowNameA) free(windowNameA);
2813 if(windowNameW) free(windowNameW);
2814
2815 if (lParam)
2816 {
2817 wndNameLength = lstrlenW(lpsz);
2818 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
2819 lstrcpyWtoA(windowNameA,lpsz);
2820 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
2821 lstrcpyW(windowNameW,lpsz);
2822 }
2823 else
2824 {
2825 windowNameA = NULL;
2826 windowNameW = NULL;
2827 wndNameLength = 0;
2828 }
2829
2830 if(OS2HwndFrame && (dwStyle & WS_CAPTION) == WS_CAPTION)
2831 return OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
2832
2833 return TRUE;
2834 }
2835
2836 default:
2837 return DefWindowProcA(Msg, wParam, lParam);
2838 }
2839}
2840//******************************************************************************
2841//******************************************************************************
2842LRESULT Win32BaseWindow::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
2843{
2844 //if the destination window is created by this process & thread, call window proc directly
2845 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
2846 return SendInternalMessageA(Msg, wParam, lParam);
2847 }
2848 //otherwise use WinSendMsg to send it to the right process/thread
2849 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, FALSE);
2850}
2851//******************************************************************************
2852//******************************************************************************
2853LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
2854{
2855 //if the destination window is created by this process & thread, call window proc directly
2856 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
2857 return SendInternalMessageW(Msg, wParam, lParam);
2858 }
2859 //otherwise use WinSendMsg to send it to the right process/thread
2860 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, TRUE);
2861}
2862//******************************************************************************
2863//Called as a result of an OS/2 message or called from a class method
2864//******************************************************************************
2865LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
2866{
2867 LRESULT rc;
2868 BOOL fInternalMsgBackup = fInternalMsg;
2869
2870 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE);
2871
2872 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, FALSE);
2873
2874 fInternalMsg = TRUE;
2875 switch(Msg)
2876 {
2877 case WM_CREATE:
2878 {
2879 if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
2880 dprintf(("WM_CREATE returned -1\n"));
2881 rc = -1; //don't create window
2882 break;
2883 }
2884 rc = 0;
2885 break;
2886 }
2887 case WM_LBUTTONDOWN:
2888 case WM_MBUTTONDOWN:
2889 case WM_RBUTTONDOWN:
2890 {
2891 if (getParent())
2892 {
2893 POINTS pt = MAKEPOINTS(lParam);
2894 POINT point;
2895
2896 point.x = pt.x;
2897 point.y = pt.y;
2898 MapWindowPoints(Win32Hwnd,getParent()->getWindowHandle(),&point,1);
2899 NotifyParent(Msg,wParam,MAKELPARAM(point.x,point.y));
2900 }
2901 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
2902 break;
2903 }
2904
2905 case WM_DESTROY:
2906 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
2907 break;
2908
2909 default:
2910 rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
2911 break;
2912 }
2913 fInternalMsg = fInternalMsgBackup;
2914 return rc;
2915}
2916//******************************************************************************
2917//Called as a result of an OS/2 message or called from a class method
2918//******************************************************************************
2919LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
2920{
2921 LRESULT rc;
2922 BOOL fInternalMsgBackup = fInternalMsg;
2923
2924 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE);
2925
2926 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, TRUE);
2927
2928 fInternalMsg = TRUE;
2929 switch(Msg)
2930 {
2931 case WM_CREATE:
2932 {
2933 if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
2934 dprintf(("WM_CREATE returned -1\n"));
2935 rc = -1; //don't create window
2936 break;
2937 }
2938 rc = 0;
2939 break;
2940 }
2941 case WM_LBUTTONDOWN:
2942 case WM_MBUTTONDOWN:
2943 case WM_RBUTTONDOWN:
2944 NotifyParent(Msg, wParam, lParam);
2945 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
2946 break;
2947
2948 case WM_DESTROY:
2949 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
2950 break;
2951 default:
2952 rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
2953 break;
2954 }
2955 fInternalMsg = fInternalMsgBackup;
2956 return rc;
2957}
2958//******************************************************************************
2959//******************************************************************************
2960void Win32BaseWindow::CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
2961{
2962 CWPSTRUCT cwp;
2963
2964 cwp.lParam = lParam;
2965 cwp.wParam = wParam;
2966 cwp.message = Msg;
2967 cwp.hwnd = getWindowHandle();
2968
2969 switch(hooktype) {
2970 case WH_CALLWNDPROC:
2971 if(fUnicode) {
2972 HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
2973 }
2974 else HOOK_CallHooksA(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
2975 break;
2976 }
2977}
2978//******************************************************************************
2979//******************************************************************************
2980//******************************************************************************
2981//TODO: Do this more efficiently
2982//******************************************************************************
2983LRESULT Win32BaseWindow::BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam)
2984{
2985 Win32BaseWindow *window;
2986 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
2987
2988 dprintf(("BroadCastMessageA %x %x %x", msg, wParam, lParam, GetFS()));
2989
2990 for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
2991 window = GetWindowFromHandle(hwnd++);
2992 if(window) {
2993 if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
2994 {
2995
2996 if(type == BROADCAST_SEND) {
2997 window->SendInternalMessageA(msg, wParam, lParam);
2998 }
2999 else PostMessageA(window->getWindowHandle(), msg, wParam, lParam);
3000 }
3001 }
3002 }
3003 return 0;
3004}
3005//******************************************************************************
3006//TODO: Do this more efficiently
3007//******************************************************************************
3008LRESULT Win32BaseWindow::BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam)
3009{
3010 Win32BaseWindow *window;
3011 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
3012
3013 dprintf(("BroadCastMessageW %x %x %x", msg, wParam, lParam));
3014
3015 for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
3016 window = GetWindowFromHandle(hwnd++);
3017 if(window) {
3018 if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
3019 {
3020
3021 if(type == BROADCAST_SEND) {
3022 window->SendInternalMessageW(msg, wParam, lParam);
3023 }
3024 else PostMessageW(window->getWindowHandle(), msg, wParam, lParam);
3025 }
3026 }
3027 }
3028 return 0;
3029}
3030//******************************************************************************
3031//******************************************************************************
3032void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
3033{
3034 Win32BaseWindow *window = this;
3035 Win32BaseWindow *parentwindow;
3036
3037 while(window)
3038 {
3039 if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
3040 {
3041 /* Notify the parent window only */
3042 parentwindow = window->getParent();
3043 if(parentwindow) {
3044 parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam );
3045 }
3046 }
3047 else break;
3048
3049 window = parentwindow;
3050 }
3051}
3052//******************************************************************************
3053//******************************************************************************
3054BOOL Win32BaseWindow::SetMenu(HMENU hMenu)
3055{
3056
3057 dprintf(("SetMenu %x", hMenu));
3058 OS2HwndMenu = OSLibWinSetMenu(OS2HwndFrame, hMenu);
3059 if(OS2HwndMenu == 0) {
3060 dprintf(("Win32BaseWindow::SetMenu OS2HwndMenu == 0"));
3061 return FALSE;
3062 }
3063 return TRUE;
3064}
3065//******************************************************************************
3066//******************************************************************************
3067BOOL Win32BaseWindow::SetIcon(HICON hIcon)
3068{
3069 dprintf(("Win32BaseWindow::SetIcon %x", hIcon));
3070 if(OSLibWinSetIcon(OS2HwndFrame, hIcon) == TRUE) {
3071//TODO: Wine does't send these. Correct?
3072// SendInternalMessageA(WM_SETICON, ICON_BIG, hIcon);
3073 return TRUE;
3074 }
3075 return FALSE;
3076}
3077//******************************************************************************
3078//******************************************************************************
3079BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow)
3080{
3081 ULONG showstate = 0;
3082 HWND hWinAfter;
3083
3084 dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
3085#if 1
3086 if (flags & WIN_NEED_SIZE)
3087 {
3088 /* should happen only in CreateWindowEx() */
3089 int wParam = SIZE_RESTORED;
3090
3091 flags &= ~WIN_NEED_SIZE;
3092 if (dwStyle & WS_MAXIMIZE)
3093 wParam = SIZE_MAXIMIZED;
3094 else
3095 if (dwStyle & WS_MINIMIZE)
3096 wParam = SIZE_MINIMIZED;
3097
3098 SendInternalMessageA(WM_SIZE, wParam,
3099 MAKELONG(rectClient.right-rectClient.left,
3100 rectClient.bottom-rectClient.top));
3101 SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
3102 }
3103#else
3104 if(fFirstShow) {
3105 if(isFrameWindow() && IS_OVERLAPPED(getStyle()) && !isChild()) {
3106 SendInternalMessageA(WM_SIZE, SIZE_RESTORED,
3107 MAKELONG(rectClient.right-rectClient.left,
3108 rectClient.bottom-rectClient.top));
3109 SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
3110
3111 }
3112 fFirstShow = FALSE;
3113 }
3114#endif
3115 switch(nCmdShow)
3116 {
3117 case SW_SHOW:
3118 case SW_SHOWDEFAULT: //todo
3119 showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
3120 break;
3121 case SW_HIDE:
3122 showstate = SWPOS_HIDE;
3123 break;
3124 case SW_RESTORE:
3125 showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
3126 break;
3127 case SW_MINIMIZE:
3128 showstate = SWPOS_MINIMIZE;
3129 break;
3130 case SW_SHOWMAXIMIZED:
3131 showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
3132 break;
3133 case SW_SHOWMINIMIZED:
3134 showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
3135 break;
3136 case SW_SHOWMINNOACTIVE:
3137 showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
3138 break;
3139 case SW_SHOWNA:
3140 showstate = SWPOS_SHOW;
3141 break;
3142 case SW_SHOWNOACTIVATE:
3143 showstate = SWPOS_SHOW;
3144 break;
3145 case SW_SHOWNORMAL:
3146 showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
3147 break;
3148 }
3149
3150 /* We can't activate a child window (WINE) */
3151 if(getStyle() & WS_CHILD)
3152 showstate &= ~SWPOS_ACTIVATE;
3153
3154 if(showstate & SWPOS_SHOW) {
3155 setStyle(getStyle() | WS_VISIBLE);
3156 }
3157 else setStyle(getStyle() & ~WS_VISIBLE);
3158
3159 BOOL rc = OSLibWinShowWindow(OS2HwndFrame, showstate);
3160
3161 return rc;
3162}
3163//******************************************************************************
3164//******************************************************************************
3165BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
3166{
3167 BOOL rc = FALSE;
3168 Win32BaseWindow *window;
3169 HWND hParent = 0;
3170
3171 dprintf (("SetWindowPos %x %x (%d,%d)(%d,%d) %x", Win32Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
3172
3173 if (fuFlags &
3174 ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
3175 SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED |
3176 SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS |
3177 SWP_NOOWNERZORDER))
3178 {
3179 return FALSE;
3180 }
3181
3182 WINDOWPOS wpos;
3183 SWP swp, swpOld;
3184
3185 wpos.flags = fuFlags;
3186 wpos.cy = cy;
3187 wpos.cx = cx;
3188 wpos.x = x;
3189 wpos.y = y;
3190 wpos.hwndInsertAfter = hwndInsertAfter;
3191 wpos.hwnd = getWindowHandle();
3192
3193 if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
3194 {
3195 if (isChild())
3196 {
3197 Win32BaseWindow *windowParent = getParent();
3198 if(windowParent) {
3199 hParent = getParent()->getOS2WindowHandle();
3200 }
3201 else dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
3202 }
3203 OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
3204 }
3205
3206 OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame);
3207 if (swp.fl == 0)
3208 return TRUE;
3209
3210// if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
3211 if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
3212 {
3213 Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
3214 if(wndBehind) {
3215 swp.hwndInsertBehind = wndBehind->getOS2FrameWindowHandle();
3216 }
3217 else {
3218 dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
3219 swp.hwndInsertBehind = 0;
3220 }
3221 }
3222#if 0
3223 if (isFrameWindow())
3224 {
3225 if (!isChild())
3226 {
3227 POINT maxSize, maxPos, minTrack, maxTrack;
3228
3229 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
3230
3231 if (swp.cx > maxTrack.x) swp.cx = maxTrack.x;
3232 if (swp.cy > maxTrack.y) swp.cy = maxTrack.y;
3233 if (swp.cx < minTrack.x) swp.cx = minTrack.x;
3234 if (swp.cy < minTrack.y) swp.cy = minTrack.y;
3235 }
3236 swp.hwnd = OS2HwndFrame;
3237 }
3238 else
3239#endif
3240 swp.hwnd = OS2HwndFrame;
3241
3242 dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
3243
3244 rc = OSLibWinSetMultWindowPos(&swp, 1);
3245
3246 if (rc == FALSE)
3247 {
3248 dprintf(("OSLibWinSetMultWindowPos failed! Error %x",OSLibWinGetLastError()));
3249 }
3250
3251 //SWP_FRAMECHANGED is ignored, not necessary for OS/2
3252
3253 return (rc);
3254}
3255//******************************************************************************
3256//TODO: WPF_RESTOREMAXIMIZED
3257//******************************************************************************
3258BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *winpos)
3259{
3260 if(isFrameWindow())
3261 {
3262 // Set the minimized position
3263 if (winpos->flags & WPF_SETMINPOSITION)
3264 {
3265 OSLibSetWindowMinPos(OS2HwndFrame, winpos->ptMinPosition.x, winpos->ptMinPosition.y);
3266 }
3267
3268 //TODO: Max position
3269
3270 // Set the new restore position.
3271 OSLibSetWindowRestoreRect(OS2HwndFrame, &winpos->rcNormalPosition);
3272 }
3273
3274 return ShowWindow(winpos->showCmd);
3275}
3276//******************************************************************************
3277//Also destroys all the child windows (destroy children first, parent last)
3278//******************************************************************************
3279BOOL Win32BaseWindow::DestroyWindow()
3280{
3281 /* Call hooks */
3282 if(HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, getWindowHandle(), 0L))
3283 {
3284 return FALSE;
3285 }
3286
3287 if(!(getStyle() & WS_CHILD) && getOwner() == NULL)
3288 {
3289 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWDESTROYED, getWindowHandle(), 0L);
3290 /* FIXME: clean up palette - see "Internals" p.352 */
3291 }
3292
3293 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
3294 {
3295 if(getParent())
3296 {
3297 /* Notify the parent window only */
3298 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
3299 if( !::IsWindow(getWindowHandle()) )
3300 {
3301 return TRUE;
3302 }
3303 }
3304 else DebugInt3();
3305 }
3306 fDestroyWindowCalled = TRUE;
3307 return OSLibWinDestroyWindow(OS2HwndFrame);
3308}
3309//******************************************************************************
3310//******************************************************************************
3311Win32BaseWindow *Win32BaseWindow::getParent()
3312{
3313 Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::GetParent();
3314 return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
3315}
3316//******************************************************************************
3317//******************************************************************************
3318HWND Win32BaseWindow::GetParent()
3319{
3320 Win32BaseWindow *wndparent;
3321
3322 if ((!(getStyle() & (WS_POPUP|WS_CHILD))))
3323 {
3324 return 0;
3325 }
3326 wndparent = ((getStyle() & WS_CHILD) ? getParent() : getOwner());
3327
3328 return (wndparent) ? wndparent->getWindowHandle() : 0;
3329}
3330//******************************************************************************
3331//******************************************************************************
3332HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
3333{
3334 HWND oldhwnd;
3335 Win32BaseWindow *newparent;
3336
3337 if(getParent()) {
3338 oldhwnd = getParent()->getWindowHandle();
3339 getParent()->RemoveChild(this);
3340 }
3341 else oldhwnd = 0;
3342
3343 newparent = GetWindowFromHandle(hwndNewParent);
3344 if(newparent)
3345 {
3346 setParent(newparent);
3347 getParent()->AddChild(this);
3348 OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
3349 return oldhwnd;
3350 }
3351 else {
3352 setParent(windowDesktop);
3353 windowDesktop->AddChild(this);
3354 OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
3355 return oldhwnd;
3356 }
3357}
3358//******************************************************************************
3359//******************************************************************************
3360BOOL Win32BaseWindow::IsChild(HWND hwndParent)
3361{
3362 if(getParent()) {
3363 return getParent()->getWindowHandle() == hwndParent;
3364 }
3365 else return 0;
3366}
3367//******************************************************************************
3368//******************************************************************************
3369HWND Win32BaseWindow::GetTopWindow()
3370{
3371 return GetWindow(GW_CHILD);
3372}
3373//******************************************************************************
3374// Get the top-level parent for a child window.
3375//******************************************************************************
3376Win32BaseWindow *Win32BaseWindow::GetTopParent()
3377{
3378 Win32BaseWindow *window = this;
3379
3380 while(window && (window->getStyle() & WS_CHILD))
3381 {
3382 window = window->getParent();
3383 }
3384 return window;
3385}
3386//******************************************************************************
3387//Don't call WinUpdateWindow as that one also updates the child windows
3388//Also need to send WM_PAINT directly to the window procedure, which doesn't
3389//always happen with WinUpdateWindow (could be posted if thread doesn't own window)
3390//******************************************************************************
3391BOOL Win32BaseWindow::UpdateWindow()
3392{
3393 RECT rect;
3394
3395 if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect))
3396 {//update region not empty
3397 HDC hdc;
3398
3399 hdc = O32_GetDC(OS2Hwnd);
3400 if (isIcon)
3401 {
3402 SendInternalMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
3403 SendInternalMessageA(WM_PAINTICON, 0, 0);
3404 }
3405 else
3406 {
3407 SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
3408 SendInternalMessageA(WM_PAINT, 0, 0);
3409 }
3410 O32_ReleaseDC(OS2Hwnd, hdc);
3411 }
3412 return TRUE;
3413}
3414//******************************************************************************
3415//******************************************************************************
3416BOOL Win32BaseWindow::IsIconic()
3417{
3418 return OSLibWinIsIconic(OS2Hwnd);
3419}
3420//******************************************************************************
3421//TODO: Should not enumerate children that are created during the enumeration!
3422//******************************************************************************
3423BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
3424{
3425 BOOL rc = TRUE;
3426 HWND hwnd;
3427 Win32BaseWindow *prevchild = 0, *child = 0;
3428
3429 dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
3430 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
3431 {
3432 dprintf(("EnumChildWindows: enumerating child %x", child->getWindowHandle()));
3433 hwnd = child->getWindowHandle();
3434 if(child->getOwner()) {
3435 continue; //shouldn't have an owner (Wine)
3436 }
3437 if(lpfn(hwnd, lParam) == FALSE)
3438 {
3439 rc = FALSE;
3440 break;
3441 }
3442 //check if the window still exists
3443 if(!::IsWindow(hwnd))
3444 {
3445 child = prevchild;
3446 continue;
3447 }
3448 if(child->getFirstChild() != NULL)
3449 {
3450 dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle()));
3451 if(child->EnumChildWindows(lpfn, lParam) == FALSE)
3452 {
3453 rc = FALSE;
3454 break;
3455 }
3456 }
3457 prevchild = child;
3458 }
3459 return rc;
3460}
3461//******************************************************************************
3462//Enumerate first-level children only and check thread id
3463//******************************************************************************
3464BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
3465{
3466 Win32BaseWindow *child = 0;
3467 ULONG tid, pid;
3468 BOOL rc;
3469 HWND hwnd;
3470
3471 dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam));
3472
3473 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
3474 {
3475 OSLibWinQueryWindowProcess(child->getOS2WindowHandle(), &pid, &tid);
3476
3477 if(dwThreadId == tid) {
3478 dprintf2(("EnumThreadWindows: Found Window %x", child->getWindowHandle()));
3479 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
3480 break;
3481 }
3482 }
3483 }
3484 return TRUE;
3485}
3486//******************************************************************************
3487//Enumerate first-level children only
3488//******************************************************************************
3489BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
3490{
3491 Win32BaseWindow *child = 0;
3492 BOOL rc;
3493 HWND hwnd;
3494
3495 dprintf(("EnumWindows %x %x", lpfn, lParam));
3496
3497 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
3498 {
3499 hwnd = child->getWindowHandle();
3500
3501 dprintf2(("EnumWindows: Found Window %x", child->getWindowHandle()));
3502 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
3503 break;
3504 }
3505 }
3506 return TRUE;
3507}
3508//******************************************************************************
3509//******************************************************************************
3510Win32BaseWindow *Win32BaseWindow::FindWindowById(int id)
3511{
3512 for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
3513 {
3514 if (child->getWindowId() == id)
3515 {
3516 return child;
3517 }
3518 }
3519 return 0;
3520}
3521//******************************************************************************
3522//TODO:
3523//We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
3524//the current process owns them.
3525//******************************************************************************
3526HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
3527 BOOL fUnicode)
3528{
3529 Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
3530 Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
3531
3532 if((hwndParent != OSLIB_HWND_DESKTOP && !parent) ||
3533 (hwndChildAfter != 0 && !child) ||
3534 (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0))
3535 {
3536 dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
3537 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
3538 return 0;
3539 }
3540 if(hwndParent != OSLIB_HWND_DESKTOP)
3541 {//if the current process owns the window, just do a quick search
3542 child = (Win32BaseWindow *)parent->getFirstChild();
3543 if(hwndChildAfter != 0)
3544 {
3545 while(child)
3546 {
3547 if(child->getWindowHandle() == hwndChildAfter)
3548 {
3549 child = (Win32BaseWindow *)child->getNextChild();
3550 break;
3551 }
3552 child = (Win32BaseWindow *)child->getNextChild();
3553 }
3554 }
3555 while(child)
3556 {
3557 if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
3558 (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
3559 {
3560 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
3561 return child->getWindowHandle();
3562 }
3563 child = (Win32BaseWindow *)child->getNextChild();
3564 }
3565 }
3566 else {
3567 Win32BaseWindow *wnd;
3568 HWND henum, hwnd;
3569
3570 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
3571 hwnd = OSLibWinGetNextWindow(henum);
3572
3573 while(hwnd)
3574 {
3575 wnd = GetWindowFromOS2Handle(hwnd);
3576 if(wnd == NULL) {
3577 hwnd = OSLibWinQueryClientWindow(hwnd);
3578 if(hwnd) wnd = GetWindowFromOS2Handle(hwnd);
3579 if(!hwnd) wnd = GetWindowFromOS2FrameHandle(hwnd);
3580 }
3581
3582 if(wnd) {
3583 if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
3584 (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
3585 {
3586 OSLibWinEndEnumWindows(henum);
3587 dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
3588 return wnd->getWindowHandle();
3589 }
3590 }
3591 hwnd = OSLibWinGetNextWindow(henum);
3592 }
3593 OSLibWinEndEnumWindows(henum);
3594 }
3595 SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
3596 return 0;
3597}
3598//******************************************************************************
3599//******************************************************************************
3600HWND Win32BaseWindow::GetWindow(UINT uCmd)
3601{
3602 HWND hwndRelated = 0;
3603 Win32BaseWindow *window;
3604
3605 switch(uCmd)
3606 {
3607 case GW_HWNDFIRST:
3608 if(getParent()) {
3609 window = (Win32BaseWindow *)getParent()->getFirstChild();
3610 hwndRelated = window->getWindowHandle();
3611 }
3612 break;
3613
3614 case GW_HWNDLAST:
3615 if(!getParent())
3616 {
3617 goto end;
3618 }
3619
3620 window = this;
3621 while(window->getNextChild())
3622 {
3623 window = (Win32BaseWindow *)window->getNextChild();
3624 }
3625 hwndRelated = window->getWindowHandle();
3626 break;
3627
3628 case GW_HWNDNEXT:
3629 window = (Win32BaseWindow *)getNextChild();
3630 if(window) {
3631 hwndRelated = window->getWindowHandle();
3632 }
3633 break;
3634
3635 case GW_HWNDPREV:
3636 if(!getParent())
3637 {
3638 goto end;
3639 }
3640 window = (Win32BaseWindow *)(getParent()->getFirstChild()); /* First sibling */
3641 if(window == this)
3642 {
3643 hwndRelated = 0; /* First in list */
3644 goto end;
3645 }
3646 while(window->getNextChild())
3647 {
3648 if (window->getNextChild() == this)
3649 {
3650 hwndRelated = window->getWindowHandle();
3651 goto end;
3652 }
3653 window = (Win32BaseWindow *)window->getNextChild();
3654 }
3655 break;
3656
3657 case GW_OWNER:
3658 if(getOwner()) {
3659 hwndRelated = getOwner()->getWindowHandle();
3660 }
3661 break;
3662
3663 case GW_CHILD:
3664 if(getFirstChild()) {
3665 hwndRelated = ((Win32BaseWindow *)getFirstChild())->getWindowHandle();
3666 }
3667 break;
3668 }
3669end:
3670 dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
3671 return hwndRelated;
3672}
3673//******************************************************************************
3674//******************************************************************************
3675HWND Win32BaseWindow::SetActiveWindow()
3676{
3677 HWND hwndActive;
3678 Win32BaseWindow *win32wnd;
3679 ULONG magic;
3680
3681 hwndActive = OSLibWinSetActiveWindow(OS2HwndFrame);
3682 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32WNDPTR);
3683 magic = OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32PM_MAGIC);
3684 if(CheckMagicDword(magic) && win32wnd)
3685 {
3686 return win32wnd->getWindowHandle();
3687 }
3688 return 0;
3689}
3690//******************************************************************************
3691//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
3692//******************************************************************************
3693BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
3694{
3695 return OSLibWinEnableWindow(OS2HwndFrame, fEnable);
3696}
3697//******************************************************************************
3698//******************************************************************************
3699BOOL Win32BaseWindow::CloseWindow()
3700{
3701 return OSLibWinMinimizeWindow(OS2HwndFrame);
3702}
3703//******************************************************************************
3704//******************************************************************************
3705HWND Win32BaseWindow::GetActiveWindow()
3706{
3707 HWND hwndActive;
3708 Win32BaseWindow *win32wnd;
3709 ULONG magic;
3710
3711 hwndActive = OSLibWinQueryActiveWindow();
3712
3713 return OS2ToWin32Handle(hwndActive);
3714}
3715//******************************************************************************
3716//******************************************************************************
3717BOOL Win32BaseWindow::IsWindowEnabled()
3718{
3719 return OSLibWinIsWindowEnabled(OS2HwndFrame);
3720}
3721//******************************************************************************
3722//******************************************************************************
3723BOOL Win32BaseWindow::IsWindowVisible()
3724{
3725#if 1
3726 return (dwStyle & WS_VISIBLE) == WS_VISIBLE;
3727#else
3728 return OSLibWinIsWindowVisible(OS2HwndFrame);
3729#endif
3730}
3731//******************************************************************************
3732//******************************************************************************
3733BOOL Win32BaseWindow::GetWindowRect(PRECT pRect)
3734{
3735 return OSLibWinQueryWindowRect(OS2HwndFrame, pRect, RELATIVE_TO_SCREEN);
3736}
3737//******************************************************************************
3738//******************************************************************************
3739BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
3740{
3741 INT len = GetWindowTextLength();
3742 BOOL res;
3743
3744 if (wndname == NULL)
3745 return (len == 0);
3746
3747 len++;
3748 if (fUnicode)
3749 {
3750 WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR));
3751
3752 GetWindowTextW(text,len);
3753 res = (lstrcmpW(text,(LPWSTR)wndname) == 0);
3754 free(text);
3755 } else
3756 {
3757 CHAR *text = (CHAR*)malloc(len*sizeof(CHAR));
3758
3759 GetWindowTextA(text,len);
3760 res = (strcmp(text,wndname) == 0);
3761 free(text);
3762 }
3763
3764 return res;
3765}
3766//******************************************************************************
3767//******************************************************************************
3768CHAR *Win32BaseWindow::getWindowNamePtrA()
3769{
3770 INT len = GetWindowTextLength();
3771 CHAR *text;
3772
3773 if (len == 0) return NULL;
3774 len++;
3775 text = (CHAR*)malloc(len*sizeof(CHAR));
3776 GetWindowTextA(text,len);
3777
3778 return text;
3779}
3780//******************************************************************************
3781//******************************************************************************
3782WCHAR *Win32BaseWindow::getWindowNamePtrW()
3783{
3784 INT len = GetWindowTextLength();
3785 WCHAR *text;
3786
3787 if (len == 0) return NULL;
3788 len++;
3789 text = (WCHAR*)malloc(len*sizeof(WCHAR));
3790 GetWindowTextW(text,len);
3791
3792 return text;
3793}
3794//******************************************************************************
3795//******************************************************************************
3796VOID Win32BaseWindow::freeWindowNamePtr(PVOID namePtr)
3797{
3798 if (namePtr) free(namePtr);
3799}
3800//******************************************************************************
3801//******************************************************************************
3802int Win32BaseWindow::GetWindowTextLength()
3803{
3804 return SendInternalMessageA(WM_GETTEXTLENGTH,0,0);
3805}
3806//******************************************************************************
3807//******************************************************************************
3808int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
3809{
3810 return SendInternalMessageA(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
3811}
3812//******************************************************************************
3813//******************************************************************************
3814int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
3815{
3816 return SendInternalMessageW(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
3817}
3818//******************************************************************************
3819//******************************************************************************
3820BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
3821{
3822 return SendInternalMessageA(WM_SETTEXT,0,(LPARAM)lpsz);
3823}
3824//******************************************************************************
3825//******************************************************************************
3826BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
3827{
3828 return SendInternalMessageW(WM_SETTEXT,0,(LPARAM)lpsz);
3829}
3830//******************************************************************************
3831//******************************************************************************
3832VOID Win32BaseWindow::updateWindowStyle(DWORD oldExStyle,DWORD oldStyle)
3833{
3834 if(IsWindowDestroyed()) return;
3835
3836 //CB: todo: dwExStyle, creating new frame controls, destroy not used controls, WS_VISIBLE, WS_CHILD, ...
3837 // write test cases
3838 if ((dwStyle & 0xFFFF0000) != (oldStyle & 0xFFFF0000))
3839 {
3840 //dprintf(("updateWindowStyle: %x %x",oldStyle,dwStyle));
3841 OSLibSetWindowStyle(OS2HwndFrame, dwStyle, fTaskList);
3842 }
3843}
3844//******************************************************************************
3845//******************************************************************************
3846LONG Win32BaseWindow::SetWindowLongA(int index, ULONG value, BOOL fUnicode)
3847{
3848 LONG oldval;
3849
3850 dprintf2(("SetWindowLong%c %x %d %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
3851 switch(index) {
3852 case GWL_EXSTYLE:
3853 {
3854 STYLESTRUCT ss;
3855
3856 if(dwExStyle == value)
3857 return value;
3858
3859 ss.styleOld = dwExStyle;
3860 ss.styleNew = value;
3861 dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
3862 SendInternalMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
3863 setExStyle(ss.styleNew);
3864 updateWindowStyle(ss.styleOld,getStyle());
3865 SendInternalMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
3866 return ss.styleOld;
3867 }
3868 case GWL_STYLE:
3869 {
3870 STYLESTRUCT ss;
3871
3872 if(dwStyle == value)
3873 return value;
3874
3875 value &= ~(WS_VISIBLE | WS_CHILD); /* Some bits can't be changed this way (WINE) */
3876 ss.styleOld = getStyle();
3877 ss.styleNew = value | (ss.styleOld & (WS_VISIBLE | WS_CHILD));
3878 dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), ss.styleOld, ss.styleNew));
3879 SendInternalMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
3880 setStyle(ss.styleNew);
3881 updateWindowStyle(dwExStyle,ss.styleOld);
3882 SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
3883#ifdef DEBUG
3884 PrintWindowStyle(ss.styleNew, 0);
3885#endif
3886 return ss.styleOld;
3887 }
3888 case GWL_WNDPROC:
3889 oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
3890 //WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A, WIN_PROC_WINDOW);
3891 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, WINPROC_GetProcType(win32wndproc), WIN_PROC_WINDOW);
3892 return oldval;
3893 case GWL_HINSTANCE:
3894 oldval = hInstance;
3895 hInstance = value;
3896 return oldval;
3897 case GWL_HWNDPARENT:
3898 return SetParent((HWND)value);
3899 case GWL_ID:
3900 oldval = getWindowId();
3901 setWindowId(value);
3902 return oldval;
3903 case GWL_USERDATA:
3904 oldval = userData;
3905 userData = value;
3906 return oldval;
3907 default:
3908 if(index >= 0 && index/4 < nrUserWindowLong)
3909 {
3910 oldval = userWindowLong[index/4];
3911 userWindowLong[index/4] = value;
3912 return oldval;
3913 }
3914 SetLastError(ERROR_INVALID_PARAMETER);
3915 return 0;
3916 }
3917}
3918//******************************************************************************
3919//******************************************************************************
3920ULONG Win32BaseWindow::GetWindowLongA(int index, BOOL fUnicode)
3921{
3922 ULONG value;
3923
3924 switch(index) {
3925 case GWL_EXSTYLE:
3926 value = dwExStyle;
3927 break;
3928 case GWL_STYLE:
3929 value = dwStyle;
3930 break;
3931 case GWL_WNDPROC:
3932 value = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
3933 break;
3934 case GWL_HINSTANCE:
3935 value = hInstance;
3936 break;
3937 case GWL_HWNDPARENT:
3938 if(getParent()) {
3939 value = getParent()->getWindowHandle();
3940 }
3941 else value = 0;
3942 break;
3943 case GWL_ID:
3944 value = getWindowId();
3945 break;
3946 case GWL_USERDATA:
3947 value = userData;
3948 break;
3949 default:
3950 if(index >= 0 && index/4 < nrUserWindowLong)
3951 {
3952 value = userWindowLong[index/4];
3953 break;
3954 }
3955 SetLastError(ERROR_INVALID_PARAMETER);
3956 return 0;
3957 }
3958 dprintf2(("GetWindowLongA %x %d %x", getWindowHandle(), index, value));
3959 return value;
3960}
3961//******************************************************************************
3962//******************************************************************************
3963WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
3964{
3965 WORD oldval;
3966
3967 if(index >= 0 && index/4 < nrUserWindowLong)
3968 {
3969 oldval = ((WORD *)userWindowLong)[index/2];
3970 ((WORD *)userWindowLong)[index/2] = value;
3971 return oldval;
3972 }
3973 SetLastError(ERROR_INVALID_PARAMETER);
3974 return 0;
3975}
3976//******************************************************************************
3977//******************************************************************************
3978WORD Win32BaseWindow::GetWindowWord(int index)
3979{
3980 if(index >= 0 && index/4 < nrUserWindowLong)
3981 {
3982 return ((WORD *)userWindowLong)[index/2];
3983 }
3984 SetLastError(ERROR_INVALID_PARAMETER);
3985 return 0;
3986}
3987//******************************************************************************
3988//******************************************************************************
3989void Win32BaseWindow::setWindowId(DWORD id)
3990{
3991 windowId = id;
3992 dprintf(("Set window ID to %x", id));
3993 OSLibSetWindowID(OS2HwndFrame, id);
3994}
3995//******************************************************************************
3996//******************************************************************************
3997Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
3998{
3999 Win32BaseWindow *window;
4000
4001 if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
4002 return window;
4003 }
4004// dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
4005 return NULL;
4006}
4007//******************************************************************************
4008//******************************************************************************
4009Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd)
4010{
4011 Win32BaseWindow *win32wnd;
4012 DWORD magic;
4013
4014 if(hwnd == OSLIB_HWND_DESKTOP)
4015 {
4016 return windowDesktop;
4017 }
4018
4019 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
4020 magic = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
4021
4022 if(win32wnd && CheckMagicDword(magic)) {
4023 return win32wnd;
4024 }
4025// dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwnd));
4026 return 0;
4027}
4028//******************************************************************************
4029//******************************************************************************
4030Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
4031{
4032 return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
4033}
4034//******************************************************************************
4035//******************************************************************************
4036HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd)
4037{
4038 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
4039
4040 if(window) {
4041 return window->getOS2WindowHandle();
4042 }
4043// dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
4044 return hwnd;
4045}
4046//******************************************************************************
4047//******************************************************************************
4048HWND Win32BaseWindow::Win32ToOS2FrameHandle(HWND hwnd)
4049{
4050 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
4051
4052 if(window) {
4053 return window->getOS2FrameWindowHandle();
4054 }
4055// dprintf2(("Win32BaseWindow::Win32ToOS2FrameHandle: not a win32 window %x", hwnd));
4056 return hwnd;
4057}
4058//******************************************************************************
4059//******************************************************************************
4060HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd)
4061{
4062 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
4063
4064 if(window) {
4065 return window->getWindowHandle();
4066 }
4067 window = GetWindowFromOS2FrameHandle(hwnd);
4068 if(window) {
4069 return window->getWindowHandle();
4070 }
4071// dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
4072 return 0;
4073// else return hwnd; //OS/2 window handle
4074}
4075//******************************************************************************
4076// GetNextDlgTabItem32 (USER32.276)
4077//******************************************************************************
4078HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
4079{
4080 Win32BaseWindow *child, *nextchild, *lastchild;
4081 HWND retvalue;
4082
4083 if (hwndCtrl)
4084 {
4085 child = GetWindowFromHandle(hwndCtrl);
4086 if (!child)
4087 {
4088 retvalue = 0;
4089 goto END;
4090 }
4091 /* Make sure hwndCtrl is a top-level child */
4092 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
4093 {
4094 child = child->getParent();
4095 if(child == NULL) break;
4096 }
4097
4098 if (!child || (child->getParent() != this))
4099 {
4100 retvalue = 0;
4101 goto END;
4102 }
4103 }
4104 else
4105 {
4106 /* No ctrl specified -> start from the beginning */
4107 child = (Win32BaseWindow *)getFirstChild();
4108 if (!child)
4109 {
4110 retvalue = 0;
4111 goto END;
4112 }
4113
4114 if (!fPrevious)
4115 {
4116 while (child->getNextChild())
4117 {
4118 child = (Win32BaseWindow *)child->getNextChild();
4119 }
4120 }
4121 }
4122
4123 lastchild = child;
4124 nextchild = (Win32BaseWindow *)child->getNextChild();
4125 while (TRUE)
4126 {
4127 if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild();
4128
4129 if (child == nextchild) break;
4130
4131 if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) &&
4132 !(nextchild->getStyle() & WS_DISABLED))
4133 {
4134 lastchild = nextchild;
4135 if (!fPrevious) break;
4136 }
4137 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
4138 }
4139 retvalue = lastchild->getWindowHandle();
4140
4141END:
4142 return retvalue;
4143}
4144//******************************************************************************
4145//******************************************************************************
4146HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
4147{
4148 Win32BaseWindow *child, *nextchild, *lastchild;
4149 HWND retvalue;
4150
4151 if (hwndCtrl)
4152 {
4153 child = GetWindowFromHandle(hwndCtrl);
4154 if (!child)
4155 {
4156 retvalue = 0;
4157 goto END;
4158 }
4159 /* Make sure hwndCtrl is a top-level child */
4160 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
4161 {
4162 child = child->getParent();
4163 if(child == NULL) break;
4164 }
4165
4166 if (!child || (child->getParent() != this))
4167 {
4168 retvalue = 0;
4169 goto END;
4170 }
4171 }
4172 else
4173 {
4174 /* No ctrl specified -> start from the beginning */
4175 child = (Win32BaseWindow *)getFirstChild();
4176 if (!child)
4177 {
4178 retvalue = 0;
4179 goto END;
4180 }
4181
4182 if (fPrevious)
4183 {
4184 while (child->getNextChild())
4185 {
4186 child = (Win32BaseWindow *)child->getNextChild();
4187 }
4188 }
4189 }
4190
4191 lastchild = child;
4192 nextchild = (Win32BaseWindow *)child->getNextChild();
4193 while (TRUE)
4194 {
4195 if (!nextchild || (nextchild->getStyle() & WS_GROUP))
4196 {
4197 /* Wrap-around to the beginning of the group */
4198 Win32BaseWindow *pWndTemp;
4199
4200 nextchild = (Win32BaseWindow *)getFirstChild();
4201
4202 for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild())
4203 {
4204 if (pWndTemp->getStyle() & WS_GROUP)
4205 nextchild = pWndTemp;
4206
4207 if (pWndTemp == child)
4208 break;
4209 }
4210
4211 }
4212 if (nextchild == child)
4213 break;
4214
4215 if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED))
4216 {
4217 lastchild = nextchild;
4218
4219 if (!fPrevious)
4220 break;
4221 }
4222
4223 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
4224 }
4225 retvalue = lastchild->getWindowHandle();
4226END:
4227 return retvalue;
4228}
4229//******************************************************************************
4230//******************************************************************************
4231#ifdef DEBUG
4232void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
4233{
4234 char style[256] = "";
4235 char exstyle[256] = "";
4236
4237 /* Window styles */
4238 if(dwStyle & WS_CHILD)
4239 strcat(style, "WS_CHILD ");
4240 if(dwStyle & WS_POPUP)
4241 strcat(style, "WS_POPUP ");
4242 if(dwStyle & WS_VISIBLE)
4243 strcat(style, "WS_VISIBLE ");
4244 if(dwStyle & WS_DISABLED)
4245 strcat(style, "WS_DISABLED ");
4246 if(dwStyle & WS_CLIPSIBLINGS)
4247 strcat(style, "WS_CLIPSIBLINGS ");
4248 if(dwStyle & WS_CLIPCHILDREN)
4249 strcat(style, "WS_CLIPCHILDREN ");
4250 if(dwStyle & WS_MAXIMIZE)
4251 strcat(style, "WS_MAXIMIZE ");
4252 if(dwStyle & WS_MINIMIZE)
4253 strcat(style, "WS_MINIMIZE ");
4254 if(dwStyle & WS_GROUP)
4255 strcat(style, "WS_GROUP ");
4256 if(dwStyle & WS_TABSTOP)
4257 strcat(style, "WS_TABSTOP ");
4258
4259 if((dwStyle & WS_CAPTION) == WS_CAPTION)
4260 strcat(style, "WS_CAPTION ");
4261 if(dwStyle & WS_DLGFRAME)
4262 strcat(style, "WS_DLGFRAME ");
4263 if(dwStyle & WS_BORDER)
4264 strcat(style, "WS_BORDER ");
4265
4266 if(dwStyle & WS_VSCROLL)
4267 strcat(style, "WS_VSCROLL ");
4268 if(dwStyle & WS_HSCROLL)
4269 strcat(style, "WS_HSCROLL ");
4270 if(dwStyle & WS_SYSMENU)
4271 strcat(style, "WS_SYSMENU ");
4272 if(dwStyle & WS_THICKFRAME)
4273 strcat(style, "WS_THICKFRAME ");
4274 if(dwStyle & WS_MINIMIZEBOX)
4275 strcat(style, "WS_MINIMIZEBOX ");
4276 if(dwStyle & WS_MAXIMIZEBOX)
4277 strcat(style, "WS_MAXIMIZEBOX ");
4278
4279 if(dwExStyle & WS_EX_DLGMODALFRAME)
4280 strcat(exstyle, "WS_EX_DLGMODALFRAME ");
4281 if(dwExStyle & WS_EX_ACCEPTFILES)
4282 strcat(exstyle, "WS_EX_ACCEPTFILES ");
4283 if(dwExStyle & WS_EX_NOPARENTNOTIFY)
4284 strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
4285 if(dwExStyle & WS_EX_TOPMOST)
4286 strcat(exstyle, "WS_EX_TOPMOST ");
4287 if(dwExStyle & WS_EX_TRANSPARENT)
4288 strcat(exstyle, "WS_EX_TRANSPARENT ");
4289
4290 if(dwExStyle & WS_EX_MDICHILD)
4291 strcat(exstyle, "WS_EX_MDICHILD ");
4292 if(dwExStyle & WS_EX_TOOLWINDOW)
4293 strcat(exstyle, "WS_EX_TOOLWINDOW ");
4294 if(dwExStyle & WS_EX_WINDOWEDGE)
4295 strcat(exstyle, "WS_EX_WINDOWEDGE ");
4296 if(dwExStyle & WS_EX_CLIENTEDGE)
4297 strcat(exstyle, "WS_EX_CLIENTEDGE ");
4298 if(dwExStyle & WS_EX_CONTEXTHELP)
4299 strcat(exstyle, "WS_EX_CONTEXTHELP ");
4300 if(dwExStyle & WS_EX_RIGHT)
4301 strcat(exstyle, "WS_EX_RIGHT ");
4302 if(dwExStyle & WS_EX_LEFT)
4303 strcat(exstyle, "WS_EX_LEFT ");
4304 if(dwExStyle & WS_EX_RTLREADING)
4305 strcat(exstyle, "WS_EX_RTLREADING ");
4306 if(dwExStyle & WS_EX_LTRREADING)
4307 strcat(exstyle, "WS_EX_LTRREADING ");
4308 if(dwExStyle & WS_EX_LEFTSCROLLBAR)
4309 strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
4310 if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
4311 strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
4312 if(dwExStyle & WS_EX_CONTROLPARENT)
4313 strcat(exstyle, "WS_EX_CONTROLPARENT ");
4314 if(dwExStyle & WS_EX_STATICEDGE)
4315 strcat(exstyle, "WS_EX_STATICEDGE ");
4316 if(dwExStyle & WS_EX_APPWINDOW)
4317 strcat(exstyle, "WS_EX_APPWINDOW ");
4318
4319 dprintf(("Window style: %x %s", dwStyle, style));
4320 dprintf(("Window exStyle: %x %s (FS = %x)", dwExStyle, exstyle, GetFS()));
4321}
4322#endif
4323//******************************************************************************
4324//******************************************************************************
4325
4326GenericObject *Win32BaseWindow::windows = NULL;
Note: See TracBrowser for help on using the repository browser.