source: trunk/src/user32/win32wbase.cpp@ 1525

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

button, static, scroll and dialog fixes

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