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

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

SetParent bugfix

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