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

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

final window text fixes

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