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

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

wm_activate fixes, scrollbar fix, drawframe fix

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