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

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

ShowScrollBar fix

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