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

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

LoadBitmap fix; split up win32wbase.cpp

File size: 104.6 KB
Line 
1/* $Id: win32wbase.cpp,v 1.31 2000-01-11 10:38:34 sandervl Exp $ */
2/*
3 * Win32 Window Base Class for OS/2
4 *
5 * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
6 * Copyright 1999 Daniela Engert (dani@ngrt.de)
7 * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)
8 *
9 * Parts based on Wine Windows code (windows\win.c)
10 *
11 * Copyright 1993, 1994, 1996 Alexandre Julliard
12 * 1995 Alex Korobka
13 *
14 * TODO: Not thread/process safe
15 *
16 * Project Odin Software License can be found in LICENSE.TXT
17 *
18 */
19#include <os2win.h>
20#include <win.h>
21#include <stdlib.h>
22#include <string.h>
23#include <stdarg.h>
24#include <assert.h>
25#include <misc.h>
26#include <heapstring.h>
27#include <win32wbase.h>
28#include <winres.h>
29#include "wndmsg.h"
30#include "oslibwin.h"
31#include "oslibmsg.h"
32#include "oslibutil.h"
33#include "oslibgdi.h"
34#include "oslibres.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#include <menu.h>
47#define INCL_TIMERWIN32
48#include "timer.h"
49
50#define SC_ABOUTWINE (SC_SCREENSAVE+1)
51#define SC_PUTMARK (SC_SCREENSAVE+2)
52
53#define HAS_DLGFRAME(style,exStyle) \
54 (((exStyle) & WS_EX_DLGMODALFRAME) || \
55 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
56
57#define HAS_THICKFRAME(style,exStyle) \
58 (((style) & WS_THICKFRAME) && \
59 !((exStyle) & WS_EX_DLGMODALFRAME) && \
60 !((style) & WS_CHILD))
61
62#define HAS_THINFRAME(style) \
63 (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
64
65#define HAS_BIGFRAME(style,exStyle) \
66 (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
67 ((exStyle) & WS_EX_DLGMODALFRAME))
68
69#define HAS_ANYFRAME(style,exStyle) \
70 (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
71 ((exStyle) & WS_EX_DLGMODALFRAME) || \
72 !((style) & (WS_CHILD | WS_POPUP)))
73
74#define HAS_3DFRAME(exStyle) \
75 ((exStyle & WS_EX_CLIENTEDGE) || (exStyle & WS_EX_STATICEDGE) || (exStyle & WS_EX_WINDOWEDGE))
76
77#define HAS_BORDER(style, exStyle) \
78 ((style & WS_BORDER) || HAS_THICKFRAME(style) || HAS_DLGFRAME(style,exStyle))
79
80#define IS_OVERLAPPED(style) \
81 !(style & (WS_CHILD | WS_POPUP))
82
83#define HAS_MENU() (!(getStyle() & WS_CHILD) && (GetMenu() != 0))
84
85/* bits in the dwKeyData */
86#define KEYDATA_ALT 0x2000
87#define KEYDATA_PREVSTATE 0x4000
88
89void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle);
90
91static fDestroyAll = FALSE;
92//For quick lookup of current process id
93static ULONG currentProcessId = -1;
94
95//******************************************************************************
96//******************************************************************************
97Win32BaseWindow::Win32BaseWindow(DWORD objType) : GenericObject(&windows, objType)
98{
99 Init();
100}
101//******************************************************************************
102//******************************************************************************
103Win32BaseWindow::Win32BaseWindow(HWND os2Handle,VOID* win32WndProc) : GenericObject(&windows,OBJTYPE_WINDOW)
104{
105 Init();
106 OS2Hwnd = OS2HwndFrame = os2Handle;
107 dwStyle = WS_VISIBLE;
108 setWindowProc((WNDPROC)win32WndProc);
109 fIsSubclassedOS2Wnd = TRUE;
110 fFirstShow = FALSE;
111 fCreated = TRUE;
112
113 SetLastError(0);
114
115 //CB: replace by a secure method
116
117 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
118 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
119 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
120 return;
121 }
122 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
123 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
124 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
125 return;
126 }
127
128 OSLibWinQueryWindowRect(OS2Hwnd,&rectClient,RELATIVE_TO_WINDOW);
129 OSLibWinQueryWindowRect(OS2Hwnd,&rectWindow,RELATIVE_TO_SCREEN);
130
131 setOldWndProc(SubclassWithDefHandler(OS2Hwnd));
132}
133//******************************************************************************
134//******************************************************************************
135Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
136 : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
137{
138 Init();
139 this->isUnicode = isUnicode;
140 CreateWindowExA(lpCreateStructA, classAtom);
141}
142//******************************************************************************
143//******************************************************************************
144void Win32BaseWindow::Init()
145{
146 isUnicode = FALSE;
147 fIsSubclassedOS2Wnd = FALSE;
148 fFirstShow = TRUE;
149 fIsDialog = FALSE;
150 fIsModalDialogOwner = FALSE;
151 OS2HwndModalDialog = 0;
152 fInternalMsg = FALSE;
153 fNoSizeMsg = FALSE;
154 fIsDestroyed = FALSE;
155 fDestroyWindowCalled = FALSE;
156 fCreated = FALSE;
157 fTaskList = FALSE;
158 fParentDC = FALSE;
159
160 windowNameA = NULL;
161 windowNameW = NULL;
162 wndNameLength = 0;
163
164 userWindowLong = NULL;;
165 nrUserWindowLong = 0;
166
167 magic = WIN32PM_MAGIC;
168 OS2Hwnd = 0;
169 OS2HwndFrame = 0;
170 hMenu = 0;
171 hSysMenu = 0;
172 Win32Hwnd = 0;
173
174 if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE)
175 {
176 dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
177 DebugInt3();
178 }
179
180 posx = posy = 0;
181 width = height = 0;
182
183 dwExStyle = 0;
184 dwStyle = 0;
185 win32wndproc = 0;
186 hInstance = 0;
187 windowId = 0xFFFFFFFF; //default = -1
188 userData = 0;
189 contextHelpId = 0;
190
191 pOldFrameProc = NULL;
192 borderWidth = 0;
193 borderHeight = 0;
194
195 hwndLinkAfter = HWND_BOTTOM;
196 flags = 0;
197 isIcon = FALSE;
198 lastHitTestVal = HTOS_NORMAL;
199 owner = NULL;
200 windowClass = 0;
201
202 iconResource = NULL;
203
204 EraseBkgndFlag = TRUE;
205 PSEraseFlag = FALSE;
206 SuppressEraseFlag = FALSE;
207
208 horzScrollInfo = NULL;
209 vertScrollInfo = NULL;
210
211 ownDC = 0;
212 hWindowRegion = 0;
213
214 if(currentProcessId == -1)
215 {
216 currentProcessId = GetCurrentProcessId();
217 }
218 dwThreadId = GetCurrentThreadId();
219 dwProcessId = currentProcessId;
220}
221//******************************************************************************
222//todo get rid of resources (menu, icon etc)
223//******************************************************************************
224Win32BaseWindow::~Win32BaseWindow()
225{
226 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
227 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
228
229 if(!fDestroyAll && getParent() && getParent()->getFirstChild() == this && getNextChild() == NULL)
230 {
231 //if we're the last child that's being destroyed and our
232 //parent window was also destroyed, then we delete the parent object
233 if(getParent()->IsWindowDestroyed())
234 {
235 dprintf(("Last Child (%x) destroyed, get rid of our parent window (%x)", getWindowHandle(), getParent()->getWindowHandle()));
236 delete getParent();
237 setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
238 }
239 }
240 else
241 if(fDestroyAll) {
242 dprintf(("Destroying window %x %s", getWindowHandle(), windowNameA));
243 setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
244 }
245
246 if (isOwnDC())
247 releaseOwnDC (ownDC);
248
249 if(Win32Hwnd)
250 HwFreeWindowHandle(Win32Hwnd);
251
252 if(userWindowLong)
253 free(userWindowLong);
254 if(windowNameA) {
255 free(windowNameA);
256 windowNameA = NULL;
257 }
258 if(windowNameW) {
259 free(windowNameW);
260 windowNameW = NULL;
261 }
262 if(vertScrollInfo) {
263 free(vertScrollInfo);
264 vertScrollInfo = NULL;
265 }
266 if(horzScrollInfo) {
267 free(horzScrollInfo);
268 horzScrollInfo = NULL;
269 }
270}
271//******************************************************************************
272//******************************************************************************
273void Win32BaseWindow::DestroyAll()
274{
275 fDestroyAll = TRUE;
276 GenericObject::DestroyAll(windows);
277}
278//******************************************************************************
279//******************************************************************************
280BOOL Win32BaseWindow::isChild()
281{
282 return ((dwStyle & WS_CHILD) != 0);
283}
284//******************************************************************************
285//******************************************************************************
286BOOL Win32BaseWindow::IsWindowUnicode()
287{
288 dprintf2(("IsWindowUnicode %x %d", getWindowHandle(), WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W));
289 return (WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W);
290}
291//******************************************************************************
292//******************************************************************************
293BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom)
294{
295 char buffer[256];
296 POINT maxSize, maxPos, minTrack, maxTrack;
297
298#ifdef DEBUG
299 PrintWindowStyle(cs->style, cs->dwExStyle);
300#endif
301
302 sw = SW_SHOW;
303 SetLastError(0);
304
305 /* Find the parent window */
306 if (cs->hwndParent)
307 {
308 Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
309 if(!window) {
310 dprintf(("Bad parent %04x\n", cs->hwndParent ));
311 SetLastError(ERROR_INVALID_PARAMETER);
312 return FALSE;
313 }
314 /* Make sure parent is valid */
315 if (!window->IsWindow() )
316 {
317 dprintf(("Bad parent %04x\n", cs->hwndParent ));
318 SetLastError(ERROR_INVALID_PARAMETER);
319 return FALSE;
320 }
321 }
322 else
323 if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
324 dprintf(("No parent for child window\n" ));
325 SetLastError(ERROR_INVALID_PARAMETER);
326 return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
327 }
328
329 /* Find the window class */
330 windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
331 if (!windowClass)
332 {
333 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
334 dprintf(("Bad class '%s'\n", buffer ));
335 SetLastError(ERROR_INVALID_PARAMETER);
336 return 0;
337 }
338#ifdef DEBUG
339 if(HIWORD(cs->lpszClass))
340 {
341 char *astring;
342
343 if(isUnicode) astring = UnicodeToAsciiString((LPWSTR)cs->lpszClass);
344 else astring = (char *)cs->lpszClass;
345
346 dprintf(("Window class %s", astring));
347 if(isUnicode) FreeAsciiString(astring);
348 }
349 else dprintf(("Window class %x", cs->lpszClass));
350#endif
351
352 /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
353 * with an atom as the class name, put some programs expect to have a *REAL* string in
354 * lpszClass when the CREATESTRUCT is sent with WM_CREATE
355 */
356 if (!HIWORD(cs->lpszClass) ) {
357 if (isUnicode) {
358 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
359 }
360 else {
361 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
362 }
363 cs->lpszClass = buffer;
364 }
365
366 /* Fix the coordinates */
367 if ((cs->x == CW_USEDEFAULT) || (cs->x == CW_USEDEFAULT16))
368 {
369// PDB *pdb = PROCESS_Current();
370
371 /* Never believe Microsoft's documentation... CreateWindowEx doc says
372 * that if an overlapped window is created with WS_VISIBLE style bit
373 * set and the x parameter is set to CW_USEDEFAULT, the system ignores
374 * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
375 * reveals that
376 *
377 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
378 * 2) it does not ignore the y parameter as the docs claim; instead, it
379 * uses it as second parameter to ShowWindow() unless y is either
380 * CW_USEDEFAULT or CW_USEDEFAULT16.
381 *
382 * The fact that we didn't do 2) caused bogus windows pop up when wine
383 * was running apps that were using this obscure feature. Example -
384 * calc.exe that comes with Win98 (only Win98, it's different from
385 * the one that comes with Win95 and NT)
386 */
387 if ((cs->y != CW_USEDEFAULT) && (cs->y != CW_USEDEFAULT16)) sw = cs->y;
388
389 /* We have saved cs->y, now we can trash it */
390#if 0
391 if ( !(cs->style & (WS_CHILD | WS_POPUP))
392 && (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
393 {
394 cs->x = pdb->env_db->startup_info->dwX;
395 cs->y = pdb->env_db->startup_info->dwY;
396 }
397#endif
398 cs->x = 0;
399 cs->y = 0;
400// }
401 }
402 if ((cs->cx == CW_USEDEFAULT) || (cs->cx == CW_USEDEFAULT16))
403 {
404#if 0
405 PDB *pdb = PROCESS_Current();
406 if ( !(cs->style & (WS_CHILD | WS_POPUP))
407 && (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )
408 {
409 cs->cx = pdb->env_db->startup_info->dwXSize;
410 cs->cy = pdb->env_db->startup_info->dwYSize;
411 }
412 else
413 {
414#endif
415 cs->cx = 600; /* FIXME */
416 cs->cy = 400;
417// }
418 }
419
420 if (cs->x < 0) cs->x = 0;
421 if (cs->y < 0) cs->y = 0;
422
423 //Allocate window words
424 nrUserWindowLong = windowClass->getExtraWndWords();
425 if(nrUserWindowLong) {
426 userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
427 memset(userWindowLong, 0, nrUserWindowLong);
428 }
429
430 if ((cs->style & WS_CHILD) && cs->hwndParent)
431 {
432 SetParent(cs->hwndParent);
433 owner = GetWindowFromHandle(cs->hwndParent);
434 if(owner == NULL)
435 {
436 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
437 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
438 return FALSE;
439 }
440 }
441 else
442 {
443 SetParent(0);
444 if (!cs->hwndParent || (cs->hwndParent == windowDesktop->getWindowHandle())) {
445 owner = NULL;
446 }
447 else
448 {
449 owner = GetWindowFromHandle(cs->hwndParent)->GetTopParent();
450 if(owner == NULL)
451 {
452 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
453 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
454 return FALSE;
455 }
456 }
457 }
458
459 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc(), WINPROC_GetProcType(windowClass->getWindowProc()), WIN_PROC_WINDOW);
460 hInstance = cs->hInstance;
461 dwStyle = cs->style & ~WS_VISIBLE;
462 dwExStyle = cs->dwExStyle;
463
464 hwndLinkAfter = HWND_TOP;
465 if(CONTROLS_IsControl(this, BUTTON_CONTROL) && ((dwStyle & 0x0f) == BS_GROUPBOX))
466 {
467 hwndLinkAfter = HWND_BOTTOM;
468 dwStyle |= WS_CLIPSIBLINGS;
469 }
470 else
471 if(CONTROLS_IsControl(this, STATIC_CONTROL) && !(dwStyle & WS_GROUP)) {
472 dwStyle |= WS_CLIPSIBLINGS;
473 }
474
475 /* Increment class window counter */
476 windowClass->IncreaseWindowCount();
477
478 if (HOOK_IsHooked( WH_CBT ))
479 {
480 CBT_CREATEWNDA cbtc;
481 LRESULT ret;
482
483 cbtc.lpcs = cs;
484 cbtc.hwndInsertAfter = hwndLinkAfter;
485 ret = HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc);
486 if(ret)
487 {
488 dprintf(("CBT-hook returned 0!!"));
489 SetLastError(ERROR_CAN_NOT_COMPLETE); //todo: wrong error
490 return FALSE;
491 }
492 }
493
494 /* Correct the window style */
495 if (!(cs->style & WS_CHILD))
496 {
497 dwStyle |= WS_CLIPSIBLINGS;
498 if (!(cs->style & WS_POPUP))
499 {
500 dwStyle |= WS_CAPTION;
501 flags |= WIN_NEED_SIZE;
502 }
503 }
504 if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
505
506 if (cs->style & WS_HSCROLL)
507 {
508 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
509 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
510 horzScrollInfo->MaxVal = 100;
511 horzScrollInfo->flags = ESB_ENABLE_BOTH;
512 }
513
514 if (cs->style & WS_VSCROLL)
515 {
516 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
517 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
518 vertScrollInfo->MaxVal = 100;
519 vertScrollInfo->flags = ESB_ENABLE_BOTH;
520 }
521
522 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
523 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
524 {
525 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
526 if (maxSize.x < cs->cx) cs->cx = maxSize.x;
527 if (maxSize.y < cs->cy) cs->cy = maxSize.y;
528 if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
529 if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
530 }
531
532 if(cs->style & WS_CHILD)
533 {
534 if(cs->cx < 0) cs->cx = 0;
535 if(cs->cy < 0) cs->cy = 0;
536 }
537 else
538 {
539 if (cs->cx <= 0) cs->cx = 1;
540 if (cs->cy <= 0) cs->cy = 1;
541 }
542
543 if(((dwStyle & 0xC0000000) == WS_OVERLAPPED) && ((dwStyle & WS_CAPTION) == WS_CAPTION) && owner == NULL
544 && dwStyle & WS_SYSMENU)
545 {
546 fTaskList = TRUE;
547 }
548
549 DWORD dwOSWinStyle, dwOSFrameStyle;
550
551 OSLibWinConvertStyle(dwStyle, &dwExStyle, &dwOSWinStyle, &dwOSFrameStyle, &borderWidth, &borderHeight);
552
553 if(HIWORD(cs->lpszName))
554 {
555 if (!isUnicode)
556 {
557 wndNameLength = strlen(cs->lpszName);
558 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
559 strcpy(windowNameA,cs->lpszName);
560 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
561 lstrcpyAtoW(windowNameW,windowNameA);
562 windowNameA[wndNameLength] = 0;
563 windowNameW[wndNameLength] = 0;
564 }
565 else
566 {
567 wndNameLength = lstrlenW((LPWSTR)cs->lpszName);
568 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
569 lstrcpyWtoA(windowNameA,(LPWSTR)cs->lpszName);
570 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
571 lstrcpyW(windowNameW,(LPWSTR)cs->lpszName);
572 windowNameA[wndNameLength] = 0;
573 windowNameW[wndNameLength] = 0;
574 }
575 }
576
577 //copy pointer of CREATESTRUCT for usage in MsgCreate method
578 tmpcs = cs;
579
580 //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it
581 THDB *thdb = GetThreadTHDB();
582
583 if(thdb == NULL) {
584 dprintf(("Window creation failed - thdb == NULL")); //this is VERY bad
585 ExitProcess(666);
586 return FALSE;
587 }
588
589 thdb->newWindow = (ULONG)this;
590
591 OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
592 dwOSWinStyle,(char *)windowNameA,
593 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
594 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
595 &OS2HwndFrame, 0, fTaskList);
596 if(OS2Hwnd == 0) {
597 dprintf(("Window creation failed!!"));
598 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
599 return FALSE;
600 }
601
602 SetLastError(0);
603 return TRUE;
604}
605//******************************************************************************
606//******************************************************************************
607BOOL Win32BaseWindow::MsgCreate(HWND hwndFrame, HWND hwndClient)
608{
609 POINT maxPos;
610 CREATESTRUCTA *cs = tmpcs; //pointer to CREATESTRUCT used in CreateWindowExA method
611
612 OS2Hwnd = hwndClient;
613 OS2HwndFrame = hwndFrame;
614
615 fNoSizeMsg = TRUE;
616
617 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
618 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
619 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
620 return FALSE;
621 }
622 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
623 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
624 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
625 return FALSE;
626 }
627
628 OSLibWinSetOwner(OS2Hwnd, OS2HwndFrame);
629
630 fakeWinBase.hwndThis = OS2Hwnd;
631 fakeWinBase.pWindowClass = windowClass;
632
633 //Set icon from class
634 if(windowClass->getIcon())
635 SetIcon(windowClass->getIcon());
636 /* Get class or window DC if needed */
637 if(windowClass->getStyle() & CS_OWNDC) {
638 dprintf(("Class with CS_OWNDC style"));
639// ownDC = GetWindowDC(getWindowHandle());
640 }
641 else
642 if (windowClass->getStyle() & CS_PARENTDC) {
643 dprintf(("WARNING: Class with CS_PARENTDC style!"));
644 fParentDC = TRUE;
645 ownDC = 0;
646 }
647 else
648 if (windowClass->getStyle() & CS_CLASSDC) {
649 dprintf(("WARNING: Class with CS_CLASSDC style!"));
650 ownDC = 0;
651 }
652 /* Set the window menu */
653 if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
654 {
655 if (cs->hMenu) {
656 SetMenu(cs->hMenu);
657 }
658 else {
659 if (windowClass->getMenuNameA()) {
660 cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
661 if (cs->hMenu) SetMenu(cs->hMenu );
662 }
663 }
664 }
665 else
666 {
667 setWindowId((DWORD)cs->hMenu);
668 }
669 hSysMenu = (dwStyle & WS_SYSMENU) ? MENU_GetSysMenu(Win32Hwnd,0):0;
670
671 // Subclass frame
672 pOldFrameProc = FrameSubclassFrameWindow(this);
673 //if (isChild()) FrameSetBorderSize(this,TRUE);
674
675 //preset rects
676 rectWindow.left = cs->x;
677 rectWindow.right = cs->x+cs->cx;
678 rectWindow.top = cs->y;
679 rectWindow.bottom = cs->y+cs->cy;
680 rectClient = rectWindow; //dummy client rect
681 if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow);
682 /* Send the WM_CREATE message
683 * Perhaps we shouldn't allow width/height changes as well.
684 * See p327 in "Internals".
685 */
686 maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
687
688 //Note: Solitaire crashes when receiving WM_SIZE messages before WM_CREATE
689 //fNoSizeMsg = FALSE;
690 fCreated = TRUE;
691
692 if (SendInternalMessageA(WM_NCCREATE,0,(LPARAM)cs))
693 {
694 //update rect
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 if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow);
700 OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
701 rectClient = rectWindow;
702 if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rectClient);
703 //set the window size and update the client
704 SetWindowPos(hwndLinkAfter,rectClient.left,rectClient.top,rectClient.right-rectClient.left,rectClient.bottom-rectClient.top,SWP_NOACTIVATE | SWP_NOREDRAW | SWP_FRAMECHANGED);
705 fNoSizeMsg = FALSE;
706 if (cs->style & WS_VISIBLE) dwStyle |= WS_VISIBLE; //program could change position in WM_CREATE
707 if( (SendInternalMessageA(WM_CREATE, 0, (LPARAM)cs )) != -1 )
708 {
709 if(!(flags & WIN_NEED_SIZE)) {
710 SendInternalMessageA(WM_SIZE, SIZE_RESTORED,
711 MAKELONG(rectClient.right-rectClient.left,
712 rectClient.bottom-rectClient.top));
713 SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
714 }
715
716 if( (getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
717 {
718 /* Notify the parent window only */
719 SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle());
720 if(!::IsWindow(getWindowHandle()))
721 {
722 dprintf(("Createwindow: WM_PARENTNOTIFY destroyed window"));
723 goto end;
724 }
725 }
726
727 if (cs->style & WS_VISIBLE) ShowWindow(sw);
728
729 /* Call WH_SHELL hook */
730 if (!(getStyle() & WS_CHILD) && !owner)
731 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWCREATED, getWindowHandle(), 0 );
732
733 SetLastError(0);
734 return TRUE;
735 }
736 }
737 dprintf(("Window creation FAILED (NCCREATE cancelled creation)"));
738 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
739end:
740 return FALSE;
741}
742//******************************************************************************
743//******************************************************************************
744ULONG Win32BaseWindow::MsgQuit()
745{
746 return SendInternalMessageA(WM_QUIT, 0, 0);
747}
748//******************************************************************************
749//******************************************************************************
750ULONG Win32BaseWindow::MsgClose()
751{
752 return SendInternalMessageA(WM_CLOSE,0,0);
753}
754//******************************************************************************
755//******************************************************************************
756ULONG Win32BaseWindow::MsgDestroy()
757{
758 ULONG rc;
759 Win32BaseWindow *child;
760 HWND hwnd = getWindowHandle();
761
762 if (isSubclassedOS2Wnd) OSLibWinSubclassWindow(OS2Hwnd,pOldWndProc);
763
764 fIsDestroyed = TRUE;
765
766 if(fDestroyWindowCalled == FALSE)
767 {//this window was destroyed because DestroyWindow was called for it's parent
768 //so: send a WM_PARENTNOTIFY now as that hasn't happened yet
769 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
770 {
771 if(getParent())
772 {
773 /* Notify the parent window only */
774 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
775 }
776 else DebugInt3();
777 }
778 }
779 SendInternalMessageA(WM_DESTROY, 0, 0);
780 if(::IsWindow(hwnd) == FALSE) {
781 //object already destroyed, so return immediately
782 return 1;
783 }
784 SendInternalMessageA(WM_NCDESTROY, 0, 0);
785
786 TIMER_KillTimerFromWindow(OS2Hwnd);
787
788 if(getFirstChild() == NULL) {
789 delete this;
790 }
791 return 1;
792}
793//******************************************************************************
794//******************************************************************************
795ULONG Win32BaseWindow::MsgEnable(BOOL fEnable)
796{
797 if(fEnable) {
798 dwStyle &= ~WS_DISABLED;
799 }
800 else dwStyle |= WS_DISABLED;
801
802 return SendInternalMessageA(WM_ENABLE, fEnable, 0);
803}
804//******************************************************************************
805//TODO: SW_PARENTCLOSING/OPENING flag (lParam)
806//******************************************************************************
807ULONG Win32BaseWindow::MsgShow(BOOL fShow)
808{
809 if(fNoSizeMsg) {
810 return 1;
811 }
812
813 if(fShow) {
814 setStyle(getStyle() | WS_VISIBLE);
815 }
816 else setStyle(getStyle() & ~WS_VISIBLE);
817
818 return SendInternalMessageA(WM_SHOWWINDOW, fShow, 0);
819}
820//******************************************************************************
821//******************************************************************************
822ULONG Win32BaseWindow::MsgPosChanging(LPARAM lp)
823{
824 //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
825 // a WM_WINDOWPOSCHANGED msg -> crash)
826 if(fNoSizeMsg || fDestroyWindowCalled)
827 return 1;
828
829 return SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, lp);
830}
831//******************************************************************************
832//******************************************************************************
833ULONG Win32BaseWindow::MsgPosChanged(LPARAM lp)
834{
835 //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
836 // a WM_WINDOWPOSCHANGED msg -> crash)
837 if(fNoSizeMsg || fDestroyWindowCalled)
838 return 1;
839
840 return SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, lp);
841}
842//******************************************************************************
843//******************************************************************************
844#if 0
845ULONG Win32BaseWindow::MsgMinMax()
846{
847
848}
849#endif
850//******************************************************************************
851//******************************************************************************
852ULONG Win32BaseWindow::MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos)
853{
854 //According to the SDK docs, the scrollbar handle (lParam) is 0 when the standard
855 //window scrollbars send these messages
856 return SendInternalMessageA(msg, MAKELONG(scrollCode, scrollPos), 0);
857}
858//******************************************************************************
859//******************************************************************************
860ULONG Win32BaseWindow::MsgHitTest(ULONG x, ULONG y)
861{
862 lastHitTestVal = SendInternalMessageA(WM_NCHITTEST, 0, MAKELONG((USHORT)x, (USHORT)y));
863 dprintf2(("MsgHitTest (%d,%d) (%d,%d) (%d,%d) returned %x", x, y, rectWindow.left, rectWindow.right, rectWindow.top, rectWindow.bottom, lastHitTestVal));
864 return lastHitTestVal;
865}
866//******************************************************************************
867//******************************************************************************
868ULONG Win32BaseWindow::MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd)
869{
870 ULONG rc, curprocid, procidhwnd = -1, threadidhwnd = 0;
871
872
873 //According to SDK docs, if app returns FALSE & window is being deactivated,
874 //default processing is cancelled
875 //TODO: According to Wine we should proceed anyway if window is sysmodal
876 if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
877 {
878 return 0;
879 }
880 rc = SendInternalMessageA(WM_ACTIVATE, MAKELONG((fActivate) ? WA_ACTIVE : WA_INACTIVE, fMinimized), hwnd);
881
882 curprocid = GetCurrentProcessId();
883 if(hwnd) {
884 threadidhwnd = GetWindowThreadProcessId(hwnd, &procidhwnd);
885 }
886
887 if(curprocid != procidhwnd && fActivate) {
888 SendInternalMessageA(WM_ACTIVATEAPP, 1, threadidhwnd);
889 }
890 return rc;
891}
892//******************************************************************************
893//TODO: Is this correct and complete?
894//Add print screen, break & numlock
895//******************************************************************************
896void Win32BaseWindow::setExtendedKey(ULONG virtualkey, ULONG *lParam)
897{
898 switch(virtualkey) {
899 case VK_DOWN:
900 case VK_UP:
901 case VK_PRIOR:
902 case VK_NEXT:
903 case VK_END:
904 case VK_DIVIDE:
905 case VK_DELETE:
906 case VK_EXECUTE: //Numeric enter key?
907 case VK_HOME:
908 case VK_INSERT:
909 case VK_RCONTROL:
910 case VK_RMENU: //is this the right alt???
911 *lParam = *lParam | (1<<24);
912 }
913}
914//******************************************************************************
915//******************************************************************************
916ULONG Win32BaseWindow::DispatchMsgA(MSG *msg)
917{
918 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
919}
920//******************************************************************************
921//******************************************************************************
922ULONG Win32BaseWindow::DispatchMsgW(MSG *msg)
923{
924 return SendInternalMessageW(msg->message, msg->wParam, msg->lParam);
925}
926//******************************************************************************
927//******************************************************************************
928ULONG Win32BaseWindow::MsgSetFocus(HWND hwnd)
929{
930 return SendInternalMessageA(WM_SETFOCUS, hwnd, 0);
931}
932//******************************************************************************
933//******************************************************************************
934ULONG Win32BaseWindow::MsgKillFocus(HWND hwnd)
935{
936 return SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
937}
938//******************************************************************************
939//******************************************************************************
940ULONG Win32BaseWindow::MsgButton(MSG *msg)
941{
942 BOOL fClick = FALSE;
943
944// dprintf(("MsgButton at (%d,%d)", msg->pt.x, msg->pt.y));
945 switch(msg->message) {
946 case WM_LBUTTONDBLCLK:
947 case WM_RBUTTONDBLCLK:
948 case WM_MBUTTONDBLCLK:
949 case WM_NCLBUTTONDBLCLK:
950 case WM_NCRBUTTONDBLCLK:
951 case WM_NCMBUTTONDBLCLK:
952 if (!(windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS) && (msg->message != WM_NCLBUTTONDBLCLK))
953 {
954 msg->message = msg->message - (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); //dblclick -> down
955 MsgButton(msg);
956 msg->message++; //button-up
957 return MsgButton(msg);
958 }
959 break;
960 case WM_LBUTTONDOWN:
961 case WM_RBUTTONDOWN:
962 case WM_MBUTTONDOWN:
963 case WM_NCLBUTTONDOWN:
964 case WM_NCRBUTTONDOWN:
965 case WM_NCMBUTTONDOWN:
966 fClick = TRUE;
967 break;
968 }
969
970 if(ISMOUSE_CAPTURED())
971 {
972 if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_BUTTON, msg->pt.x, msg->pt.y))
973 return 0;
974 }
975
976 if(fClick)
977 {
978 HWND hwndTop;
979
980 /* Activate the window if needed */
981 if(isSubclassedOS2Wnd()) {
982 Win32BaseWindow *parentwnd = GetWindowFromOS2FrameHandle(OSLibWinQueryWindow(OS2Hwnd, QWOS_PARENT));
983 if(parentwnd) {
984 hwndTop = (parentwnd->GetTopParent()) ? parentwnd->GetTopParent()->getWindowHandle() : 0;
985 }
986 else hwndTop = 0;
987 }
988 else hwndTop = (GetTopParent()) ? GetTopParent()->getWindowHandle() : 0;
989
990 HWND hwndActive = GetActiveWindow();
991 if (hwndTop && (getWindowHandle() != hwndActive))
992 {
993 LONG ret = SendInternalMessageA(WM_MOUSEACTIVATE, hwndTop,
994 MAKELONG( lastHitTestVal, msg->message) );
995
996#if 0
997 if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
998 eatMsg = TRUE;
999#endif
1000 if(((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT))
1001 && hwndTop != GetForegroundWindow() )
1002 {
1003 ::SetActiveWindow(hwndTop);
1004 }
1005 }
1006 }
1007
1008 SendInternalMessageA(WM_SETCURSOR, getWindowHandle(), MAKELONG(lastHitTestVal, msg->message));
1009
1010 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
1011}
1012//******************************************************************************
1013//******************************************************************************
1014ULONG Win32BaseWindow::MsgPaint(ULONG tmp1, BOOL select)
1015{
1016 if (select && isIcon)
1017 return SendInternalMessageA(WM_PAINTICON, 0, 0);
1018 else
1019 return SendInternalMessageA(WM_PAINT, 0, 0);
1020}
1021//******************************************************************************
1022//TODO: Is the clipper region of the window DC equal to the invalidated rectangle?
1023// (or are we simply erasing too much here)
1024//******************************************************************************
1025ULONG Win32BaseWindow::MsgEraseBackGround(HDC hdc)
1026{
1027 ULONG rc;
1028 HDC hdcErase = hdc;
1029
1030 if (hdcErase == 0)
1031 hdcErase = O32_GetDC(OS2Hwnd);
1032
1033 if(isIcon)
1034 rc = SendInternalMessageA(WM_ICONERASEBKGND, hdcErase, 0);
1035 else
1036 rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0);
1037 if (hdc == 0)
1038 O32_ReleaseDC(OS2Hwnd, hdcErase);
1039 return (rc);
1040}
1041//******************************************************************************
1042//******************************************************************************
1043ULONG Win32BaseWindow::MsgMouseMove(MSG *msg)
1044{
1045 if(ISMOUSE_CAPTURED()) {
1046 if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_MOVE, msg->pt.x, msg->pt.y))
1047 return 0;
1048 }
1049
1050 //TODO: hiword should be 0 if window enters menu mode (SDK docs)
1051 SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, msg->message));
1052
1053 //translated message == WM_(NC)MOUSEMOVE
1054 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
1055}
1056//******************************************************************************
1057//TODO: Depending on menu type, we should send WM_INITMENU or WM_INITPOPUPMENU
1058//TODO: PM sends it for each submenu that gets activated; Windows only for the first
1059// submenu; once the menu bar is active, moving the cursor doesn't generate other
1060// WM_INITMENU msgs. Not really a problem, but might need to fix this later on.
1061//******************************************************************************
1062ULONG Win32BaseWindow::MsgInitMenu(MSG *msg)
1063{
1064 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
1065}
1066//******************************************************************************
1067//******************************************************************************
1068ULONG Win32BaseWindow::MsgNCPaint()
1069{
1070 RECT rect;
1071
1072 if (GetOS2UpdateRect(OS2HwndFrame,&rect))
1073 {
1074 HRGN hrgn;
1075 ULONG rc;
1076 RECT client = rectClient;
1077
1078//CB: bug in dc.cpp!!!
1079 if ((rect.left == rect.right) || (rect.bottom == rect.top)) return 0;
1080 mapWin32Rect(getParent() ? getParent()->getOS2WindowHandle():OSLIB_HWND_DESKTOP,OS2HwndFrame,&client);
1081 if ((rect.left >= client.left) && (rect.left < client.right) &&
1082 (rect.right >= client.left) && (rect.right < client.right) &&
1083 (rect.top >= client.top) && (rect.top < client.bottom) &&
1084 (rect.bottom >= client.top) && (rect.bottom < client.bottom))
1085 return 0;
1086 hrgn = CreateRectRgnIndirect(&rect);
1087 if (!hrgn) return 0;
1088//CB: bug in GetDCEx with region!!!
1089 rc = SendInternalMessageA(WM_NCPAINT,/*hrgn*/0,0);
1090//dprintf(("CB: %d %d %d %d",rect.left,rect.top,rect.bottom,rect.right));
1091 DeleteObject(hrgn);
1092 //CB: todo: check if intersection with client
1093
1094 return rc;
1095 } else return 0;
1096}
1097//******************************************************************************
1098//******************************************************************************
1099ULONG Win32BaseWindow::MsgFormatFrame()
1100{
1101 RECT window = rectWindow,client = rectClient,rect;
1102 WINDOWPOS wndPos;
1103
1104 wndPos.hwnd = Win32Hwnd;
1105 wndPos.hwndInsertAfter = 0;
1106 rect = rectWindow;
1107 if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rect);
1108 wndPos.x = rect.left;
1109 wndPos.y = rect.top;
1110 wndPos.cx = rect.right-rect.left;
1111 wndPos.cy = rect.bottom-rect.top;
1112 wndPos.flags = 0; //dummy
1113
1114 return SendNCCalcSize(TRUE,&window,&window,&client,&wndPos,&rectClient);
1115}
1116//******************************************************************************
1117//******************************************************************************
1118ULONG Win32BaseWindow::MsgSetText(LPSTR lpsz, LONG cch)
1119{
1120 return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
1121}
1122//******************************************************************************
1123//******************************************************************************
1124ULONG Win32BaseWindow::MsgGetTextLength()
1125{
1126 return SendInternalMessageA(WM_GETTEXTLENGTH, 0, 0);
1127}
1128//******************************************************************************
1129//******************************************************************************
1130char *Win32BaseWindow::MsgGetText()
1131{
1132 SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA);
1133 return windowNameA;
1134}
1135//******************************************************************************
1136//******************************************************************************
1137ULONG Win32BaseWindow::MsgContextMenu(ULONG x,ULONG y)
1138{
1139 return SendInternalMessageA(WM_CONTEXTMENU,Win32Hwnd,MAKELPARAM(x,y));
1140}
1141//******************************************************************************
1142//******************************************************************************
1143BOOL Win32BaseWindow::isMDIClient()
1144{
1145 return FALSE;
1146}
1147//******************************************************************************
1148//******************************************************************************
1149BOOL Win32BaseWindow::isMDIChild()
1150{
1151 return FALSE;
1152}
1153//******************************************************************************
1154//TODO: Not complete
1155//******************************************************************************
1156BOOL Win32BaseWindow::isFrameWindow()
1157{
1158// if(isMDIChild() || IsDialog() || (getParent() == NULL || getParent() == windowDesktop) && ((dwStyle & WS_CAPTION) == WS_CAPTION))
1159 if((dwStyle & WS_CAPTION) == WS_CAPTION || dwStyle & (WS_VSCROLL|WS_HSCROLL))
1160 return TRUE;
1161
1162 return FALSE;
1163}
1164//******************************************************************************
1165//******************************************************************************
1166SCROLLBAR_INFO *Win32BaseWindow::getScrollInfo(int nBar)
1167{
1168 switch(nBar)
1169 {
1170 case SB_HORZ:
1171 if (!horzScrollInfo)
1172 {
1173 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
1174 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
1175 horzScrollInfo->MaxVal = 100;
1176 horzScrollInfo->flags = ESB_ENABLE_BOTH;
1177 }
1178 return horzScrollInfo;
1179
1180 case SB_VERT:
1181 if (!vertScrollInfo)
1182 {
1183 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
1184 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
1185 vertScrollInfo->MaxVal = 100;
1186 vertScrollInfo->flags = ESB_ENABLE_BOTH;
1187 }
1188 return vertScrollInfo;
1189 }
1190
1191 return NULL;
1192}
1193//******************************************************************************
1194//******************************************************************************
1195LRESULT Win32BaseWindow::DefWndControlColor(UINT ctlType, HDC hdc)
1196{
1197 //SvL: Set background color to default button color (not window (white))
1198 if(ctlType == CTLCOLOR_BTN)
1199 {
1200 SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
1201 SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
1202 return GetSysColorBrush(COLOR_BTNFACE);
1203 }
1204 //SvL: Set background color to default dialog color if window is dialog
1205 if((ctlType == CTLCOLOR_DLG || ctlType == CTLCOLOR_STATIC) && IsDialog()) {
1206 SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
1207 SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
1208 return GetSysColorBrush(COLOR_BTNFACE);
1209 }
1210
1211 if( ctlType == CTLCOLOR_SCROLLBAR)
1212 {
1213 HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
1214 COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
1215 SetTextColor( hdc, GetSysColor(COLOR_3DFACE));
1216 SetBkColor( hdc, bk);
1217
1218//TODO?
1219#if 0
1220 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
1221 * we better use 0x55aa bitmap brush to make scrollbar's background
1222 * look different from the window background.
1223 */
1224 if (bk == GetSysColor(COLOR_WINDOW)) {
1225 return CACHE_GetPattern55AABrush();
1226 }
1227#endif
1228 UnrealizeObject( hb );
1229 return (LRESULT)hb;
1230 }
1231
1232 SetTextColor( hdc, GetSysColor(COLOR_WINDOWTEXT));
1233
1234 if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
1235 {
1236 SetBkColor( hdc, GetSysColor(COLOR_WINDOW) );
1237 }
1238 else
1239 {
1240 SetBkColor( hdc, GetSysColor(COLOR_3DFACE) );
1241 return (LRESULT)GetSysColorBrush(COLOR_3DFACE);
1242 }
1243 return (LRESULT)GetSysColorBrush(COLOR_WINDOW);
1244}
1245//******************************************************************************
1246//******************************************************************************
1247LRESULT Win32BaseWindow::DefWndPrint(HDC hdc,ULONG uFlags)
1248{
1249 /*
1250 * Visibility flag.
1251 */
1252 if ( (uFlags & PRF_CHECKVISIBLE) &&
1253 !IsWindowVisible() )
1254 return 0;
1255
1256 /*
1257 * Unimplemented flags.
1258 */
1259 if ( (uFlags & PRF_CHILDREN) ||
1260 (uFlags & PRF_OWNED) ||
1261 (uFlags & PRF_NONCLIENT) )
1262 {
1263 dprintf(("WM_PRINT message with unsupported flags\n"));
1264 }
1265
1266 /*
1267 * Background
1268 */
1269 if ( uFlags & PRF_ERASEBKGND)
1270 SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
1271
1272 /*
1273 * Client area
1274 */
1275 if ( uFlags & PRF_CLIENT)
1276 SendInternalMessageA(WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
1277
1278
1279 return 0;
1280}
1281//******************************************************************************
1282//******************************************************************************
1283LRESULT Win32BaseWindow::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam)
1284{
1285 switch(Msg)
1286 {
1287 case WM_CLOSE:
1288 dprintf(("DefWindowProcA: WM_CLOSE %x", getWindowHandle()));
1289 DestroyWindow();
1290 return 0;
1291
1292 case WM_GETTEXTLENGTH:
1293 return wndNameLength;
1294
1295 case WM_GETTEXT:
1296 if (!lParam || !wParam) return 0;
1297 if (!windowNameA) ((LPSTR)lParam)[0] = 0;
1298 else lstrcpynA((LPSTR)lParam, windowNameA, wParam);
1299 return min(wndNameLength, wParam);
1300
1301 case WM_SETTEXT:
1302 {
1303 LPCSTR lpsz = (LPCSTR)lParam;
1304
1305 if(windowNameA) free(windowNameA);
1306 if(windowNameW) free(windowNameW);
1307
1308 if (lParam)
1309 {
1310 wndNameLength = strlen(lpsz);
1311 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
1312 strcpy(windowNameA, lpsz);
1313 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
1314 lstrcpyAtoW(windowNameW, windowNameA);
1315 }
1316 else
1317 {
1318 windowNameA = NULL;
1319 windowNameW = NULL;
1320 wndNameLength = 0;
1321 }
1322 dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, lParam));
1323 if (dwStyle & WS_CAPTION)
1324 {
1325 //CB: optimize!
1326 HandleNCPaint(0);
1327 }
1328/* //CB: endless loop in trackbar.exe -> to fix
1329 if(OS2HwndFrame && (dwStyle & WS_CAPTION) == WS_CAPTION)
1330 return OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
1331*/
1332 return TRUE;
1333 }
1334
1335 case WM_SETREDRAW:
1336 {
1337 if (wParam)
1338 {
1339 setStyle(getStyle() | WS_VISIBLE);
1340 OSLibWinEnableWindowUpdate(OS2HwndFrame,TRUE);
1341 }
1342 else
1343 {
1344 if (getStyle() & WS_VISIBLE)
1345 {
1346 setStyle(getStyle() & ~WS_VISIBLE);
1347 OSLibWinEnableWindowUpdate(OS2HwndFrame,FALSE);
1348 }
1349 }
1350 return 0;
1351 }
1352
1353 case WM_CTLCOLORMSGBOX:
1354 case WM_CTLCOLOREDIT:
1355 case WM_CTLCOLORLISTBOX:
1356 case WM_CTLCOLORBTN:
1357 case WM_CTLCOLORDLG:
1358 case WM_CTLCOLORSTATIC:
1359 case WM_CTLCOLORSCROLLBAR:
1360 return DefWndControlColor(Msg - WM_CTLCOLORMSGBOX, (HDC)wParam);
1361
1362 case WM_CTLCOLOR:
1363 return DefWndControlColor(HIWORD(lParam), (HDC)wParam);
1364
1365 case WM_VKEYTOITEM:
1366 case WM_CHARTOITEM:
1367 return -1;
1368
1369 case WM_PARENTNOTIFY:
1370 return 0;
1371
1372 case WM_MOUSEACTIVATE:
1373 {
1374 dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
1375 if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
1376 {
1377 if(getParent()) {
1378 LRESULT rc = getParent()->SendInternalMessageA(WM_MOUSEACTIVATE, wParam, lParam );
1379 if(rc) return rc;
1380 }
1381 }
1382 return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
1383 }
1384
1385 case WM_ACTIVATE:
1386 return 0;
1387
1388 case WM_SETCURSOR:
1389 {
1390 dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
1391 if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
1392 {
1393 if(getParent()) {
1394 LRESULT rc = getParent()->SendInternalMessageA(WM_SETCURSOR, wParam, lParam);
1395 if(rc) return rc;
1396 }
1397 }
1398 if (wParam == Win32Hwnd)
1399 {
1400 HCURSOR hCursor;
1401
1402 switch(LOWORD(lParam))
1403 {
1404 case HTCLIENT:
1405 hCursor = windowClass ? windowClass->getCursor():LoadCursorA(0,IDC_ARROWA);
1406 break;
1407
1408 case HTLEFT:
1409 case HTRIGHT:
1410 hCursor = LoadCursorA(0,IDC_SIZEWEA);
1411 break;
1412
1413 case HTTOP:
1414 case HTBOTTOM:
1415 hCursor = LoadCursorA(0,IDC_SIZENSA);
1416 break;
1417
1418 case HTTOPLEFT:
1419 case HTBOTTOMRIGHT:
1420 hCursor = LoadCursorA(0,IDC_SIZENWSEA);
1421 break;
1422
1423 case HTTOPRIGHT:
1424 case HTBOTTOMLEFT:
1425 hCursor = LoadCursorA(0,IDC_SIZENESWA);
1426 break;
1427
1428 default:
1429 hCursor = LoadCursorA(0,IDC_ARROWA);
1430 break;
1431 }
1432
1433 if (hCursor)
1434 {
1435 SetCursor(hCursor);
1436 return 1;
1437 } else return 0;
1438 } else return 0;
1439 }
1440
1441 case WM_MOUSEMOVE:
1442 return 0;
1443
1444 case WM_WINDOWPOSCHANGED:
1445 {
1446
1447/* undocumented SWP flags - from SDK 3.1 */
1448#define SWP_NOCLIENTSIZE 0x0800
1449#define SWP_NOCLIENTMOVE 0x1000
1450
1451 PWINDOWPOS wpos = (PWINDOWPOS)lParam;
1452 WPARAM wp = SIZE_RESTORED;
1453
1454 if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE))
1455 SendInternalMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
1456
1457 if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE))
1458 {
1459 if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
1460 else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
1461
1462 SendInternalMessageA(WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left,
1463 rectClient.bottom - rectClient.top));
1464 }
1465 return 0;
1466 }
1467 case WM_WINDOWPOSCHANGING:
1468 return HandleWindowPosChanging((WINDOWPOS *)lParam);
1469
1470 case WM_ERASEBKGND:
1471 case WM_ICONERASEBKGND:
1472 {
1473 RECT rect;
1474 int rc;
1475
1476 if (!windowClass || !windowClass->getBackgroundBrush()) return 0;
1477
1478 rc = GetClipBox( (HDC)wParam, &rect );
1479 if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
1480 {
1481 HBRUSH hBrush = windowClass->getBackgroundBrush();
1482
1483 if (hBrush <= (HBRUSH)(SYSCOLOR_GetLastColor()+1)) hBrush = GetSysColorBrush(hBrush-1);
1484
1485 FillRect( (HDC)wParam, &rect, hBrush);
1486 }
1487
1488 return 1;
1489 }
1490
1491 case WM_PRINT:
1492 return DefWndPrint(wParam,lParam);
1493
1494 case WM_PAINTICON:
1495 case WM_PAINT:
1496 {
1497 PAINTSTRUCT ps;
1498 HDC hdc = BeginPaint(getWindowHandle(), &ps );
1499 if( hdc )
1500 {
1501 if( (getStyle() & WS_MINIMIZE) && getWindowClass()->getIcon())
1502 {
1503 int x = (rectWindow.right - rectWindow.left - GetSystemMetrics(SM_CXICON))/2;
1504 int y = (rectWindow.bottom - rectWindow.top - GetSystemMetrics(SM_CYICON))/2;
1505 dprintf(("Painting class icon: vis rect=(%i,%i - %i,%i)\n", ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ));
1506 DrawIcon(hdc, x, y, getWindowClass()->getIcon() );
1507 }
1508 EndPaint(getWindowHandle(), &ps );
1509 }
1510 return 0;
1511 }
1512
1513 case WM_GETDLGCODE:
1514 return 0;
1515
1516 case WM_NCPAINT:
1517 return HandleNCPaint((HRGN)wParam);
1518
1519 case WM_NCACTIVATE:
1520 return HandleNCActivate(wParam);
1521
1522 case WM_NCCREATE:
1523 return(TRUE);
1524
1525 case WM_NCDESTROY:
1526 return 0;
1527
1528 case WM_NCCALCSIZE:
1529 return HandleNCCalcSize((BOOL)wParam,(RECT*)lParam);
1530
1531 case WM_NCLBUTTONDOWN:
1532 return HandleNCLButtonDown(wParam,lParam);
1533
1534 case WM_LBUTTONDBLCLK:
1535 case WM_NCLBUTTONDBLCLK:
1536 return HandleNCLButtonDblClk(wParam,lParam);
1537
1538 case WM_NCRBUTTONDOWN:
1539 case WM_NCRBUTTONDBLCLK:
1540 case WM_NCMBUTTONDOWN:
1541 case WM_NCMBUTTONDBLCLK:
1542 if (lastHitTestVal == HTERROR) MessageBeep(MB_ICONEXCLAMATION);
1543 return 0;
1544
1545 case WM_NCRBUTTONUP:
1546 case WM_NCMBUTTONUP:
1547 return 0;
1548
1549 case WM_NCHITTEST:
1550 {
1551 POINT point;
1552
1553 point.x = (SHORT)LOWORD(lParam);
1554 point.y = (SHORT)HIWORD(lParam);
1555
1556 return HandleNCHitTest(point);
1557 }
1558
1559 case WM_SYSCOMMAND:
1560 {
1561 POINT point;
1562
1563 point.x = LOWORD(lParam);
1564 point.y = HIWORD(lParam);
1565 return HandleSysCommand(wParam,&point);
1566 }
1567
1568 case WM_SYSKEYDOWN:
1569 if(wParam == VK_F4) /* try to close the window */
1570 {
1571 Win32BaseWindow *window = GetTopParent();
1572 if(window && !(window->getClass()->getStyle() & CS_NOCLOSE))
1573 PostMessageA(getWindowHandle(), WM_SYSCOMMAND, SC_CLOSE, 0);
1574 }
1575
1576 Win32BaseWindow *siblingWindow;
1577 HWND sibling;
1578 char nameBuffer [40], mnemonic;
1579 int nameLength;
1580
1581 GetWindowTextA (nameBuffer, 40);
1582
1583 // search all sibling to see it this key is their mnemonic
1584 sibling = GetWindow (GW_HWNDFIRST);
1585 while (sibling != 0) {
1586 siblingWindow = GetWindowFromHandle (sibling);
1587 nameLength = siblingWindow->GetWindowTextA (nameBuffer, 40);
1588
1589 // find the siblings mnemonic
1590 mnemonic = '\0';
1591 for (int i=0 ; i<nameLength ; i++) {
1592 if (nameBuffer [i] == '&') {
1593 mnemonic = nameBuffer [i+1];
1594 if ((mnemonic >= 'a') && (mnemonic <= 'z'))
1595 mnemonic -= 32; // make it uppercase
1596 break; // stop searching
1597 }
1598 }
1599
1600 // key matches siblings mnemonic, send mouseclick
1601 if (mnemonic == (char) wParam) {
1602 siblingWindow->SendInternalMessageA (BM_CLICK, 0, 0);
1603 }
1604
1605 sibling = siblingWindow->GetNextWindow (GW_HWNDNEXT);
1606 }
1607
1608 return 0;
1609
1610 case WM_SHOWWINDOW:
1611 if (!lParam) return 0; /* sent from ShowWindow */
1612 if (!(dwStyle & WS_POPUP) || !owner) return 0;
1613 if ((dwStyle & WS_VISIBLE) && wParam) return 0;
1614 else if (!(dwStyle & WS_VISIBLE) && !wParam) return 0;
1615 ShowWindow(wParam ? SW_SHOWNOACTIVATE : SW_HIDE);
1616 return 0;
1617
1618 case WM_CANCELMODE:
1619 if (getParent() == windowDesktop) EndMenu();
1620 if (GetCapture() == Win32Hwnd) ReleaseCapture();
1621 return 0;
1622
1623 case WM_DROPOBJECT:
1624 return DRAG_FILE;
1625
1626 case WM_QUERYDROPOBJECT:
1627 if (dwExStyle & WS_EX_ACCEPTFILES) return 1;
1628 return 0;
1629
1630 case WM_QUERYDRAGICON:
1631 {
1632 HICON hIcon = windowClass->getCursor();
1633 UINT len;
1634
1635 if(hIcon) return (LRESULT)hIcon;
1636 for(len = 1; len < 64; len++)
1637 {
1638 hIcon = LoadIconA(hInstance,MAKEINTRESOURCEA(len));
1639 if(hIcon)
1640 return (LRESULT)hIcon;
1641 }
1642 return (LRESULT)LoadIconA(0,IDI_APPLICATIONA);
1643 }
1644
1645 case WM_QUERYOPEN:
1646 case WM_QUERYENDSESSION:
1647 return 1;
1648
1649 case WM_NOTIFYFORMAT:
1650 if (IsWindowUnicode()) return NFR_UNICODE;
1651 else return NFR_ANSI;
1652
1653 case WM_SETICON:
1654 case WM_GETICON:
1655 {
1656 LRESULT result = 0;
1657 if (!windowClass) return result;
1658 int index = GCL_HICON;
1659
1660 if (wParam == ICON_SMALL)
1661 index = GCL_HICONSM;
1662
1663 result = windowClass->getClassLongA(index);
1664
1665 if (Msg == WM_SETICON)
1666 windowClass->setClassLongA(index, lParam);
1667
1668 return result;
1669 }
1670
1671 case WM_NOTIFY:
1672 return 0; //comctl32 controls expect this
1673
1674 default:
1675 if(Msg > WM_USER) {
1676 return 0;
1677 }
1678 return 1; //CB: shouldn't this be 0?
1679 }
1680}
1681//******************************************************************************
1682//******************************************************************************
1683LRESULT Win32BaseWindow::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam)
1684{
1685 switch(Msg)
1686 {
1687 case WM_GETTEXTLENGTH:
1688 return wndNameLength;
1689
1690 case WM_GETTEXT:
1691 if (!lParam || !wParam) return 0;
1692 if (!windowNameW) ((LPWSTR)lParam)[0] = 0;
1693 else lstrcpynW((LPWSTR)lParam,windowNameW,wParam);
1694 return min(wndNameLength,wParam);
1695
1696 case WM_SETTEXT:
1697 {
1698 LPWSTR lpsz = (LPWSTR)lParam;
1699
1700 if(windowNameA) free(windowNameA);
1701 if(windowNameW) free(windowNameW);
1702
1703 if (lParam)
1704 {
1705 wndNameLength = lstrlenW(lpsz);
1706 windowNameA = (LPSTR)_smalloc(wndNameLength+1);
1707 lstrcpyWtoA(windowNameA,lpsz);
1708 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
1709 lstrcpyW(windowNameW,lpsz);
1710 }
1711 else
1712 {
1713 windowNameA = NULL;
1714 windowNameW = NULL;
1715 wndNameLength = 0;
1716 }
1717
1718 if(OS2HwndFrame && (dwStyle & WS_CAPTION) == WS_CAPTION)
1719 return OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
1720
1721 return TRUE;
1722 }
1723
1724 default:
1725 return DefWindowProcA(Msg, wParam, lParam);
1726 }
1727}
1728//******************************************************************************
1729//******************************************************************************
1730LRESULT Win32BaseWindow::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
1731{
1732 //if the destination window is created by this process & thread, call window proc directly
1733 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
1734 return SendInternalMessageA(Msg, wParam, lParam);
1735 }
1736 //otherwise use WinSendMsg to send it to the right process/thread
1737 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, FALSE);
1738}
1739//******************************************************************************
1740//******************************************************************************
1741LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
1742{
1743 //if the destination window is created by this process & thread, call window proc directly
1744 if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
1745 return SendInternalMessageW(Msg, wParam, lParam);
1746 }
1747 //otherwise use WinSendMsg to send it to the right process/thread
1748 return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, TRUE);
1749}
1750//******************************************************************************
1751//Called as a result of an OS/2 message or called from a class method
1752//******************************************************************************
1753LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
1754{
1755 LRESULT rc;
1756 BOOL fInternalMsgBackup = fInternalMsg;
1757
1758 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE);
1759
1760 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, FALSE);
1761
1762 fInternalMsg = TRUE;
1763 switch(Msg)
1764 {
1765 case WM_CREATE:
1766 {
1767 if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1768 dprintf(("WM_CREATE returned -1\n"));
1769 rc = -1; //don't create window
1770 break;
1771 }
1772 rc = 0;
1773 break;
1774 }
1775 case WM_LBUTTONDOWN:
1776 case WM_MBUTTONDOWN:
1777 case WM_RBUTTONDOWN:
1778 {
1779 if (getParent())
1780 {
1781 POINTS pt = MAKEPOINTS(lParam);
1782 POINT point;
1783
1784 point.x = pt.x;
1785 point.y = pt.y;
1786 mapWin32Point(OS2Hwnd,getParent()->getOS2WindowHandle(),(OSLIBPOINT*)&point);
1787 NotifyParent(Msg,wParam,MAKELPARAM(point.x,point.y));
1788 }
1789 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1790 break;
1791 }
1792
1793 case WM_DESTROY:
1794 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1795 break;
1796
1797 default:
1798 rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
1799 break;
1800 }
1801 fInternalMsg = fInternalMsgBackup;
1802 return rc;
1803}
1804//******************************************************************************
1805//Called as a result of an OS/2 message or called from a class method
1806//******************************************************************************
1807LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
1808{
1809 LRESULT rc;
1810 BOOL fInternalMsgBackup = fInternalMsg;
1811
1812 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE);
1813
1814 CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, TRUE);
1815
1816 fInternalMsg = TRUE;
1817 switch(Msg)
1818 {
1819 case WM_CREATE:
1820 {
1821 if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1822 dprintf(("WM_CREATE returned -1\n"));
1823 rc = -1; //don't create window
1824 break;
1825 }
1826 rc = 0;
1827 break;
1828 }
1829 case WM_LBUTTONDOWN:
1830 case WM_MBUTTONDOWN:
1831 case WM_RBUTTONDOWN:
1832 NotifyParent(Msg, wParam, lParam);
1833 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1834 break;
1835
1836 case WM_DESTROY:
1837 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1838 break;
1839 default:
1840 rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
1841 break;
1842 }
1843 fInternalMsg = fInternalMsgBackup;
1844 return rc;
1845}
1846//******************************************************************************
1847//******************************************************************************
1848void Win32BaseWindow::CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
1849{
1850 CWPSTRUCT cwp;
1851
1852 cwp.lParam = lParam;
1853 cwp.wParam = wParam;
1854 cwp.message = Msg;
1855 cwp.hwnd = getWindowHandle();
1856
1857 switch(hooktype) {
1858 case WH_CALLWNDPROC:
1859 if(fUnicode) {
1860 HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
1861 }
1862 else HOOK_CallHooksA(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
1863 break;
1864 }
1865}
1866//******************************************************************************
1867//******************************************************************************
1868//******************************************************************************
1869//TODO: Do this more efficiently
1870//******************************************************************************
1871LRESULT Win32BaseWindow::BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam)
1872{
1873 Win32BaseWindow *window;
1874 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
1875
1876 dprintf(("BroadCastMessageA %x %x %x", msg, wParam, lParam, GetFS()));
1877
1878 for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
1879 window = GetWindowFromHandle(hwnd++);
1880 if(window) {
1881 if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
1882 {
1883
1884 if(type == BROADCAST_SEND) {
1885 window->SendInternalMessageA(msg, wParam, lParam);
1886 }
1887 else PostMessageA(window->getWindowHandle(), msg, wParam, lParam);
1888 }
1889 }
1890 }
1891 return 0;
1892}
1893//******************************************************************************
1894//TODO: Do this more efficiently
1895//******************************************************************************
1896LRESULT Win32BaseWindow::BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam)
1897{
1898 Win32BaseWindow *window;
1899 HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
1900
1901 dprintf(("BroadCastMessageW %x %x %x", msg, wParam, lParam));
1902
1903 for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
1904 window = GetWindowFromHandle(hwnd++);
1905 if(window) {
1906 if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
1907 {
1908
1909 if(type == BROADCAST_SEND) {
1910 window->SendInternalMessageW(msg, wParam, lParam);
1911 }
1912 else PostMessageW(window->getWindowHandle(), msg, wParam, lParam);
1913 }
1914 }
1915 }
1916 return 0;
1917}
1918//******************************************************************************
1919//******************************************************************************
1920void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
1921{
1922 Win32BaseWindow *window = this;
1923 Win32BaseWindow *parentwindow;
1924
1925 while(window)
1926 {
1927 if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
1928 {
1929 /* Notify the parent window only */
1930 parentwindow = window->getParent();
1931 if(parentwindow) {
1932 parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam );
1933 }
1934 }
1935 else break;
1936
1937 window = parentwindow;
1938 }
1939}
1940//******************************************************************************
1941//******************************************************************************
1942BOOL Win32BaseWindow::SetIcon(HICON hIcon)
1943{
1944 dprintf(("Win32BaseWindow::SetIcon %x", hIcon));
1945 if(OSLibWinSetIcon(OS2HwndFrame, hIcon) == TRUE) {
1946//TODO: Wine does't send these. Correct?
1947// SendInternalMessageA(WM_SETICON, ICON_BIG, hIcon);
1948 return TRUE;
1949 }
1950 return FALSE;
1951}
1952//******************************************************************************
1953//******************************************************************************
1954BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow)
1955{
1956 ULONG showstate = 0;
1957 HWND hWinAfter;
1958
1959 dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
1960#if 1
1961 if (flags & WIN_NEED_SIZE)
1962 {
1963 /* should happen only in CreateWindowEx() */
1964 int wParam = SIZE_RESTORED;
1965
1966 flags &= ~WIN_NEED_SIZE;
1967 if (dwStyle & WS_MAXIMIZE)
1968 wParam = SIZE_MAXIMIZED;
1969 else
1970 if (dwStyle & WS_MINIMIZE)
1971 wParam = SIZE_MINIMIZED;
1972
1973 SendInternalMessageA(WM_SIZE, wParam,
1974 MAKELONG(rectClient.right-rectClient.left,
1975 rectClient.bottom-rectClient.top));
1976 SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
1977 }
1978#else
1979 if(fFirstShow) {
1980 if(isFrameWindow() && IS_OVERLAPPED(getStyle()) && !isChild()) {
1981 SendInternalMessageA(WM_SIZE, SIZE_RESTORED,
1982 MAKELONG(rectClient.right-rectClient.left,
1983 rectClient.bottom-rectClient.top));
1984 SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
1985
1986 }
1987 fFirstShow = FALSE;
1988 }
1989#endif
1990 switch(nCmdShow)
1991 {
1992 case SW_SHOW:
1993 case SW_SHOWDEFAULT: //todo
1994 showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
1995 break;
1996 case SW_HIDE:
1997 showstate = SWPOS_HIDE;
1998 break;
1999 case SW_RESTORE:
2000 showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
2001 break;
2002 case SW_MINIMIZE:
2003 showstate = SWPOS_MINIMIZE;
2004 break;
2005 case SW_SHOWMAXIMIZED:
2006 showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
2007 break;
2008 case SW_SHOWMINIMIZED:
2009 showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
2010 break;
2011 case SW_SHOWMINNOACTIVE:
2012 showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
2013 break;
2014 case SW_SHOWNA:
2015 showstate = SWPOS_SHOW;
2016 break;
2017 case SW_SHOWNOACTIVATE:
2018 showstate = SWPOS_SHOW;
2019 break;
2020 case SW_SHOWNORMAL:
2021 showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
2022 break;
2023 }
2024
2025 /* We can't activate a child window (WINE) */
2026 if(getStyle() & WS_CHILD)
2027 showstate &= ~SWPOS_ACTIVATE;
2028
2029 if(showstate & SWPOS_SHOW) {
2030 setStyle(getStyle() | WS_VISIBLE);
2031 }
2032 else setStyle(getStyle() & ~WS_VISIBLE);
2033
2034 BOOL rc = OSLibWinShowWindow(OS2HwndFrame, showstate);
2035
2036 return rc;
2037}
2038//******************************************************************************
2039//******************************************************************************
2040BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
2041{
2042 BOOL rc = FALSE;
2043 Win32BaseWindow *window;
2044 HWND hParent = 0;
2045
2046 dprintf (("SetWindowPos %x %x (%d,%d)(%d,%d) %x", Win32Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
2047
2048 if (fuFlags &
2049 ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
2050 SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED |
2051 SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS |
2052 SWP_NOOWNERZORDER))
2053 {
2054 return FALSE;
2055 }
2056
2057 WINDOWPOS wpos;
2058 SWP swp, swpOld;
2059
2060 wpos.flags = fuFlags;
2061 wpos.cy = cy;
2062 wpos.cx = cx;
2063 wpos.x = x;
2064 wpos.y = y;
2065 wpos.hwndInsertAfter = hwndInsertAfter;
2066 wpos.hwnd = getWindowHandle();
2067
2068 if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
2069 {
2070 if (isChild())
2071 {
2072 Win32BaseWindow *windowParent = getParent();
2073 if(windowParent) {
2074 hParent = getParent()->getOS2WindowHandle();
2075 }
2076 else dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
2077 }
2078 OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
2079 }
2080
2081 OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame);
2082 if (swp.fl == 0)
2083 return TRUE;
2084
2085// if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
2086 if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
2087 {
2088 Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
2089 if(wndBehind) {
2090 swp.hwndInsertBehind = wndBehind->getOS2FrameWindowHandle();
2091 }
2092 else {
2093 dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
2094 swp.hwndInsertBehind = 0;
2095 }
2096 }
2097//CB: todo
2098 #if 0
2099 if (isFrameWindow())
2100 {
2101 if (!isChild())
2102 {
2103 POINT maxSize, maxPos, minTrack, maxTrack;
2104
2105 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
2106
2107 if (swp.cx > maxTrack.x) swp.cx = maxTrack.x;
2108 if (swp.cy > maxTrack.y) swp.cy = maxTrack.y;
2109 if (swp.cx < minTrack.x) swp.cx = minTrack.x;
2110 if (swp.cy < minTrack.y) swp.cy = minTrack.y;
2111 }
2112 swp.hwnd = OS2HwndFrame;
2113 }
2114 else
2115#endif
2116 swp.hwnd = OS2HwndFrame;
2117
2118 dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
2119
2120 rc = OSLibWinSetMultWindowPos(&swp, 1);
2121
2122 if (rc == FALSE)
2123 {
2124 dprintf(("OSLibWinSetMultWindowPos failed! Error %x",OSLibWinGetLastError()));
2125 }
2126
2127 if (fuFlags == SWP_FRAMECHANGED)
2128 {
2129 //CB: optimize: if frame size has changed not necessary!
2130 FrameUpdateFrame(this,0);
2131 }
2132
2133 return (rc);
2134}
2135//******************************************************************************
2136//TODO: WPF_RESTOREMAXIMIZED
2137//******************************************************************************
2138BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *winpos)
2139{
2140 if(isFrameWindow())
2141 {
2142 // Set the minimized position
2143 if (winpos->flags & WPF_SETMINPOSITION)
2144 {
2145 OSLibSetWindowMinPos(OS2HwndFrame, winpos->ptMinPosition.x, winpos->ptMinPosition.y);
2146 }
2147
2148 //TODO: Max position
2149
2150 // Set the new restore position.
2151 OSLibSetWindowRestoreRect(OS2HwndFrame, &winpos->rcNormalPosition);
2152 }
2153
2154 return ShowWindow(winpos->showCmd);
2155}
2156//******************************************************************************
2157//Also destroys all the child windows (destroy children first, parent last)
2158//******************************************************************************
2159BOOL Win32BaseWindow::DestroyWindow()
2160{
2161 /* Call hooks */
2162 if(HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, getWindowHandle(), 0L))
2163 {
2164 return FALSE;
2165 }
2166
2167 if(!(getStyle() & WS_CHILD) && getOwner() == NULL)
2168 {
2169 HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWDESTROYED, getWindowHandle(), 0L);
2170 /* FIXME: clean up palette - see "Internals" p.352 */
2171 }
2172
2173 if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
2174 {
2175 if(getParent())
2176 {
2177 /* Notify the parent window only */
2178 getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
2179 if( !::IsWindow(getWindowHandle()) )
2180 {
2181 return TRUE;
2182 }
2183 }
2184 else DebugInt3();
2185 }
2186 fDestroyWindowCalled = TRUE;
2187 return OSLibWinDestroyWindow(OS2HwndFrame);
2188}
2189//******************************************************************************
2190//******************************************************************************
2191Win32BaseWindow *Win32BaseWindow::getParent()
2192{
2193 Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::GetParent();
2194 return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
2195}
2196//******************************************************************************
2197//******************************************************************************
2198HWND Win32BaseWindow::GetParent()
2199{
2200 Win32BaseWindow *wndparent;
2201
2202 if ((!(getStyle() & (WS_POPUP|WS_CHILD))))
2203 {
2204 return 0;
2205 }
2206 wndparent = ((getStyle() & WS_CHILD) ? getParent() : getOwner());
2207
2208 return (wndparent) ? wndparent->getWindowHandle() : 0;
2209}
2210//******************************************************************************
2211//******************************************************************************
2212HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
2213{
2214 HWND oldhwnd;
2215 Win32BaseWindow *newparent;
2216
2217 if(getParent()) {
2218 oldhwnd = getParent()->getWindowHandle();
2219 getParent()->RemoveChild(this);
2220 }
2221 else oldhwnd = 0;
2222
2223 newparent = GetWindowFromHandle(hwndNewParent);
2224 if(newparent)
2225 {
2226 setParent(newparent);
2227 getParent()->AddChild(this);
2228 OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
2229 return oldhwnd;
2230 }
2231 else {
2232 setParent(windowDesktop);
2233 windowDesktop->AddChild(this);
2234 OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
2235 return oldhwnd;
2236 }
2237}
2238//******************************************************************************
2239//******************************************************************************
2240BOOL Win32BaseWindow::IsChild(HWND hwndParent)
2241{
2242 if(getParent()) {
2243 return getParent()->getWindowHandle() == hwndParent;
2244 }
2245 else return 0;
2246}
2247//******************************************************************************
2248//******************************************************************************
2249HWND Win32BaseWindow::GetTopWindow()
2250{
2251 return GetWindow(GW_CHILD);
2252}
2253//******************************************************************************
2254// Get the top-level parent for a child window.
2255//******************************************************************************
2256Win32BaseWindow *Win32BaseWindow::GetTopParent()
2257{
2258 Win32BaseWindow *window = this;
2259
2260 while(window && (window->getStyle() & WS_CHILD))
2261 {
2262 window = window->getParent();
2263 }
2264 return window;
2265}
2266//******************************************************************************
2267//Don't call WinUpdateWindow as that one also updates the child windows
2268//Also need to send WM_PAINT directly to the window procedure, which doesn't
2269//always happen with WinUpdateWindow (could be posted if thread doesn't own window)
2270//******************************************************************************
2271BOOL Win32BaseWindow::UpdateWindow()
2272{
2273 RECT rect;
2274
2275 if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect))
2276 {//update region not empty
2277 HDC hdc;
2278
2279 hdc = O32_GetDC(OS2Hwnd);
2280 if (isIcon)
2281 {
2282 SendInternalMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
2283 SendInternalMessageA(WM_PAINTICON, 0, 0);
2284 }
2285 else
2286 {
2287 SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
2288 SendInternalMessageA(WM_PAINT, 0, 0);
2289 }
2290 O32_ReleaseDC(OS2Hwnd, hdc);
2291 }
2292 return TRUE;
2293}
2294//******************************************************************************
2295//******************************************************************************
2296BOOL Win32BaseWindow::IsIconic()
2297{
2298 return OSLibWinIsIconic(OS2Hwnd);
2299}
2300//******************************************************************************
2301//TODO: Should not enumerate children that are created during the enumeration!
2302//******************************************************************************
2303BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
2304{
2305 BOOL rc = TRUE;
2306 HWND hwnd;
2307 Win32BaseWindow *prevchild = 0, *child = 0;
2308
2309 dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
2310 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2311 {
2312 dprintf(("EnumChildWindows: enumerating child %x", child->getWindowHandle()));
2313 hwnd = child->getWindowHandle();
2314 if(child->getOwner()) {
2315 continue; //shouldn't have an owner (Wine)
2316 }
2317 if(lpfn(hwnd, lParam) == FALSE)
2318 {
2319 rc = FALSE;
2320 break;
2321 }
2322 //check if the window still exists
2323 if(!::IsWindow(hwnd))
2324 {
2325 child = prevchild;
2326 continue;
2327 }
2328 if(child->getFirstChild() != NULL)
2329 {
2330 dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle()));
2331 if(child->EnumChildWindows(lpfn, lParam) == FALSE)
2332 {
2333 rc = FALSE;
2334 break;
2335 }
2336 }
2337 prevchild = child;
2338 }
2339 return rc;
2340}
2341//******************************************************************************
2342//Enumerate first-level children only and check thread id
2343//******************************************************************************
2344BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
2345{
2346 Win32BaseWindow *child = 0;
2347 ULONG tid, pid;
2348 BOOL rc;
2349 HWND hwnd;
2350
2351 dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam));
2352
2353 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2354 {
2355 OSLibWinQueryWindowProcess(child->getOS2WindowHandle(), &pid, &tid);
2356
2357 if(dwThreadId == tid) {
2358 dprintf2(("EnumThreadWindows: Found Window %x", child->getWindowHandle()));
2359 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
2360 break;
2361 }
2362 }
2363 }
2364 return TRUE;
2365}
2366//******************************************************************************
2367//Enumerate first-level children only
2368//******************************************************************************
2369BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
2370{
2371 Win32BaseWindow *child = 0;
2372 BOOL rc;
2373 HWND hwnd;
2374
2375 dprintf(("EnumWindows %x %x", lpfn, lParam));
2376
2377 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2378 {
2379 hwnd = child->getWindowHandle();
2380
2381 dprintf2(("EnumWindows: Found Window %x", child->getWindowHandle()));
2382 if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
2383 break;
2384 }
2385 }
2386 return TRUE;
2387}
2388//******************************************************************************
2389//******************************************************************************
2390Win32BaseWindow *Win32BaseWindow::FindWindowById(int id)
2391{
2392 for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2393 {
2394 if (child->getWindowId() == id)
2395 {
2396 return child;
2397 }
2398 }
2399 return 0;
2400}
2401//******************************************************************************
2402//TODO:
2403//We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
2404//the current process owns them.
2405//******************************************************************************
2406HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
2407 BOOL fUnicode)
2408{
2409 Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
2410 Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
2411
2412 if((hwndParent != OSLIB_HWND_DESKTOP && !parent) ||
2413 (hwndChildAfter != 0 && !child) ||
2414 (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0))
2415 {
2416 dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
2417 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
2418 return 0;
2419 }
2420 if(hwndParent != OSLIB_HWND_DESKTOP)
2421 {//if the current process owns the window, just do a quick search
2422 child = (Win32BaseWindow *)parent->getFirstChild();
2423 if(hwndChildAfter != 0)
2424 {
2425 while(child)
2426 {
2427 if(child->getWindowHandle() == hwndChildAfter)
2428 {
2429 child = (Win32BaseWindow *)child->getNextChild();
2430 break;
2431 }
2432 child = (Win32BaseWindow *)child->getNextChild();
2433 }
2434 }
2435 while(child)
2436 {
2437 if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
2438 (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
2439 {
2440 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
2441 return child->getWindowHandle();
2442 }
2443 child = (Win32BaseWindow *)child->getNextChild();
2444 }
2445 }
2446 else {
2447 Win32BaseWindow *wnd;
2448 HWND henum, hwnd;
2449
2450 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
2451 hwnd = OSLibWinGetNextWindow(henum);
2452
2453 while(hwnd)
2454 {
2455 wnd = GetWindowFromOS2Handle(hwnd);
2456 if(wnd == NULL) {
2457 hwnd = OSLibWinQueryClientWindow(hwnd);
2458 if(hwnd) wnd = GetWindowFromOS2Handle(hwnd);
2459 if(!hwnd) wnd = GetWindowFromOS2FrameHandle(hwnd);
2460 }
2461
2462 if(wnd) {
2463 if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
2464 (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
2465 {
2466 OSLibWinEndEnumWindows(henum);
2467 dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
2468 return wnd->getWindowHandle();
2469 }
2470 }
2471 hwnd = OSLibWinGetNextWindow(henum);
2472 }
2473 OSLibWinEndEnumWindows(henum);
2474 }
2475 SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
2476 return 0;
2477}
2478//******************************************************************************
2479//******************************************************************************
2480HWND Win32BaseWindow::GetWindow(UINT uCmd)
2481{
2482 HWND hwndRelated = 0;
2483 Win32BaseWindow *window;
2484
2485 switch(uCmd)
2486 {
2487 case GW_HWNDFIRST:
2488 if(getParent()) {
2489 window = (Win32BaseWindow *)getParent()->getFirstChild();
2490 hwndRelated = window->getWindowHandle();
2491 }
2492 break;
2493
2494 case GW_HWNDLAST:
2495 if(!getParent())
2496 {
2497 goto end;
2498 }
2499
2500 window = this;
2501 while(window->getNextChild())
2502 {
2503 window = (Win32BaseWindow *)window->getNextChild();
2504 }
2505 hwndRelated = window->getWindowHandle();
2506 break;
2507
2508 case GW_HWNDNEXT:
2509 window = (Win32BaseWindow *)getNextChild();
2510 if(window) {
2511 hwndRelated = window->getWindowHandle();
2512 }
2513 break;
2514
2515 case GW_HWNDPREV:
2516 if(!getParent())
2517 {
2518 goto end;
2519 }
2520 window = (Win32BaseWindow *)(getParent()->getFirstChild()); /* First sibling */
2521 if(window == this)
2522 {
2523 hwndRelated = 0; /* First in list */
2524 goto end;
2525 }
2526 while(window->getNextChild())
2527 {
2528 if (window->getNextChild() == this)
2529 {
2530 hwndRelated = window->getWindowHandle();
2531 goto end;
2532 }
2533 window = (Win32BaseWindow *)window->getNextChild();
2534 }
2535 break;
2536
2537 case GW_OWNER:
2538 if(getOwner()) {
2539 hwndRelated = getOwner()->getWindowHandle();
2540 }
2541 break;
2542
2543 case GW_CHILD:
2544 if(getFirstChild()) {
2545 hwndRelated = ((Win32BaseWindow *)getFirstChild())->getWindowHandle();
2546 }
2547 break;
2548 }
2549end:
2550 dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
2551 return hwndRelated;
2552}
2553//******************************************************************************
2554//******************************************************************************
2555HWND Win32BaseWindow::SetActiveWindow()
2556{
2557 HWND hwndActive;
2558 Win32BaseWindow *win32wnd;
2559 ULONG magic;
2560
2561 hwndActive = OSLibWinSetActiveWindow(OS2HwndFrame);
2562 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32WNDPTR);
2563 magic = OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32PM_MAGIC);
2564 if(CheckMagicDword(magic) && win32wnd)
2565 {
2566 return win32wnd->getWindowHandle();
2567 }
2568 return 0;
2569}
2570//******************************************************************************
2571//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
2572//******************************************************************************
2573BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
2574{
2575 return OSLibWinEnableWindow(OS2HwndFrame, fEnable);
2576}
2577//******************************************************************************
2578//******************************************************************************
2579BOOL Win32BaseWindow::CloseWindow()
2580{
2581 return OSLibWinMinimizeWindow(OS2HwndFrame);
2582}
2583//******************************************************************************
2584//******************************************************************************
2585HWND Win32BaseWindow::GetActiveWindow()
2586{
2587 HWND hwndActive;
2588 Win32BaseWindow *win32wnd;
2589 ULONG magic;
2590
2591 hwndActive = OSLibWinQueryActiveWindow();
2592
2593 return OS2ToWin32Handle(hwndActive);
2594}
2595//******************************************************************************
2596//******************************************************************************
2597BOOL Win32BaseWindow::IsWindowEnabled()
2598{
2599 return OSLibWinIsWindowEnabled(OS2HwndFrame);
2600}
2601//******************************************************************************
2602//******************************************************************************
2603BOOL Win32BaseWindow::IsWindowVisible()
2604{
2605#if 1
2606 return (dwStyle & WS_VISIBLE) == WS_VISIBLE;
2607#else
2608 return OSLibWinIsWindowVisible(OS2HwndFrame);
2609#endif
2610}
2611//******************************************************************************
2612//******************************************************************************
2613BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
2614{
2615 INT len = GetWindowTextLength();
2616 BOOL res;
2617
2618 if (wndname == NULL)
2619 return (len == 0);
2620
2621 len++;
2622 if (fUnicode)
2623 {
2624 WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR));
2625
2626 GetWindowTextW(text,len);
2627 res = (lstrcmpW(text,(LPWSTR)wndname) == 0);
2628 free(text);
2629 } else
2630 {
2631 CHAR *text = (CHAR*)malloc(len*sizeof(CHAR));
2632
2633 GetWindowTextA(text,len);
2634 res = (strcmp(text,wndname) == 0);
2635 free(text);
2636 }
2637
2638 return res;
2639}
2640//******************************************************************************
2641//******************************************************************************
2642CHAR *Win32BaseWindow::getWindowNamePtrA()
2643{
2644 INT len = GetWindowTextLength();
2645 CHAR *text;
2646
2647 if (len == 0) return NULL;
2648 len++;
2649 text = (CHAR*)malloc(len*sizeof(CHAR));
2650 GetWindowTextA(text,len);
2651
2652 return text;
2653}
2654//******************************************************************************
2655//******************************************************************************
2656WCHAR *Win32BaseWindow::getWindowNamePtrW()
2657{
2658 INT len = GetWindowTextLength();
2659 WCHAR *text;
2660
2661 if (len == 0) return NULL;
2662 len++;
2663 text = (WCHAR*)malloc(len*sizeof(WCHAR));
2664 GetWindowTextW(text,len);
2665
2666 return text;
2667}
2668//******************************************************************************
2669//******************************************************************************
2670VOID Win32BaseWindow::freeWindowNamePtr(PVOID namePtr)
2671{
2672 if (namePtr) free(namePtr);
2673}
2674//******************************************************************************
2675//******************************************************************************
2676int Win32BaseWindow::GetWindowTextLength()
2677{
2678 return SendInternalMessageA(WM_GETTEXTLENGTH,0,0);
2679}
2680//******************************************************************************
2681//******************************************************************************
2682int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
2683{
2684 return SendInternalMessageA(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
2685}
2686//******************************************************************************
2687//******************************************************************************
2688int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
2689{
2690 return SendInternalMessageW(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
2691}
2692//******************************************************************************
2693//******************************************************************************
2694BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
2695{
2696 return SendInternalMessageA(WM_SETTEXT,0,(LPARAM)lpsz);
2697}
2698//******************************************************************************
2699//******************************************************************************
2700BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
2701{
2702 return SendInternalMessageW(WM_SETTEXT,0,(LPARAM)lpsz);
2703}
2704//******************************************************************************
2705//******************************************************************************
2706VOID Win32BaseWindow::updateWindowStyle(DWORD oldExStyle,DWORD oldStyle)
2707{
2708 if(IsWindowDestroyed()) return;
2709
2710 //CB: todo: dwExStyle, creating new frame controls, destroy not used controls, WS_VISIBLE, WS_CHILD, ...
2711 // write test cases
2712 if ((dwStyle & 0xFFFF0000) != (oldStyle & 0xFFFF0000))
2713 {
2714 //dprintf(("updateWindowStyle: %x %x",oldStyle,dwStyle));
2715 OSLibSetWindowStyle(OS2HwndFrame, dwStyle, fTaskList);
2716 }
2717}
2718//******************************************************************************
2719//******************************************************************************
2720LONG Win32BaseWindow::SetWindowLongA(int index, ULONG value, BOOL fUnicode)
2721{
2722 LONG oldval;
2723
2724 dprintf2(("SetWindowLong%c %x %d %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
2725 switch(index) {
2726 case GWL_EXSTYLE:
2727 {
2728 STYLESTRUCT ss;
2729
2730 if(dwExStyle == value)
2731 return value;
2732
2733 ss.styleOld = dwExStyle;
2734 ss.styleNew = value;
2735 dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
2736 SendInternalMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
2737 setExStyle(ss.styleNew);
2738 updateWindowStyle(ss.styleOld,getStyle());
2739 SendInternalMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
2740 return ss.styleOld;
2741 }
2742 case GWL_STYLE:
2743 {
2744 STYLESTRUCT ss;
2745
2746 if(dwStyle == value)
2747 return value;
2748
2749 value &= ~(WS_VISIBLE | WS_CHILD); /* Some bits can't be changed this way (WINE) */
2750 ss.styleOld = getStyle();
2751 ss.styleNew = value | (ss.styleOld & (WS_VISIBLE | WS_CHILD));
2752 dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), ss.styleOld, ss.styleNew));
2753 SendInternalMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
2754 setStyle(ss.styleNew);
2755 updateWindowStyle(dwExStyle,ss.styleOld);
2756 SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
2757#ifdef DEBUG
2758 PrintWindowStyle(ss.styleNew, 0);
2759#endif
2760 return ss.styleOld;
2761 }
2762 case GWL_WNDPROC:
2763 oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
2764 //WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A, WIN_PROC_WINDOW);
2765 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, WINPROC_GetProcType(win32wndproc), WIN_PROC_WINDOW);
2766 return oldval;
2767 case GWL_HINSTANCE:
2768 oldval = hInstance;
2769 hInstance = value;
2770 return oldval;
2771 case GWL_HWNDPARENT:
2772 return SetParent((HWND)value);
2773 case GWL_ID:
2774 oldval = getWindowId();
2775 setWindowId(value);
2776 return oldval;
2777 case GWL_USERDATA:
2778 oldval = userData;
2779 userData = value;
2780 return oldval;
2781 default:
2782 if(index >= 0 && index/4 < nrUserWindowLong)
2783 {
2784 oldval = userWindowLong[index/4];
2785 userWindowLong[index/4] = value;
2786 return oldval;
2787 }
2788 SetLastError(ERROR_INVALID_PARAMETER);
2789 return 0;
2790 }
2791}
2792//******************************************************************************
2793//******************************************************************************
2794ULONG Win32BaseWindow::GetWindowLongA(int index, BOOL fUnicode)
2795{
2796 ULONG value;
2797
2798 switch(index) {
2799 case GWL_EXSTYLE:
2800 value = dwExStyle;
2801 break;
2802 case GWL_STYLE:
2803 value = dwStyle;
2804 break;
2805 case GWL_WNDPROC:
2806 value = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
2807 break;
2808 case GWL_HINSTANCE:
2809 value = hInstance;
2810 break;
2811 case GWL_HWNDPARENT:
2812 if(getParent()) {
2813 value = getParent()->getWindowHandle();
2814 }
2815 else value = 0;
2816 break;
2817 case GWL_ID:
2818 value = getWindowId();
2819 break;
2820 case GWL_USERDATA:
2821 value = userData;
2822 break;
2823 default:
2824 if(index >= 0 && index/4 < nrUserWindowLong)
2825 {
2826 value = userWindowLong[index/4];
2827 break;
2828 }
2829 SetLastError(ERROR_INVALID_PARAMETER);
2830 return 0;
2831 }
2832 dprintf2(("GetWindowLongA %x %d %x", getWindowHandle(), index, value));
2833 return value;
2834}
2835//******************************************************************************
2836//******************************************************************************
2837WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
2838{
2839 WORD oldval;
2840
2841 if(index >= 0 && index/4 < nrUserWindowLong)
2842 {
2843 oldval = ((WORD *)userWindowLong)[index/2];
2844 ((WORD *)userWindowLong)[index/2] = value;
2845 return oldval;
2846 }
2847 SetLastError(ERROR_INVALID_PARAMETER);
2848 return 0;
2849}
2850//******************************************************************************
2851//******************************************************************************
2852WORD Win32BaseWindow::GetWindowWord(int index)
2853{
2854 if(index >= 0 && index/4 < nrUserWindowLong)
2855 {
2856 return ((WORD *)userWindowLong)[index/2];
2857 }
2858 SetLastError(ERROR_INVALID_PARAMETER);
2859 return 0;
2860}
2861//******************************************************************************
2862//******************************************************************************
2863void Win32BaseWindow::setWindowId(DWORD id)
2864{
2865 windowId = id;
2866 dprintf(("Set window ID to %x", id));
2867 OSLibSetWindowID(OS2HwndFrame, id);
2868}
2869//******************************************************************************
2870//******************************************************************************
2871Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
2872{
2873 Win32BaseWindow *window;
2874
2875 if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
2876 return window;
2877 }
2878// dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
2879 return NULL;
2880}
2881//******************************************************************************
2882//******************************************************************************
2883Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd)
2884{
2885 Win32BaseWindow *win32wnd;
2886 DWORD magic;
2887
2888 if(hwnd == OSLIB_HWND_DESKTOP)
2889 {
2890 return windowDesktop;
2891 }
2892
2893 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
2894 magic = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
2895
2896 if(win32wnd && CheckMagicDword(magic)) {
2897 return win32wnd;
2898 }
2899// dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwnd));
2900 return 0;
2901}
2902//******************************************************************************
2903//******************************************************************************
2904Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
2905{
2906 return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
2907}
2908//******************************************************************************
2909//******************************************************************************
2910HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd)
2911{
2912 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
2913
2914 if(window) {
2915 return window->getOS2WindowHandle();
2916 }
2917// dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
2918 return hwnd;
2919}
2920//******************************************************************************
2921//******************************************************************************
2922HWND Win32BaseWindow::Win32ToOS2FrameHandle(HWND hwnd)
2923{
2924 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
2925
2926 if(window) {
2927 return window->getOS2FrameWindowHandle();
2928 }
2929// dprintf2(("Win32BaseWindow::Win32ToOS2FrameHandle: not a win32 window %x", hwnd));
2930 return hwnd;
2931}
2932//******************************************************************************
2933//******************************************************************************
2934HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd)
2935{
2936 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
2937
2938 if(window) {
2939 return window->getWindowHandle();
2940 }
2941 window = GetWindowFromOS2FrameHandle(hwnd);
2942 if(window) {
2943 return window->getWindowHandle();
2944 }
2945// dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
2946 return 0;
2947// else return hwnd; //OS/2 window handle
2948}
2949//******************************************************************************
2950// GetNextDlgTabItem32 (USER32.276)
2951//******************************************************************************
2952HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
2953{
2954 Win32BaseWindow *child, *nextchild, *lastchild;
2955 HWND retvalue;
2956
2957 if (hwndCtrl)
2958 {
2959 child = GetWindowFromHandle(hwndCtrl);
2960 if (!child)
2961 {
2962 retvalue = 0;
2963 goto END;
2964 }
2965 /* Make sure hwndCtrl is a top-level child */
2966 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
2967 {
2968 child = child->getParent();
2969 if(child == NULL) break;
2970 }
2971
2972 if (!child || (child->getParent() != this))
2973 {
2974 retvalue = 0;
2975 goto END;
2976 }
2977 }
2978 else
2979 {
2980 /* No ctrl specified -> start from the beginning */
2981 child = (Win32BaseWindow *)getFirstChild();
2982 if (!child)
2983 {
2984 retvalue = 0;
2985 goto END;
2986 }
2987
2988 if (!fPrevious)
2989 {
2990 while (child->getNextChild())
2991 {
2992 child = (Win32BaseWindow *)child->getNextChild();
2993 }
2994 }
2995 }
2996
2997 lastchild = child;
2998 nextchild = (Win32BaseWindow *)child->getNextChild();
2999 while (TRUE)
3000 {
3001 if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild();
3002
3003 if (child == nextchild) break;
3004
3005 if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) &&
3006 !(nextchild->getStyle() & WS_DISABLED))
3007 {
3008 lastchild = nextchild;
3009 if (!fPrevious) break;
3010 }
3011 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
3012 }
3013 retvalue = lastchild->getWindowHandle();
3014
3015END:
3016 return retvalue;
3017}
3018//******************************************************************************
3019//******************************************************************************
3020HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
3021{
3022 Win32BaseWindow *child, *nextchild, *lastchild;
3023 HWND retvalue;
3024
3025 if (hwndCtrl)
3026 {
3027 child = GetWindowFromHandle(hwndCtrl);
3028 if (!child)
3029 {
3030 retvalue = 0;
3031 goto END;
3032 }
3033 /* Make sure hwndCtrl is a top-level child */
3034 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
3035 {
3036 child = child->getParent();
3037 if(child == NULL) break;
3038 }
3039
3040 if (!child || (child->getParent() != this))
3041 {
3042 retvalue = 0;
3043 goto END;
3044 }
3045 }
3046 else
3047 {
3048 /* No ctrl specified -> start from the beginning */
3049 child = (Win32BaseWindow *)getFirstChild();
3050 if (!child)
3051 {
3052 retvalue = 0;
3053 goto END;
3054 }
3055
3056 if (fPrevious)
3057 {
3058 while (child->getNextChild())
3059 {
3060 child = (Win32BaseWindow *)child->getNextChild();
3061 }
3062 }
3063 }
3064
3065 lastchild = child;
3066 nextchild = (Win32BaseWindow *)child->getNextChild();
3067 while (TRUE)
3068 {
3069 if (!nextchild || (nextchild->getStyle() & WS_GROUP))
3070 {
3071 /* Wrap-around to the beginning of the group */
3072 Win32BaseWindow *pWndTemp;
3073
3074 nextchild = (Win32BaseWindow *)getFirstChild();
3075
3076 for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild())
3077 {
3078 if (pWndTemp->getStyle() & WS_GROUP)
3079 nextchild = pWndTemp;
3080
3081 if (pWndTemp == child)
3082 break;
3083 }
3084
3085 }
3086 if (nextchild == child)
3087 break;
3088
3089 if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED))
3090 {
3091 lastchild = nextchild;
3092
3093 if (!fPrevious)
3094 break;
3095 }
3096
3097 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
3098 }
3099 retvalue = lastchild->getWindowHandle();
3100END:
3101 return retvalue;
3102}
3103//******************************************************************************
3104//******************************************************************************
3105#ifdef DEBUG
3106void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
3107{
3108 char style[256] = "";
3109 char exstyle[256] = "";
3110
3111 /* Window styles */
3112 if(dwStyle & WS_CHILD)
3113 strcat(style, "WS_CHILD ");
3114 if(dwStyle & WS_POPUP)
3115 strcat(style, "WS_POPUP ");
3116 if(dwStyle & WS_VISIBLE)
3117 strcat(style, "WS_VISIBLE ");
3118 if(dwStyle & WS_DISABLED)
3119 strcat(style, "WS_DISABLED ");
3120 if(dwStyle & WS_CLIPSIBLINGS)
3121 strcat(style, "WS_CLIPSIBLINGS ");
3122 if(dwStyle & WS_CLIPCHILDREN)
3123 strcat(style, "WS_CLIPCHILDREN ");
3124 if(dwStyle & WS_MAXIMIZE)
3125 strcat(style, "WS_MAXIMIZE ");
3126 if(dwStyle & WS_MINIMIZE)
3127 strcat(style, "WS_MINIMIZE ");
3128 if(dwStyle & WS_GROUP)
3129 strcat(style, "WS_GROUP ");
3130 if(dwStyle & WS_TABSTOP)
3131 strcat(style, "WS_TABSTOP ");
3132
3133 if((dwStyle & WS_CAPTION) == WS_CAPTION)
3134 strcat(style, "WS_CAPTION ");
3135 if(dwStyle & WS_DLGFRAME)
3136 strcat(style, "WS_DLGFRAME ");
3137 if(dwStyle & WS_BORDER)
3138 strcat(style, "WS_BORDER ");
3139
3140 if(dwStyle & WS_VSCROLL)
3141 strcat(style, "WS_VSCROLL ");
3142 if(dwStyle & WS_HSCROLL)
3143 strcat(style, "WS_HSCROLL ");
3144 if(dwStyle & WS_SYSMENU)
3145 strcat(style, "WS_SYSMENU ");
3146 if(dwStyle & WS_THICKFRAME)
3147 strcat(style, "WS_THICKFRAME ");
3148 if(dwStyle & WS_MINIMIZEBOX)
3149 strcat(style, "WS_MINIMIZEBOX ");
3150 if(dwStyle & WS_MAXIMIZEBOX)
3151 strcat(style, "WS_MAXIMIZEBOX ");
3152
3153 if(dwExStyle & WS_EX_DLGMODALFRAME)
3154 strcat(exstyle, "WS_EX_DLGMODALFRAME ");
3155 if(dwExStyle & WS_EX_ACCEPTFILES)
3156 strcat(exstyle, "WS_EX_ACCEPTFILES ");
3157 if(dwExStyle & WS_EX_NOPARENTNOTIFY)
3158 strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
3159 if(dwExStyle & WS_EX_TOPMOST)
3160 strcat(exstyle, "WS_EX_TOPMOST ");
3161 if(dwExStyle & WS_EX_TRANSPARENT)
3162 strcat(exstyle, "WS_EX_TRANSPARENT ");
3163
3164 if(dwExStyle & WS_EX_MDICHILD)
3165 strcat(exstyle, "WS_EX_MDICHILD ");
3166 if(dwExStyle & WS_EX_TOOLWINDOW)
3167 strcat(exstyle, "WS_EX_TOOLWINDOW ");
3168 if(dwExStyle & WS_EX_WINDOWEDGE)
3169 strcat(exstyle, "WS_EX_WINDOWEDGE ");
3170 if(dwExStyle & WS_EX_CLIENTEDGE)
3171 strcat(exstyle, "WS_EX_CLIENTEDGE ");
3172 if(dwExStyle & WS_EX_CONTEXTHELP)
3173 strcat(exstyle, "WS_EX_CONTEXTHELP ");
3174 if(dwExStyle & WS_EX_RIGHT)
3175 strcat(exstyle, "WS_EX_RIGHT ");
3176 if(dwExStyle & WS_EX_LEFT)
3177 strcat(exstyle, "WS_EX_LEFT ");
3178 if(dwExStyle & WS_EX_RTLREADING)
3179 strcat(exstyle, "WS_EX_RTLREADING ");
3180 if(dwExStyle & WS_EX_LTRREADING)
3181 strcat(exstyle, "WS_EX_LTRREADING ");
3182 if(dwExStyle & WS_EX_LEFTSCROLLBAR)
3183 strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
3184 if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
3185 strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
3186 if(dwExStyle & WS_EX_CONTROLPARENT)
3187 strcat(exstyle, "WS_EX_CONTROLPARENT ");
3188 if(dwExStyle & WS_EX_STATICEDGE)
3189 strcat(exstyle, "WS_EX_STATICEDGE ");
3190 if(dwExStyle & WS_EX_APPWINDOW)
3191 strcat(exstyle, "WS_EX_APPWINDOW ");
3192
3193 dprintf(("Window style: %x %s", dwStyle, style));
3194 dprintf(("Window exStyle: %x %s (FS = %x)", dwExStyle, exstyle, GetFS()));
3195}
3196#endif
3197//******************************************************************************
3198//******************************************************************************
3199
3200GenericObject *Win32BaseWindow::windows = NULL;
Note: See TracBrowser for help on using the repository browser.