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

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

ported all USER32 bitmaps, several bug fixes

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