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

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

* empty log message *

File size: 105.6 KB
Line 
1/* $Id: win32wbase.cpp,v 1.91 1999-11-22 18:06:46 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 = 1; //CB: right?
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 windowNameA = (LPSTR)_smalloc(strlen(cs->lpszName)+1);
524 strcpy(windowNameA,cs->lpszName);
525 windowNameW = (LPWSTR)_smalloc((strlen(cs->lpszName)+1)*sizeof(WCHAR));
526 lstrcpyAtoW(windowNameW,windowNameA);
527 wndNameLength = strlen(windowNameA)+1; //including 0 terminator
528 } else
529 {
530 windowNameA = (LPSTR)_smalloc(lstrlenW((LPWSTR)cs->lpszName)+1);
531 lstrcpyWtoA(windowNameA,(LPWSTR)cs->lpszName);
532 windowNameW = (LPWSTR)_smalloc((lstrlenW((LPWSTR)cs->lpszName)+1)*sizeof(WCHAR));
533 lstrcpyW(windowNameW,(LPWSTR)cs->lpszName);
534 wndNameLength = strlen(windowNameA)+1; //including 0 terminator
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) return 0;
1514 strncpy((LPSTR)lParam, windowNameA, wParam);
1515 return min(wndNameLength, wParam);
1516
1517 case WM_SETTEXT:
1518 {
1519 LPCSTR lpsz = (LPCSTR)lParam;
1520
1521 if(windowNameA) free(windowNameA);
1522 if(windowNameW) free(windowNameW);
1523
1524 if (lParam)
1525 {
1526 windowNameA = (LPSTR)_smalloc(strlen(lpsz)+1);
1527 strcpy(windowNameA, lpsz);
1528 windowNameW = (LPWSTR)_smalloc((strlen(lpsz)+1)*sizeof(WCHAR));
1529 lstrcpyAtoW(windowNameW, windowNameA);
1530 wndNameLength = strlen(windowNameA)+1; //including 0 terminator
1531 dprintf(("WM_SETTEXT of %d to %s\n", Win32Hwnd, lParam));
1532 } else
1533 {
1534 windowNameA = NULL;
1535 windowNameW = NULL;
1536 wndNameLength = 1;
1537 }
1538
1539 if(OS2HwndFrame && (dwStyle & WS_CAPTION) == WS_CAPTION)
1540 return OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
1541
1542 return TRUE;
1543 }
1544
1545 case WM_SETREDRAW:
1546 if(wParam)
1547 SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) | WS_VISIBLE);
1548 else SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE);
1549
1550 return 0; //TODO
1551
1552 case WM_NCCREATE:
1553 return(TRUE);
1554
1555 case WM_NCCALCSIZE:
1556 return NCHandleCalcSize(wParam, (NCCALCSIZE_PARAMS *)lParam);
1557
1558 case WM_CTLCOLORMSGBOX:
1559 case WM_CTLCOLOREDIT:
1560 case WM_CTLCOLORLISTBOX:
1561 case WM_CTLCOLORBTN:
1562 case WM_CTLCOLORDLG:
1563 case WM_CTLCOLORSTATIC:
1564 case WM_CTLCOLORSCROLLBAR:
1565 return DefWndControlColor(Msg - WM_CTLCOLORMSGBOX, (HDC)wParam);
1566
1567 case WM_CTLCOLOR:
1568 return DefWndControlColor(HIWORD(lParam), (HDC)wParam);
1569
1570 case WM_VKEYTOITEM:
1571 case WM_CHARTOITEM:
1572 return -1;
1573
1574 case WM_PARENTNOTIFY:
1575 return 0;
1576
1577 case WM_MOUSEACTIVATE:
1578 {
1579 dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
1580 if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
1581 {
1582 if(getParent()) {
1583 LRESULT rc = getParent()->SendMessageA(WM_MOUSEACTIVATE, wParam, lParam );
1584 if(rc) return rc;
1585 }
1586 }
1587 return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
1588 }
1589 case WM_SETCURSOR:
1590 {
1591 dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
1592 if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
1593 {
1594 if(getParent()) {
1595 LRESULT rc = getParent()->SendMessageA(WM_SETCURSOR, wParam, lParam);
1596 if(rc) return rc;
1597 }
1598 }
1599 if (wParam == Win32Hwnd)
1600 {
1601 HCURSOR hCursor = windowClass ? windowClass->getCursor():LoadCursorA(0,IDC_ARROWA);
1602
1603 if (hCursor) SetCursor(hCursor);
1604 return 1;
1605 } else return 0;
1606 }
1607 case WM_MOUSEMOVE:
1608 return 0; //we do our own cursor handling
1609
1610 case WM_WINDOWPOSCHANGED:
1611 {
1612
1613/* undocumented SWP flags - from SDK 3.1 */
1614#define SWP_NOCLIENTSIZE 0x0800
1615#define SWP_NOCLIENTMOVE 0x1000
1616
1617 PWINDOWPOS wpos = (PWINDOWPOS)lParam;
1618 WPARAM wp = SIZE_RESTORED;
1619
1620 if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE))
1621 SendMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
1622
1623 if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE))
1624 {
1625 if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
1626 else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
1627
1628 SendMessageA(WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left,
1629 rectClient.bottom - rectClient.top));
1630 }
1631 return 0;
1632 }
1633 case WM_WINDOWPOSCHANGING:
1634 return HandleWindowPosChanging((WINDOWPOS *)lParam);
1635
1636 case WM_ERASEBKGND:
1637 case WM_ICONERASEBKGND:
1638 {
1639 RECT rect;
1640 int rc;
1641
1642 if (!windowClass || !windowClass->getBackgroundBrush()) return 0;
1643
1644 rc = GetClipBox( (HDC)wParam, &rect );
1645 if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
1646 FillRect( (HDC)wParam, &rect, windowClass->getBackgroundBrush());
1647
1648 return 1;
1649 }
1650 case WM_GETDLGCODE:
1651 return 0;
1652
1653 case WM_NCLBUTTONDOWN:
1654 case WM_NCLBUTTONUP:
1655 case WM_NCLBUTTONDBLCLK:
1656 case WM_NCRBUTTONUP:
1657 case WM_NCRBUTTONDOWN:
1658 case WM_NCRBUTTONDBLCLK:
1659 case WM_NCMBUTTONDOWN:
1660 case WM_NCMBUTTONUP:
1661 case WM_NCMBUTTONDBLCLK:
1662 return 0; //TODO: Send WM_SYSCOMMAND if required
1663
1664 case WM_NCHITTEST: //TODO: Calculate position of
1665 return HTCLIENT;
1666
1667 case WM_SYSCOMMAND:
1668 {
1669 POINT point;
1670
1671 point.x = LOWORD(lParam);
1672 point.y = HIWORD(lParam);
1673 return HandleSysCommand(wParam, &point);
1674 }
1675
1676 case WM_SYSKEYDOWN:
1677 if(wParam == VK_F4) /* try to close the window */
1678 {
1679 Win32BaseWindow *window = GetTopParent();
1680 if(window && !(window->getClass()->getStyle() & CS_NOCLOSE))
1681 window->PostMessageA(WM_SYSCOMMAND, SC_CLOSE, 0);
1682 }
1683
1684 Win32BaseWindow *siblingWindow;
1685 HWND sibling;
1686 char nameBuffer [40], mnemonic;
1687 int nameLength;
1688
1689 GetWindowTextA (nameBuffer, 40);
1690
1691 // search all sibling to see it this key is their mnemonic
1692 sibling = GetWindow (GW_HWNDFIRST);
1693 while (sibling != 0) {
1694 siblingWindow = GetWindowFromHandle (sibling);
1695 nameLength = siblingWindow->GetWindowTextA (nameBuffer, 40);
1696
1697 // find the siblings mnemonic
1698 mnemonic = '\0';
1699 for (int i=0 ; i<nameLength ; i++) {
1700 if (nameBuffer [i] == '&') {
1701 mnemonic = nameBuffer [i+1];
1702 if ((mnemonic >= 'a') && (mnemonic <= 'z'))
1703 mnemonic -= 32; // make it uppercase
1704 break; // stop searching
1705 }
1706 }
1707
1708 // key matches siblings mnemonic, send mouseclick
1709 if (mnemonic == (char) wParam) {
1710 siblingWindow->SendMessageA (BM_CLICK, 0, 0);
1711 }
1712
1713 sibling = siblingWindow->GetNextWindow (GW_HWNDNEXT);
1714 }
1715
1716 return 0;
1717
1718 case WM_QUERYOPEN:
1719 case WM_QUERYENDSESSION:
1720 return 1;
1721
1722 case WM_NOTIFYFORMAT:
1723 if (IsUnicode()) return NFR_UNICODE;
1724 else return NFR_ANSI;
1725
1726 case WM_SETICON:
1727 case WM_GETICON:
1728 {
1729 LRESULT result = 0;
1730 if (!windowClass) return result;
1731 int index = GCL_HICON;
1732
1733 if (wParam == ICON_SMALL)
1734 index = GCL_HICONSM;
1735
1736 result = windowClass->getClassLongA(index);
1737
1738 if (Msg == WM_SETICON)
1739 windowClass->setClassLongA(index, lParam);
1740
1741 return result;
1742 }
1743 case WM_NOTIFY:
1744 return 0; //comctl32 controls expect this
1745
1746 default:
1747 if(Msg > WM_USER) {
1748 return 0;
1749 }
1750 return 1;
1751 }
1752}
1753//******************************************************************************
1754//******************************************************************************
1755LRESULT Win32BaseWindow::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam)
1756{
1757 switch(Msg)
1758 {
1759 case WM_GETTEXTLENGTH:
1760 return wndNameLength;
1761
1762 case WM_GETTEXT:
1763 if (!lParam) return 0;
1764 lstrcpynW((LPWSTR)lParam,windowNameW,wParam);
1765 return min(wndNameLength,wParam);
1766
1767 case WM_SETTEXT:
1768 {
1769 LPWSTR lpsz = (LPWSTR)lParam;
1770
1771 if(windowNameA) free(windowNameA);
1772 if(windowNameW) free(windowNameW);
1773
1774 if (lParam)
1775 {
1776 windowNameA = (LPSTR)_smalloc(lstrlenW(lpsz)+1);
1777 lstrcpyWtoA(windowNameA,lpsz);
1778 windowNameW = (LPWSTR)_smalloc((lstrlenW(lpsz)+1)*sizeof(WCHAR));
1779 lstrcpyW(windowNameW,lpsz);
1780 wndNameLength = strlen(windowNameA)+1; //including 0 terminator
1781 } else
1782 {
1783 windowNameA = NULL;
1784 windowNameW = NULL;
1785 wndNameLength = 1;
1786 }
1787
1788 if(OS2HwndFrame && (dwStyle & WS_CAPTION) == WS_CAPTION)
1789 return OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
1790
1791 return TRUE;
1792 }
1793
1794 default:
1795 return DefWindowProcA(Msg, wParam, lParam);
1796 }
1797}
1798//******************************************************************************
1799//******************************************************************************
1800LRESULT Win32BaseWindow::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
1801{
1802 LRESULT rc;
1803 BOOL fInternalMsgBackup = fInternalMsg;
1804
1805 //SvL: Some Wine controls send WM_COMMAND messages when they receive the focus -> apps don't like to
1806 // receive those before they get their WM_CREATE message
1807 //NOTE: May need to refuse more messages
1808 if(fCreated == FALSE && Msg == WM_COMMAND) {
1809 dprintf(("SendMessageA BEFORE creation! %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
1810 return 0;
1811 }
1812
1813 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, FALSE);
1814
1815 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
1816 return(0);
1817 }
1818 fInternalMsg = FALSE;
1819 switch(Msg)
1820 {
1821 case WM_CREATE:
1822 {
1823 if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1824 dprintf(("WM_CREATE returned -1\n"));
1825 rc = -1; //don't create window
1826 break;
1827 }
1828 NotifyParent(Msg, wParam, lParam);
1829
1830 rc = 0;
1831 break;
1832 }
1833 case WM_SETTEXT:
1834 rc = CallWindowProcA(win32wndproc, getWindowHandle(), WM_SETTEXT, wParam, lParam);
1835 break;
1836
1837 case WM_LBUTTONDOWN:
1838 case WM_MBUTTONDOWN:
1839 case WM_RBUTTONDOWN:
1840 NotifyParent(Msg, wParam, lParam);
1841 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1842 break;
1843
1844 case WM_DESTROY:
1845 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
1846 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1847 break;
1848
1849 default:
1850 rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
1851 break;
1852 }
1853 fInternalMsg = fInternalMsgBackup;
1854 return rc;
1855}
1856//******************************************************************************
1857//******************************************************************************
1858LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
1859{
1860 LRESULT rc;
1861 BOOL fInternalMsgBackup = fInternalMsg;
1862
1863 //SvL: Some Wine controls send WM_COMMAND messages when they receive the focus -> apps don't like to
1864 // receive those before they get their WM_CREATE message
1865 //NOTE: May need to refuse more messages
1866 if(fCreated == FALSE && Msg == WM_COMMAND) {
1867 dprintf(("SendMessageA BEFORE creation! %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
1868 return 0;
1869 }
1870
1871 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, FALSE);
1872
1873 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
1874 return(0);
1875 }
1876 fInternalMsg = FALSE;
1877 switch(Msg)
1878 {
1879 case WM_CREATE:
1880 {
1881 if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1882 dprintf(("WM_CREATE returned -1\n"));
1883 rc = -1; //don't create window
1884 break;
1885 }
1886 NotifyParent(Msg, wParam, lParam);
1887
1888 rc = 0;
1889 break;
1890 }
1891 case WM_SETTEXT:
1892 rc = CallWindowProcW(win32wndproc, getWindowHandle(), WM_SETTEXT, wParam, lParam);
1893 break;
1894
1895 case WM_LBUTTONDOWN:
1896 case WM_MBUTTONDOWN:
1897 case WM_RBUTTONDOWN:
1898 NotifyParent(Msg, wParam, lParam);
1899 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1900 break;
1901
1902 case WM_DESTROY:
1903 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
1904 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1905 break;
1906
1907 default:
1908 rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
1909 break;
1910 }
1911 fInternalMsg = fInternalMsgBackup;
1912 return rc;
1913}
1914//******************************************************************************
1915//Called as a result of an OS/2 message
1916//******************************************************************************
1917LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
1918{
1919 LRESULT rc;
1920 BOOL fInternalMsgBackup = fInternalMsg;
1921
1922 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE);
1923
1924 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
1925 return(0);
1926 }
1927 fInternalMsg = TRUE;
1928 switch(Msg)
1929 {
1930 case WM_CREATE:
1931 {
1932 if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1933 dprintf(("WM_CREATE returned -1\n"));
1934 rc = -1; //don't create window
1935 break;
1936 }
1937 NotifyParent(Msg, wParam, lParam);
1938 rc = 0;
1939 break;
1940 }
1941 case WM_LBUTTONDOWN:
1942 case WM_MBUTTONDOWN:
1943 case WM_RBUTTONDOWN:
1944 NotifyParent(Msg, wParam, lParam);
1945 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1946 break;
1947
1948 case WM_DESTROY:
1949 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
1950 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1951 break;
1952
1953 default:
1954 rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
1955 break;
1956 }
1957 fInternalMsg = fInternalMsgBackup;
1958 return rc;
1959}
1960//******************************************************************************
1961//Called as a result of an OS/2 message
1962//todo, unicode msgs (WM_SETTEXT etc)
1963//******************************************************************************
1964LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
1965{
1966 LRESULT rc;
1967 BOOL fInternalMsgBackup = fInternalMsg;
1968
1969 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE);
1970
1971 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
1972 return(0);
1973 }
1974 fInternalMsg = TRUE;
1975 switch(Msg)
1976 {
1977 case WM_CREATE:
1978 {
1979 if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1980 dprintf(("WM_CREATE returned -1\n"));
1981 rc = -1; //don't create window
1982 break;
1983 }
1984 NotifyParent(Msg, wParam, lParam);
1985 rc = 0;
1986 break;
1987 }
1988 case WM_LBUTTONDOWN:
1989 case WM_MBUTTONDOWN:
1990 case WM_RBUTTONDOWN:
1991 NotifyParent(Msg, wParam, lParam);
1992 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1993 break;
1994
1995 case WM_DESTROY:
1996 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
1997 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1998 break;
1999 default:
2000 rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
2001 break;
2002 }
2003 fInternalMsg = fInternalMsgBackup;
2004 return rc;
2005}
2006//******************************************************************************
2007//******************************************************************************
2008BOOL Win32BaseWindow::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam)
2009{
2010 return OSLibPostMessage(OS2Hwnd, WIN32APP_USERMSGBASE+msg, wParam, lParam);
2011}
2012//******************************************************************************
2013//******************************************************************************
2014BOOL Win32BaseWindow::PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam)
2015{
2016 return OSLibPostMessage(OS2Hwnd, WIN32APP_USERMSGBASE+msg, wParam, lParam);
2017}
2018//******************************************************************************
2019//TODO: do we need to inform the parent of the parent (etc) of the child window?
2020//******************************************************************************
2021void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
2022{
2023 Win32BaseWindow *window = this;
2024 Win32BaseWindow *parentwindow;
2025
2026 while(window)
2027 {
2028 if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
2029 {
2030 /* Notify the parent window only */
2031 parentwindow = window->getParent();
2032 if(parentwindow) {
2033 if(Msg == WM_CREATE || Msg == WM_DESTROY) {
2034 parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle());
2035 }
2036 else parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );
2037 }
2038 }
2039 else break;
2040
2041 window = parentwindow;
2042 }
2043}
2044//******************************************************************************
2045//******************************************************************************
2046BOOL Win32BaseWindow::SetMenu(HMENU hMenu)
2047{
2048
2049 dprintf(("SetMenu %x", hMenu));
2050 OS2HwndMenu = OSLibWinSetMenu(OS2HwndFrame, hMenu);
2051 if(OS2HwndMenu == 0) {
2052 dprintf(("Win32BaseWindow::SetMenu OS2HwndMenu == 0"));
2053 return FALSE;
2054 }
2055 return TRUE;
2056}
2057//******************************************************************************
2058//******************************************************************************
2059BOOL Win32BaseWindow::SetAccelTable(HACCEL hAccel)
2060{
2061 Win32Resource *winres = (Win32Resource *)hAccel;
2062 HANDLE accelhandle;
2063
2064 if(HIWORD(hAccel) == 0) {
2065 dprintf(("SetAccelTable: hAccel %x invalid", hAccel));
2066 SetLastError(ERROR_INVALID_PARAMETER);
2067 return FALSE;
2068 }
2069 acceltableResource = winres;
2070 accelhandle = OSLibWinSetAccelTable(OS2HwndFrame, winres->getOS2Handle(), winres->lockOS2Resource());
2071 winres->setOS2Handle(accelhandle);
2072 return(accelhandle != 0);
2073}
2074//******************************************************************************
2075//******************************************************************************
2076BOOL Win32BaseWindow::SetIcon(HICON hIcon)
2077{
2078 dprintf(("Win32BaseWindow::SetIcon %x", hIcon));
2079 if(OSLibWinSetIcon(OS2HwndFrame, hIcon) == TRUE) {
2080//TODO: Wine does't send these. Correct?
2081// SendMessageA(WM_SETICON, ICON_BIG, hIcon);
2082 return TRUE;
2083 }
2084 return FALSE;
2085}
2086//******************************************************************************
2087//******************************************************************************
2088BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow)
2089{
2090 ULONG showstate = 0;
2091 HWND hWinAfter;
2092
2093 dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
2094#if 1
2095 if (flags & WIN_NEED_SIZE)
2096 {
2097 /* should happen only in CreateWindowEx() */
2098 int wParam = SIZE_RESTORED;
2099
2100 flags &= ~WIN_NEED_SIZE;
2101 if (dwStyle & WS_MAXIMIZE)
2102 wParam = SIZE_MAXIMIZED;
2103 else
2104 if (dwStyle & WS_MINIMIZE)
2105 wParam = SIZE_MINIMIZED;
2106
2107 SendMessageA(WM_SIZE, wParam,
2108 MAKELONG(rectClient.right-rectClient.left,
2109 rectClient.bottom-rectClient.top));
2110 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
2111 }
2112#else
2113 if(fFirstShow) {
2114 if(isFrameWindow() && IS_OVERLAPPED(getStyle()) && !isChild()) {
2115 SendMessageA(WM_SIZE, SIZE_RESTORED,
2116 MAKELONG(rectClient.right-rectClient.left,
2117 rectClient.bottom-rectClient.top));
2118 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
2119
2120 }
2121 fFirstShow = FALSE;
2122 }
2123#endif
2124 switch(nCmdShow)
2125 {
2126 case SW_SHOW:
2127 case SW_SHOWDEFAULT: //todo
2128 showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
2129 break;
2130 case SW_HIDE:
2131 showstate = SWPOS_HIDE;
2132 break;
2133 case SW_RESTORE:
2134 showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
2135 break;
2136 case SW_MINIMIZE:
2137 showstate = SWPOS_MINIMIZE;
2138 break;
2139 case SW_SHOWMAXIMIZED:
2140 showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
2141 break;
2142 case SW_SHOWMINIMIZED:
2143 showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
2144 break;
2145 case SW_SHOWMINNOACTIVE:
2146 showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
2147 break;
2148 case SW_SHOWNA:
2149 showstate = SWPOS_SHOW;
2150 break;
2151 case SW_SHOWNOACTIVATE:
2152 showstate = SWPOS_SHOW;
2153 break;
2154 case SW_SHOWNORMAL:
2155 showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
2156 break;
2157 }
2158
2159 /* We can't activate a child window (WINE) */
2160 if(getStyle() & WS_CHILD)
2161 showstate &= ~SWPOS_ACTIVATE;
2162
2163 if(showstate & SWPOS_SHOW) {
2164 setStyle(getStyle() | WS_VISIBLE);
2165 }
2166 else setStyle(getStyle() & ~WS_VISIBLE);
2167
2168 BOOL rc = OSLibWinShowWindow(OS2HwndFrame, showstate);
2169 return rc;
2170}
2171//******************************************************************************
2172//******************************************************************************
2173BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
2174{
2175 BOOL rc = FALSE;
2176 Win32BaseWindow *window;
2177 HWND hParent = 0;
2178
2179 dprintf (("SetWindowPos %x %x (%d,%d)(%d,%d) %x", Win32Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
2180
2181 if (fuFlags &
2182 ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
2183 SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED |
2184 SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS |
2185 SWP_NOOWNERZORDER))
2186 {
2187 return FALSE;
2188 }
2189
2190 WINDOWPOS wpos;
2191 SWP swp, swpOld;
2192
2193 wpos.flags = fuFlags;
2194 wpos.cy = cy;
2195 wpos.cx = cx;
2196 wpos.x = x;
2197 wpos.y = y;
2198 wpos.hwndInsertAfter = hwndInsertAfter;
2199 wpos.hwnd = getWindowHandle();
2200
2201 if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
2202 {
2203 if (isChild())
2204 {
2205 hParent = getParent()->getOS2WindowHandle();
2206 }
2207 OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
2208 }
2209
2210 OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame);
2211 if (swp.fl == 0)
2212 return TRUE;
2213
2214// if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
2215 if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
2216 {
2217 Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
2218 if(wndBehind) {
2219 swp.hwndInsertBehind = wndBehind->getOS2WindowHandle();
2220 }
2221 else {
2222 dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
2223 swp.hwndInsertBehind = 0;
2224 }
2225 }
2226#if 0
2227 if (isFrameWindow())
2228 {
2229 if (!isChild())
2230 {
2231 POINT maxSize, maxPos, minTrack, maxTrack;
2232
2233 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
2234
2235 if (swp.cx > maxTrack.x) swp.cx = maxTrack.x;
2236 if (swp.cy > maxTrack.y) swp.cy = maxTrack.y;
2237 if (swp.cx < minTrack.x) swp.cx = minTrack.x;
2238 if (swp.cy < minTrack.y) swp.cy = minTrack.y;
2239 }
2240 swp.hwnd = OS2HwndFrame;
2241 }
2242 else
2243#endif
2244 swp.hwnd = OS2HwndFrame;
2245
2246 dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
2247
2248 rc = OSLibWinSetMultWindowPos(&swp, 1);
2249
2250 if (rc == FALSE)
2251 {
2252 dprintf(("OSLibWinSetMultWindowPos failed!"));
2253 }
2254 else
2255 {
2256 if (fuFlags & SWP_FRAMECHANGED_W)
2257 OSLibSendMessage (OS2HwndFrame, 0x42 /*WM_UPDATEFRAME*/, -1, 0);
2258 }
2259
2260 return (rc);
2261}
2262//******************************************************************************
2263//TODO: WPF_RESTOREMAXIMIZED
2264//******************************************************************************
2265BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *winpos)
2266{
2267 if(isFrameWindow())
2268 {
2269 // Set the minimized position
2270 if (winpos->flags & WPF_SETMINPOSITION)
2271 {
2272 OSLibSetWindowMinPos(OS2HwndFrame, winpos->ptMinPosition.x, winpos->ptMinPosition.y);
2273 }
2274
2275 //TODO: Max position
2276
2277 // Set the new restore position.
2278 OSLibSetWindowRestoreRect(OS2HwndFrame, &winpos->rcNormalPosition);
2279 }
2280
2281 return ShowWindow(winpos->showCmd);
2282}
2283//******************************************************************************
2284//Also destroys all the child windows (destroy parent, destroy children)
2285//******************************************************************************
2286BOOL Win32BaseWindow::DestroyWindow()
2287{
2288 return OSLibWinDestroyWindow(OS2HwndFrame);
2289}
2290//******************************************************************************
2291//******************************************************************************
2292HWND Win32BaseWindow::GetParent()
2293{
2294 if(getParent()) {
2295 return getParent()->getWindowHandle();
2296 }
2297 else return 0;
2298}
2299//******************************************************************************
2300//******************************************************************************
2301HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
2302{
2303 HWND oldhwnd;
2304 Win32BaseWindow *newparent;
2305
2306 if(getParent()) {
2307 oldhwnd = getParent()->getWindowHandle();
2308 getParent()->RemoveChild(this);
2309 }
2310 else oldhwnd = 0;
2311
2312 newparent = GetWindowFromHandle(hwndNewParent);
2313 if(newparent)
2314 {
2315 setParent(newparent);
2316 getParent()->AddChild(this);
2317 OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
2318 return oldhwnd;
2319 }
2320 SetLastError(ERROR_INVALID_PARAMETER);
2321 return 0;
2322}
2323//******************************************************************************
2324//******************************************************************************
2325BOOL Win32BaseWindow::IsChild(HWND hwndParent)
2326{
2327 if(getParent()) {
2328 return getParent()->getWindowHandle() == hwndParent;
2329 }
2330 else return 0;
2331}
2332//******************************************************************************
2333//******************************************************************************
2334HWND Win32BaseWindow::GetTopWindow()
2335{
2336 return GetWindow(GW_CHILD);
2337}
2338//******************************************************************************
2339// Get the top-level parent for a child window.
2340//******************************************************************************
2341Win32BaseWindow *Win32BaseWindow::GetTopParent()
2342{
2343 Win32BaseWindow *window = this;
2344
2345 while(window && (window->getStyle() & WS_CHILD))
2346 {
2347 window = window->getParent();
2348 }
2349 return window;
2350}
2351//******************************************************************************
2352//Don't call WinUpdateWindow as that one also updates the child windows
2353//Also need to send WM_PAINT directly to the window procedure, which doesn't
2354//always happen with WinUpdateWindow (could be posted if thread doesn't own window)
2355//******************************************************************************
2356BOOL Win32BaseWindow::UpdateWindow()
2357{
2358 RECT rect;
2359
2360 if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect))
2361 {//update region not empty
2362 HDC hdc;
2363
2364 hdc = O32_GetDC(OS2Hwnd);
2365 if (isIcon)
2366 {
2367 SendMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
2368 SendMessageA(WM_PAINTICON, 0, 0);
2369 } else
2370 {
2371 SendMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
2372 SendMessageA(WM_PAINT, 0, 0);
2373 }
2374 O32_ReleaseDC(OS2Hwnd, hdc);
2375 }
2376 return TRUE;
2377}
2378//******************************************************************************
2379//******************************************************************************
2380BOOL Win32BaseWindow::IsIconic()
2381{
2382 return OSLibWinIsIconic(OS2Hwnd);
2383}
2384//******************************************************************************
2385//TODO: Should not enumerate children that are created during the enumeration!
2386//******************************************************************************
2387BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
2388{
2389 BOOL rc = TRUE;
2390 HWND hwnd;
2391 Win32BaseWindow *prevchild = 0, *child = 0;
2392
2393 dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
2394 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2395 {
2396 dprintf(("EnumChildWindows: enumerating child %x", child->getWindowHandle()));
2397 hwnd = child->getWindowHandle();
2398 if(lpfn(hwnd, lParam) == FALSE)
2399 {
2400 rc = FALSE;
2401 break;
2402 }
2403 //check if the window still exists
2404 if(!::IsWindow(hwnd))
2405 {
2406 child = prevchild;
2407 continue;
2408 }
2409 if(child->getFirstChild() != NULL)
2410 {
2411 dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle()));
2412 if(child->EnumChildWindows(lpfn, lParam) == FALSE)
2413 {
2414 rc = FALSE;
2415 break;
2416 }
2417 }
2418 prevchild = child;
2419 }
2420 return rc;
2421}
2422//******************************************************************************
2423//******************************************************************************
2424Win32BaseWindow *Win32BaseWindow::FindWindowById(int id)
2425{
2426 for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2427 {
2428 if (child->getWindowId() == id)
2429 {
2430 return child;
2431 }
2432 }
2433 return 0;
2434}
2435//******************************************************************************
2436//TODO:
2437//We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
2438//the current process owns them.
2439//******************************************************************************
2440HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
2441 BOOL fUnicode)
2442{
2443 Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
2444 Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
2445
2446 if((hwndParent != OSLIB_HWND_DESKTOP && !parent) ||
2447 (hwndChildAfter != 0 && !child) ||
2448 (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0))
2449 {
2450 dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
2451 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
2452 return 0;
2453 }
2454 if(hwndParent != OSLIB_HWND_DESKTOP)
2455 {//if the current process owns the window, just do a quick search
2456 child = (Win32BaseWindow *)parent->getFirstChild();
2457 if(hwndChildAfter != 0)
2458 {
2459 while(child)
2460 {
2461 if(child->getWindowHandle() == hwndChildAfter)
2462 {
2463 child = (Win32BaseWindow *)child->getNextChild();
2464 break;
2465 }
2466 child = (Win32BaseWindow *)child->getNextChild();
2467 }
2468 }
2469 while(child)
2470 {
2471 if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
2472 (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
2473 {
2474 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
2475 return child->getWindowHandle();
2476 }
2477 child = (Win32BaseWindow *)child->getNextChild();
2478 }
2479 }
2480 else {
2481 Win32BaseWindow *wnd;
2482 HWND henum, hwnd;
2483
2484 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
2485 hwnd = OSLibWinGetNextWindow(henum);
2486
2487 while(hwnd)
2488 {
2489 wnd = GetWindowFromOS2Handle(hwnd);
2490 if(wnd == NULL) {
2491 hwnd = OSLibWinQueryClientWindow(hwnd);
2492 if(hwnd) wnd = GetWindowFromOS2Handle(hwnd);
2493 if(!hwnd) wnd = GetWindowFromOS2FrameHandle(hwnd);
2494 }
2495
2496 if(wnd) {
2497 if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
2498 (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
2499 {
2500 OSLibWinEndEnumWindows(henum);
2501 dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
2502 return wnd->getWindowHandle();
2503 }
2504 }
2505 hwnd = OSLibWinGetNextWindow(henum);
2506 }
2507 OSLibWinEndEnumWindows(henum);
2508 }
2509 SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
2510 return 0;
2511}
2512//******************************************************************************
2513//******************************************************************************
2514HWND Win32BaseWindow::GetWindow(UINT uCmd)
2515{
2516 HWND hwndRelated = 0;
2517 Win32BaseWindow *window;
2518
2519 switch(uCmd)
2520 {
2521 case GW_HWNDFIRST:
2522 if(getParent()) {
2523 window = (Win32BaseWindow *)getParent()->getFirstChild();
2524 hwndRelated = window->getWindowHandle();
2525 }
2526 break;
2527
2528 case GW_HWNDLAST:
2529 if(getParent())
2530 {
2531 goto end;
2532 }
2533
2534 window = this;
2535 while(window)
2536 {
2537 window = (Win32BaseWindow *)window->getNextChild();
2538 }
2539 hwndRelated = window->getWindowHandle();
2540 break;
2541
2542 case GW_HWNDNEXT:
2543 window = (Win32BaseWindow *)getNextChild();
2544 if(window) {
2545 hwndRelated = window->getWindowHandle();
2546 }
2547 break;
2548
2549 case GW_HWNDPREV:
2550 if(!getParent())
2551 {
2552 goto end;
2553 }
2554 window = (Win32BaseWindow *)(getParent()->getFirstChild()); /* First sibling */
2555 if(window == this)
2556 {
2557 hwndRelated = 0; /* First in list */
2558 goto end;
2559 }
2560 while(window->getNextChild())
2561 {
2562 if (window->getNextChild() == this)
2563 {
2564 hwndRelated = window->getWindowHandle();
2565 goto end;
2566 }
2567 window = (Win32BaseWindow *)window->getNextChild();
2568 }
2569 break;
2570
2571 case GW_OWNER:
2572 if(getOwner()) {
2573 hwndRelated = getOwner()->getWindowHandle();
2574 }
2575 break;
2576
2577 case GW_CHILD:
2578 if(getFirstChild()) {
2579 hwndRelated = ((Win32BaseWindow *)getFirstChild())->getWindowHandle();
2580 }
2581 break;
2582 }
2583end:
2584 dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
2585 return hwndRelated;
2586}
2587//******************************************************************************
2588//******************************************************************************
2589HWND Win32BaseWindow::SetActiveWindow()
2590{
2591 return OSLibWinSetActiveWindow(OS2HwndFrame);
2592}
2593//******************************************************************************
2594//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
2595//******************************************************************************
2596BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
2597{
2598 return OSLibWinEnableWindow(OS2HwndFrame, fEnable);
2599}
2600//******************************************************************************
2601//******************************************************************************
2602BOOL Win32BaseWindow::CloseWindow()
2603{
2604 return OSLibWinMinimizeWindow(OS2HwndFrame);
2605}
2606//******************************************************************************
2607//******************************************************************************
2608HWND Win32BaseWindow::GetActiveWindow()
2609{
2610 HWND hwndActive;
2611 Win32BaseWindow *win32wnd;
2612 ULONG magic;
2613
2614 hwndActive = OSLibWinQueryActiveWindow();
2615
2616 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32WNDPTR);
2617 magic = OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32PM_MAGIC);
2618 if(CheckMagicDword(magic) && win32wnd)
2619 {
2620 return win32wnd->getWindowHandle();
2621 }
2622 return hwndActive;
2623}
2624//******************************************************************************
2625//******************************************************************************
2626BOOL Win32BaseWindow::IsWindowEnabled()
2627{
2628 return OSLibWinIsWindowEnabled(OS2HwndFrame);
2629}
2630//******************************************************************************
2631//******************************************************************************
2632BOOL Win32BaseWindow::IsWindowVisible()
2633{
2634#if 1
2635 return (dwStyle & WS_VISIBLE) == WS_VISIBLE;
2636#else
2637 return OSLibWinIsWindowVisible(OS2HwndFrame);
2638#endif
2639}
2640//******************************************************************************
2641//******************************************************************************
2642BOOL Win32BaseWindow::GetWindowRect(PRECT pRect)
2643{
2644 return OSLibWinQueryWindowRect(OS2HwndFrame, pRect, RELATIVE_TO_SCREEN);
2645}
2646//******************************************************************************
2647//******************************************************************************
2648BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
2649{
2650 if(wndname == NULL)
2651 return FALSE;
2652
2653 if(fUnicode) {
2654 return (lstrcmpW(windowNameW, (LPWSTR)wndname) == 0);
2655 }
2656 else return (strcmp(windowNameA, wndname) == 0);
2657}
2658//******************************************************************************
2659//******************************************************************************
2660int Win32BaseWindow::GetWindowTextLength()
2661{
2662 return SendInternalMessageA(WM_GETTEXTLENGTH,0,0);
2663}
2664//******************************************************************************
2665//******************************************************************************
2666int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
2667{
2668 return SendInternalMessageA(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
2669}
2670//******************************************************************************
2671//******************************************************************************
2672int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
2673{
2674 return SendInternalMessageW(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
2675}
2676//******************************************************************************
2677//******************************************************************************
2678BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
2679{
2680 return SendInternalMessageA(WM_SETTEXT,0,(LPARAM)lpsz);
2681}
2682//******************************************************************************
2683//******************************************************************************
2684BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
2685{
2686 return SendInternalMessageW(WM_SETTEXT,0,(LPARAM)lpsz);
2687}
2688//******************************************************************************
2689//******************************************************************************
2690VOID Win32BaseWindow::updateWindowStyle(DWORD oldExStyle,DWORD oldStyle)
2691{
2692 if(IsWindowDestroyed()) return;
2693
2694/*
2695 if (isChild())
2696 {
2697 DWORD dwOSWinStyle,dwOSFrameStyle,newBorderWidth,newBorderHeight;
2698
2699 OSLibWinConvertStyle(dwStyle,&dwExStyle,&dwOSWinStyle,&dwOSFrameStyle,&newBorderWidth,&newBorderHeight);
2700 if (newBorderWidth != borderWidth || newBorderHeight != borderHeight)
2701 {
2702 borderWidth = newBorderWidth;
2703 borderHeight = newBorderHeight;
2704 FrameSetBorderSize(this,TRUE);
2705 }
2706 }
2707*/
2708
2709 if (dwStyle != oldStyle) OSLibSetWindowStyle(OS2HwndFrame,dwStyle);
2710}
2711//******************************************************************************
2712//******************************************************************************
2713LONG Win32BaseWindow::SetWindowLongA(int index, ULONG value)
2714{
2715 LONG oldval;
2716
2717 dprintf2(("SetWindowLongA %x %d %x", getWindowHandle(), index, value));
2718 switch(index) {
2719 case GWL_EXSTYLE:
2720 {
2721 STYLESTRUCT ss;
2722
2723 if(dwExStyle == value)
2724 return value;
2725
2726 ss.styleOld = dwExStyle;
2727 ss.styleNew = value;
2728 dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
2729 SendMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
2730 setExStyle(ss.styleNew);
2731 updateWindowStyle(ss.styleOld,dwStyle);
2732 SendMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
2733 return ss.styleOld;
2734 }
2735 case GWL_STYLE:
2736 {
2737 STYLESTRUCT ss;
2738
2739 if(dwStyle == value)
2740 return value;
2741
2742 ss.styleOld = dwStyle;
2743 ss.styleNew = value;
2744 dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), dwStyle, value));
2745 SendMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
2746 setStyle(ss.styleNew);
2747 updateWindowStyle(dwExStyle,ss.styleOld);
2748 SendMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
2749 return ss.styleOld;
2750 }
2751 case GWL_WNDPROC:
2752 oldval = (LONG)getWindowProc();
2753 setWindowProc((WNDPROC)value);
2754 return oldval;
2755 case GWL_HINSTANCE:
2756 oldval = hInstance;
2757 hInstance = value;
2758 return oldval;
2759 case GWL_HWNDPARENT:
2760 return SetParent((HWND)value);
2761 case GWL_ID:
2762 oldval = getWindowId();
2763 setWindowId(value);
2764 return oldval;
2765 case GWL_USERDATA:
2766 oldval = userData;
2767 userData = value;
2768 return oldval;
2769 default:
2770 if(index >= 0 && index/4 < nrUserWindowLong)
2771 {
2772 oldval = userWindowLong[index/4];
2773 userWindowLong[index/4] = value;
2774 return oldval;
2775 }
2776 SetLastError(ERROR_INVALID_PARAMETER);
2777 return 0;
2778 }
2779}
2780//******************************************************************************
2781//******************************************************************************
2782ULONG Win32BaseWindow::GetWindowLongA(int index)
2783{
2784 ULONG value;
2785
2786 switch(index) {
2787 case GWL_EXSTYLE:
2788 value = dwExStyle;
2789 break;
2790 case GWL_STYLE:
2791 value = dwStyle;
2792 break;
2793 case GWL_WNDPROC:
2794 value = (ULONG)getWindowProc();
2795 break;
2796 case GWL_HINSTANCE:
2797 value = hInstance;
2798 break;
2799 case GWL_HWNDPARENT:
2800 if(getParent()) {
2801 value = getParent()->getWindowHandle();
2802 }
2803 else value = 0;
2804 break;
2805 case GWL_ID:
2806 value = getWindowId();
2807 break;
2808 case GWL_USERDATA:
2809 value = userData;
2810 break;
2811 default:
2812 if(index >= 0 && index/4 < nrUserWindowLong)
2813 {
2814 value = userWindowLong[index/4];
2815 break;
2816 }
2817 SetLastError(ERROR_INVALID_PARAMETER);
2818 return 0;
2819 }
2820 dprintf2(("GetWindowLongA %x %d %x", getWindowHandle(), index, value));
2821 return value;
2822}
2823//******************************************************************************
2824//******************************************************************************
2825WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
2826{
2827 WORD oldval;
2828
2829 if(index >= 0 && index/4 < nrUserWindowLong)
2830 {
2831 oldval = ((WORD *)userWindowLong)[index/2];
2832 ((WORD *)userWindowLong)[index/2] = value;
2833 return oldval;
2834 }
2835 SetLastError(ERROR_INVALID_PARAMETER);
2836 return 0;
2837}
2838//******************************************************************************
2839//******************************************************************************
2840WORD Win32BaseWindow::GetWindowWord(int index)
2841{
2842 if(index >= 0 && index/4 < nrUserWindowLong)
2843 {
2844 return ((WORD *)userWindowLong)[index/2];
2845 }
2846 SetLastError(ERROR_INVALID_PARAMETER);
2847 return 0;
2848}
2849//******************************************************************************
2850//******************************************************************************
2851void Win32BaseWindow::setWindowId(DWORD id)
2852{
2853 windowId = id;
2854 OSLibSetWindowID(OS2HwndFrame, id);
2855}
2856//******************************************************************************
2857//******************************************************************************
2858Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
2859{
2860 Win32BaseWindow *window;
2861
2862 if(hwnd == NULL && windowDesktop)
2863 return windowDesktop;
2864
2865 if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
2866 return window;
2867 }
2868 else return NULL;
2869}
2870//******************************************************************************
2871//******************************************************************************
2872Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd)
2873{
2874 Win32BaseWindow *win32wnd;
2875 DWORD magic;
2876
2877 if(hwnd == OSLIB_HWND_DESKTOP)
2878 {
2879 return windowDesktop;
2880 }
2881
2882 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
2883 magic = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
2884
2885 if(win32wnd && CheckMagicDword(magic)) {
2886 return win32wnd;
2887 }
2888 return 0;
2889}
2890//******************************************************************************
2891//******************************************************************************
2892Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
2893{
2894 return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
2895}
2896//******************************************************************************
2897//******************************************************************************
2898HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd)
2899{
2900 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
2901
2902 if(window) {
2903 return window->getOS2WindowHandle();
2904 }
2905 else return hwnd;
2906}
2907//******************************************************************************
2908//******************************************************************************
2909HWND Win32BaseWindow::Win32ToOS2FrameHandle(HWND hwnd)
2910{
2911 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
2912
2913 if(window) {
2914 return window->getOS2FrameWindowHandle();
2915 }
2916 else return hwnd;
2917}
2918//******************************************************************************
2919//******************************************************************************
2920HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd)
2921{
2922 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
2923
2924 if(window) {
2925 return window->getWindowHandle();
2926 }
2927 window = GetWindowFromOS2FrameHandle(hwnd);
2928 if(window) {
2929 return window->getWindowHandle();
2930 }
2931 else return 0;
2932// else return hwnd; //OS/2 window handle
2933}
2934//******************************************************************************
2935// GetNextDlgTabItem32 (USER32.276)
2936//******************************************************************************
2937HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
2938{
2939 Win32BaseWindow *child, *nextchild, *lastchild;
2940 HWND retvalue;
2941
2942 if (hwndCtrl)
2943 {
2944 child = GetWindowFromHandle(hwndCtrl);
2945 if (!child)
2946 {
2947 retvalue = 0;
2948 goto END;
2949 }
2950 /* Make sure hwndCtrl is a top-level child */
2951 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
2952 {
2953 child = child->getParent();
2954 if(child == NULL) break;
2955 }
2956
2957 if (!child || child->getParent() != this)
2958 {
2959 retvalue = 0;
2960 goto END;
2961 }
2962 }
2963 else
2964 {
2965 /* No ctrl specified -> start from the beginning */
2966 child = (Win32BaseWindow *)getFirstChild();
2967 if (!child)
2968 {
2969 retvalue = 0;
2970 goto END;
2971 }
2972
2973 if (!fPrevious)
2974 {
2975 while (child->getNextChild())
2976 {
2977 child = (Win32BaseWindow *)child->getNextChild();
2978 }
2979 }
2980 }
2981
2982 lastchild = child;
2983 nextchild = (Win32BaseWindow *)child->getNextChild();
2984 while (TRUE)
2985 {
2986 if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild();
2987
2988 if (child == nextchild) break;
2989
2990 if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) &&
2991 !(nextchild->getStyle() & WS_DISABLED))
2992 {
2993 lastchild = nextchild;
2994 if (!fPrevious) break;
2995 }
2996 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
2997 }
2998 retvalue = lastchild->getWindowHandle();
2999
3000END:
3001 return retvalue;
3002}
3003//******************************************************************************
3004//******************************************************************************
3005HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
3006{
3007 Win32BaseWindow *child, *nextchild, *lastchild;
3008 HWND retvalue;
3009
3010 if (hwndCtrl)
3011 {
3012 child = GetWindowFromHandle(hwndCtrl);
3013 if (!child)
3014 {
3015 retvalue = 0;
3016 goto END;
3017 }
3018 /* Make sure hwndCtrl is a top-level child */
3019 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
3020 {
3021 child = child->getParent();
3022 if(child == NULL) break;
3023 }
3024
3025 if (!child || child->getParent() != this)
3026 {
3027 retvalue = 0;
3028 goto END;
3029 }
3030 }
3031 else
3032 {
3033 /* No ctrl specified -> start from the beginning */
3034 child = (Win32BaseWindow *)getFirstChild();
3035 if (!child)
3036 {
3037 retvalue = 0;
3038 goto END;
3039 }
3040
3041 if (fPrevious)
3042 {
3043 while (child->getNextChild())
3044 {
3045 child = (Win32BaseWindow *)child->getNextChild();
3046 }
3047 }
3048 }
3049
3050 lastchild = child;
3051 nextchild = (Win32BaseWindow *)child->getNextChild();
3052 while (TRUE)
3053 {
3054 if (!nextchild || nextchild->getStyle() & WS_GROUP)
3055 {
3056 /* Wrap-around to the beginning of the group */
3057 Win32BaseWindow *pWndTemp;
3058
3059 nextchild = (Win32BaseWindow *)getFirstChild();
3060
3061 for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild())
3062 {
3063 if (pWndTemp->getStyle() & WS_GROUP)
3064 nextchild = pWndTemp;
3065
3066 if (pWndTemp == child)
3067 break;
3068 }
3069
3070 }
3071 if (nextchild == child)
3072 break;
3073
3074 if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED))
3075 {
3076 lastchild = nextchild;
3077
3078 if (!fPrevious)
3079 break;
3080 }
3081
3082 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
3083 }
3084 retvalue = lastchild->getWindowHandle();
3085END:
3086 return retvalue;
3087}
3088//******************************************************************************
3089//******************************************************************************
3090#ifdef DEBUG
3091void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
3092{
3093 char style[256] = "";
3094 char exstyle[256] = "";
3095
3096 /* Window styles */
3097 if(dwStyle & WS_CHILD)
3098 strcat(style, "WS_CHILD ");
3099 if(dwStyle & WS_POPUP)
3100 strcat(style, "WS_POPUP ");
3101 if(dwStyle & WS_VISIBLE)
3102 strcat(style, "WS_VISIBLE ");
3103 if(dwStyle & WS_DISABLED)
3104 strcat(style, "WS_DISABLED ");
3105 if(dwStyle & WS_CLIPSIBLINGS)
3106 strcat(style, "WS_CLIPSIBLINGS ");
3107 if(dwStyle & WS_CLIPCHILDREN)
3108 strcat(style, "WS_CLIPCHILDREN ");
3109 if(dwStyle & WS_MAXIMIZE)
3110 strcat(style, "WS_MAXIMIZE ");
3111 if(dwStyle & WS_MINIMIZE)
3112 strcat(style, "WS_MINIMIZE ");
3113 if(dwStyle & WS_GROUP)
3114 strcat(style, "WS_GROUP ");
3115 if(dwStyle & WS_TABSTOP)
3116 strcat(style, "WS_TABSTOP ");
3117
3118 if((dwStyle & WS_CAPTION) == WS_CAPTION)
3119 strcat(style, "WS_CAPTION ");
3120 if(dwStyle & WS_DLGFRAME)
3121 strcat(style, "WS_DLGFRAME ");
3122 if(dwStyle & WS_BORDER)
3123 strcat(style, "WS_BORDER ");
3124
3125 if(dwStyle & WS_VSCROLL)
3126 strcat(style, "WS_VSCROLL ");
3127 if(dwStyle & WS_HSCROLL)
3128 strcat(style, "WS_HSCROLL ");
3129 if(dwStyle & WS_SYSMENU)
3130 strcat(style, "WS_SYSMENU ");
3131 if(dwStyle & WS_THICKFRAME)
3132 strcat(style, "WS_THICKFRAME ");
3133 if(dwStyle & WS_MINIMIZEBOX)
3134 strcat(style, "WS_MINIMIZEBOX ");
3135 if(dwStyle & WS_MAXIMIZEBOX)
3136 strcat(style, "WS_MAXIMIZEBOX ");
3137
3138 if(dwExStyle & WS_EX_DLGMODALFRAME)
3139 strcat(exstyle, "WS_EX_DLGMODALFRAME ");
3140 if(dwExStyle & WS_EX_ACCEPTFILES)
3141 strcat(exstyle, "WS_EX_ACCEPTFILES ");
3142 if(dwExStyle & WS_EX_NOPARENTNOTIFY)
3143 strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
3144 if(dwExStyle & WS_EX_TOPMOST)
3145 strcat(exstyle, "WS_EX_TOPMOST ");
3146 if(dwExStyle & WS_EX_TRANSPARENT)
3147 strcat(exstyle, "WS_EX_TRANSPARENT ");
3148
3149 if(dwExStyle & WS_EX_MDICHILD)
3150 strcat(exstyle, "WS_EX_MDICHILD ");
3151 if(dwExStyle & WS_EX_TOOLWINDOW)
3152 strcat(exstyle, "WS_EX_TOOLWINDOW ");
3153 if(dwExStyle & WS_EX_WINDOWEDGE)
3154 strcat(exstyle, "WS_EX_WINDOWEDGE ");
3155 if(dwExStyle & WS_EX_CLIENTEDGE)
3156 strcat(exstyle, "WS_EX_CLIENTEDGE ");
3157 if(dwExStyle & WS_EX_CONTEXTHELP)
3158 strcat(exstyle, "WS_EX_CONTEXTHELP ");
3159 if(dwExStyle & WS_EX_RIGHT)
3160 strcat(exstyle, "WS_EX_RIGHT ");
3161 if(dwExStyle & WS_EX_LEFT)
3162 strcat(exstyle, "WS_EX_LEFT ");
3163 if(dwExStyle & WS_EX_RTLREADING)
3164 strcat(exstyle, "WS_EX_RTLREADING ");
3165 if(dwExStyle & WS_EX_LTRREADING)
3166 strcat(exstyle, "WS_EX_LTRREADING ");
3167 if(dwExStyle & WS_EX_LEFTSCROLLBAR)
3168 strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
3169 if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
3170 strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
3171 if(dwExStyle & WS_EX_CONTROLPARENT)
3172 strcat(exstyle, "WS_EX_CONTROLPARENT ");
3173 if(dwExStyle & WS_EX_STATICEDGE)
3174 strcat(exstyle, "WS_EX_STATICEDGE ");
3175 if(dwExStyle & WS_EX_APPWINDOW)
3176 strcat(exstyle, "WS_EX_APPWINDOW ");
3177
3178 dprintf(("Window style: %x %s", dwStyle, style));
3179 dprintf(("Window exStyle: %x %s", dwExStyle, exstyle));
3180}
3181#endif
3182//******************************************************************************
3183//******************************************************************************
3184
3185GenericObject *Win32BaseWindow::windows = NULL;
Note: See TracBrowser for help on using the repository browser.