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

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

single frame works now

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