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

Last change on this file since 2294 was 2294, checked in by sandervl, 26 years ago

Implemented Set/GetWindowRgn (not activated)

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