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

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

cursor handling fixed

File size: 104.6 KB
Line 
1/* $Id: win32wbase.cpp,v 1.85 1999-11-17 17:04:55 cbratschi Exp $ */
2/*
3 * Win32 Window Base Class for OS/2
4 *
5 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
6 * Copyright 1999 Daniela Engert (dani@ngrt.de)
7 *
8 * Parts based on Wine Windows code (windows\win.c)
9 *
10 * Copyright 1993, 1994 Alexandre Julliard
11 *
12 * TODO: Not thread/process safe
13 *
14 * Project Odin Software License can be found in LICENSE.TXT
15 *
16 */
17#include <os2win.h>
18#include <win.h>
19#include <stdlib.h>
20#include <string.h>
21#include <stdarg.h>
22#include <assert.h>
23#include <misc.h>
24#include <heapstring.h>
25#include <win32wbase.h>
26#include <winres.h>
27#include "wndmsg.h"
28#include "hooks.h"
29#include "oslibwin.h"
30#include "oslibutil.h"
31#include "oslibgdi.h"
32#include "oslibres.h"
33#include "oslibmenu.h"
34#include "oslibdos.h"
35#include "syscolor.h"
36#include "win32wndhandle.h"
37#include "dc.h"
38#include "pmframe.h"
39#include "win32wdesktop.h"
40#include "pmwindow.h"
41#include "controls.h"
42#include <wprocess.h>
43#include "winmouse.h"
44
45#define HAS_DLGFRAME(style,exStyle) \
46 (((exStyle) & WS_EX_DLGMODALFRAME) || \
47 (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
48
49#define HAS_THICKFRAME(style,exStyle) \
50 (((style) & WS_THICKFRAME) && \
51 !((exStyle) & WS_EX_DLGMODALFRAME))
52
53#define HAS_THINFRAME(style) \
54 (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
55
56#define HAS_BIGFRAME(style,exStyle) \
57 (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
58 ((exStyle) & WS_EX_DLGMODALFRAME))
59
60#define HAS_ANYFRAME(style,exStyle) \
61 (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
62 ((exStyle) & WS_EX_DLGMODALFRAME) || \
63 !((style) & (WS_CHILD | WS_POPUP)))
64
65#define HAS_3DFRAME(exStyle) \
66 ((exStyle & WS_EX_CLIENTEDGE) || (exStyle & WS_EX_STATICEDGE) || (exStyle & WS_EX_WINDOWEDGE))
67
68#define HAS_BORDER(style, exStyle) \
69 ((style & WS_BORDER) || HAS_THICKFRAME(style) || HAS_DLGFRAME(style,exStyle))
70
71#define IS_OVERLAPPED(style) \
72 !(style & (WS_CHILD | WS_POPUP))
73
74/* bits in the dwKeyData */
75#define KEYDATA_ALT 0x2000
76#define KEYDATA_PREVSTATE 0x4000
77
78void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle);
79
80static fDestroyAll = FALSE;
81
82//******************************************************************************
83//******************************************************************************
84Win32BaseWindow::Win32BaseWindow(DWORD objType) : GenericObject(&windows, objType)
85{
86 Init();
87}
88//******************************************************************************
89//******************************************************************************
90Win32BaseWindow::Win32BaseWindow(HWND os2Handle,VOID* win32WndProc) : GenericObject(&windows,OBJTYPE_WINDOW)
91{
92 Init();
93 OS2Hwnd = OS2HwndFrame = os2Handle;
94 dwStyle = WS_VISIBLE;
95 setWindowProc((WNDPROC)win32WndProc);
96 fIsSubclassedOS2Wnd = TRUE;
97 fFirstShow = FALSE;
98
99 SetLastError(0);
100
101 //CB: replace by a secure method
102
103 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
104 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
105 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
106 return;
107 }
108 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
109 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
110 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
111 return;
112 }
113
114 OSLibWinQueryWindowRect(OS2Hwnd,&rectWindow);
115 rectClient = rectWindow;
116 rectClient.bottom -= rectClient.top;
117 rectClient.top = 0;
118 rectClient.right -= rectClient.left;
119 rectClient.left = 0;
120
121 setOldWndProc(SubclassWithDefHandler(OS2Hwnd));
122}
123//******************************************************************************
124//******************************************************************************
125Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
126 : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
127{
128 Init();
129 this->isUnicode = isUnicode;
130 CreateWindowExA(lpCreateStructA, classAtom);
131}
132//******************************************************************************
133//******************************************************************************
134void Win32BaseWindow::Init()
135{
136 isUnicode = FALSE;
137 fIsSubclassedOS2Wnd = FALSE;
138 fFirstShow = TRUE;
139 fIsDialog = FALSE;
140 fIsModalDialogOwner = FALSE;
141 OS2HwndModalDialog = 0;
142 fInternalMsg = FALSE;
143 fNoSizeMsg = FALSE;
144 fIsDestroyed = FALSE;
145 fCreated = FALSE;
146
147 windowNameA = NULL;
148 windowNameW = NULL;
149 wndNameLength = 0;
150
151 userWindowLong = NULL;;
152 nrUserWindowLong = 0;
153
154 magic = WIN32PM_MAGIC;
155 OS2Hwnd = 0;
156 OS2HwndFrame = 0;
157 OS2HwndMenu = 0;
158 Win32Hwnd = 0;
159
160 if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE)
161 {
162 dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
163 DebugInt3();
164 }
165
166 posx = posy = 0;
167 width = height = 0;
168
169 dwExStyle = 0;
170 dwStyle = 0;
171 win32wndproc = 0;
172 hInstance = 0;
173 windowId = 0xFFFFFFFF; //default = -1
174 userData = 0;
175 contextHelpId = 0;
176
177 pOldFrameProc = NULL;
178 borderWidth = 0;
179 borderHeight = 0;
180
181 hwndLinkAfter = HWND_BOTTOM;
182 flags = 0;
183 isIcon = FALSE;
184 lastHitTestVal = 0;
185 owner = NULL;
186 windowClass = 0;
187
188 acceltableResource = NULL;
189 iconResource = NULL;
190
191 EraseBkgndFlag = TRUE;
192 PSEraseFlag = FALSE;
193 SupressEraseFlag = FALSE;
194
195 horzScrollInfo = NULL;
196 vertScrollInfo = NULL;
197 hwndHorzScroll = 0;
198 hwndVertScroll = 0;
199
200 ownDC = 0;
201}
202//******************************************************************************
203//todo get rid of resources (menu, accel, icon etc)
204//******************************************************************************
205Win32BaseWindow::~Win32BaseWindow()
206{
207 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
208 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
209
210 if(!fDestroyAll && getParent() && getParent()->getFirstChild() == this && getNextChild() == NULL)
211 {
212 //if we're the last child that's being destroyed and our
213 //parent window was also destroyed, then we delete the parent object
214 if(getParent()->IsWindowDestroyed())
215 {
216 dprintf(("Last Child (%x) destroyed, get rid of our parent window (%x)", getWindowHandle(), getParent()->getWindowHandle()));
217 delete getParent();
218 setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
219 }
220 }
221 else
222 if(fDestroyAll) {
223 dprintf(("Destroying window %x %s", getWindowHandle(), windowNameA));
224 setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
225 }
226
227 if (isOwnDC())
228 releaseOwnDC (ownDC);
229
230 if(Win32Hwnd)
231 HwFreeWindowHandle(Win32Hwnd);
232
233 if(userWindowLong)
234 free(userWindowLong);
235 if(windowNameA) {
236 free(windowNameA);
237 windowNameA = NULL;
238 }
239 if(windowNameW) {
240 free(windowNameW);
241 windowNameW = NULL;
242 }
243 if(vertScrollInfo) {
244 free(vertScrollInfo);
245 vertScrollInfo = NULL;
246 }
247 if(horzScrollInfo) {
248 free(horzScrollInfo);
249 horzScrollInfo = NULL;
250 }
251}
252//******************************************************************************
253//******************************************************************************
254void Win32BaseWindow::DestroyAll()
255{
256 fDestroyAll = TRUE;
257 GenericObject::DestroyAll(windows);
258}
259//******************************************************************************
260//******************************************************************************
261BOOL Win32BaseWindow::isChild()
262{
263 return ((dwStyle & WS_CHILD) != 0);
264}
265//******************************************************************************
266//******************************************************************************
267BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom)
268{
269 char buffer[256];
270 POINT maxSize, maxPos, minTrack, maxTrack;
271
272#ifdef DEBUG
273 PrintWindowStyle(cs->style, cs->dwExStyle);
274#endif
275
276 sw = SW_SHOW;
277 SetLastError(0);
278
279 /* Find the parent window */
280 if (cs->hwndParent)
281 {
282 Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
283 if(!window) {
284 dprintf(("Bad parent %04x\n", cs->hwndParent ));
285 SetLastError(ERROR_INVALID_PARAMETER);
286 return FALSE;
287 }
288 /* Make sure parent is valid */
289 if (!window->IsWindow() )
290 {
291 dprintf(("Bad parent %04x\n", cs->hwndParent ));
292 SetLastError(ERROR_INVALID_PARAMETER);
293 return FALSE;
294 }
295 }
296 else
297 if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
298 dprintf(("No parent for child window\n" ));
299 SetLastError(ERROR_INVALID_PARAMETER);
300 return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
301 }
302
303 /* Find the window class */
304 windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
305 if (!windowClass)
306 {
307 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
308 dprintf(("Bad class '%s'\n", buffer ));
309 SetLastError(ERROR_INVALID_PARAMETER);
310 return 0;
311 }
312#ifdef DEBUG
313 if(HIWORD(cs->lpszClass))
314 {
315 char *astring;
316
317 if(isUnicode) astring = UnicodeToAsciiString((LPWSTR)cs->lpszClass);
318 else astring = (char *)cs->lpszClass;
319
320 dprintf(("Window class %s", astring));
321 if(isUnicode) FreeAsciiString(astring);
322 }
323 else dprintf(("Window class %x", cs->lpszClass));
324#endif
325
326 /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
327 * with an atom as the class name, put some programs expect to have a *REAL* string in
328 * lpszClass when the CREATESTRUCT is sent with WM_CREATE
329 */
330 if (!HIWORD(cs->lpszClass) ) {
331 if (isUnicode) {
332 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
333 }
334 else {
335 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
336 }
337 cs->lpszClass = buffer;
338 }
339
340 /* Fix the coordinates */
341 if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16)
342 {
343// PDB *pdb = PROCESS_Current();
344
345 /* Never believe Microsoft's documentation... CreateWindowEx doc says
346 * that if an overlapped window is created with WS_VISIBLE style bit
347 * set and the x parameter is set to CW_USEDEFAULT, the system ignores
348 * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
349 * reveals that
350 *
351 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
352 * 2) it does not ignore the y parameter as the docs claim; instead, it
353 * uses it as second parameter to ShowWindow() unless y is either
354 * CW_USEDEFAULT or CW_USEDEFAULT16.
355 *
356 * The fact that we didn't do 2) caused bogus windows pop up when wine
357 * was running apps that were using this obscure feature. Example -
358 * calc.exe that comes with Win98 (only Win98, it's different from
359 * the one that comes with Win95 and NT)
360 */
361 if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) sw = cs->y;
362
363 /* We have saved cs->y, now we can trash it */
364#if 0
365 if ( !(cs->style & (WS_CHILD | WS_POPUP))
366 && (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
367 {
368 cs->x = pdb->env_db->startup_info->dwX;
369 cs->y = pdb->env_db->startup_info->dwY;
370 }
371#endif
372 cs->x = 0;
373 cs->y = 0;
374// }
375 }
376 if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16)
377 {
378#if 0
379 PDB *pdb = PROCESS_Current();
380 if ( !(cs->style & (WS_CHILD | WS_POPUP))
381 && (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )
382 {
383 cs->cx = pdb->env_db->startup_info->dwXSize;
384 cs->cy = pdb->env_db->startup_info->dwYSize;
385 }
386 else
387 {
388#endif
389 cs->cx = 600; /* FIXME */
390 cs->cy = 400;
391// }
392 }
393
394 if (cs->x < 0) cs->x = 0;
395 if (cs->y < 0) cs->y = 0;
396
397 //Allocate window words
398 nrUserWindowLong = windowClass->getExtraWndWords();
399 if(nrUserWindowLong) {
400 userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
401 memset(userWindowLong, 0, nrUserWindowLong);
402 }
403
404 if ((cs->style & WS_CHILD) && cs->hwndParent)
405 {
406 SetParent(cs->hwndParent);
407 owner = GetWindowFromHandle(cs->hwndParent);
408 if(owner == NULL)
409 {
410 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
411 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
412 return FALSE;
413 }
414 }
415 else
416 {
417 SetParent(windowDesktop->getWindowHandle());
418 if (!cs->hwndParent || cs->hwndParent == windowDesktop->getWindowHandle()) {
419 owner = NULL;
420 }
421 else
422 {
423 owner = GetWindowFromHandle(cs->hwndParent)->GetTopParent();
424 if(owner == NULL)
425 {
426 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
427 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
428 return FALSE;
429 }
430 }
431 }
432
433 setWindowProc(windowClass->getWindowProc());
434 hInstance = cs->hInstance;
435 dwStyle = cs->style & ~WS_VISIBLE;
436 dwExStyle = cs->dwExStyle;
437
438 hwndLinkAfter = HWND_TOP;
439 if(WIDGETS_IsControl(this, BUTTON_CONTROL) && ((dwStyle & 0x0f) == BS_GROUPBOX))
440 {
441 hwndLinkAfter = HWND_BOTTOM;
442 dwStyle |= WS_CLIPSIBLINGS;
443 }
444 else
445 if(WIDGETS_IsControl(this, STATIC_CONTROL) && !(dwStyle & WS_GROUP)) {
446 dwStyle |= WS_CLIPSIBLINGS;
447 }
448
449 /* Increment class window counter */
450 windowClass->IncreaseWindowCount();
451
452 /* Correct the window style */
453 if (!(cs->style & WS_CHILD))
454 {
455 dwStyle |= WS_CLIPSIBLINGS;
456 if (!(cs->style & WS_POPUP))
457 {
458 dwStyle |= WS_CAPTION;
459 flags |= WIN_NEED_SIZE;
460 }
461 }
462 if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
463
464 //TODO?
465#if 0
466 /* Get class or window DC if needed */
467 if (classPtr->style & CS_OWNDC) dce = DCE_AllocDCE(hwnd,DCE_WINDOW_DC);
468 else if (classPtr->style & CS_CLASSDC) wndPtr->dce = classPtr->dce;
469 else wndPtr->dce = NULL;
470#endif
471
472 if (cs->style & WS_HSCROLL)
473 {
474 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
475 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
476 horzScrollInfo->MaxVal = 100;
477 horzScrollInfo->flags = ESB_ENABLE_BOTH;
478 }
479
480 if (cs->style & WS_VSCROLL)
481 {
482 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
483 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
484 vertScrollInfo->MaxVal = 100;
485 vertScrollInfo->flags = ESB_ENABLE_BOTH;
486 }
487
488 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
489 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
490 {
491 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
492 if (maxSize.x < cs->cx) cs->cx = maxSize.x;
493 if (maxSize.y < cs->cy) cs->cy = maxSize.y;
494 if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
495 if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
496 }
497
498 if(cs->style & WS_CHILD)
499 {
500 if(cs->cx < 0) cs->cx = 0;
501 if(cs->cy < 0) cs->cy = 0;
502 }
503 else
504 {
505 if (cs->cx <= 0) cs->cx = 1;
506 if (cs->cy <= 0) cs->cy = 1;
507 }
508
509 DWORD dwOSWinStyle, dwOSFrameStyle;
510
511 OSLibWinConvertStyle(dwStyle, &dwExStyle, &dwOSWinStyle, &dwOSFrameStyle, &borderWidth, &borderHeight);
512
513 rectWindow.left = cs->x;
514 rectWindow.top = cs->y;
515 rectWindow.right = cs->x + cs->cx;
516 rectWindow.bottom = cs->y + cs->cy;
517 rectClient = rectWindow;
518
519 if(HIWORD(cs->lpszName))
520 {
521 if(isUnicode)
522 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 if (wParam == Win32Hwnd)
1573 {
1574 HCURSOR hCursor = windowClass ? windowClass->getCursor():LoadCursorA(0,IDC_ARROWA);
1575
1576 if (hCursor) SetCursor(hCursor);
1577 return 1;
1578 } else return 0;
1579 }
1580 case WM_MOUSEMOVE:
1581 return 0; //we do our own cursor handling
1582
1583 case WM_WINDOWPOSCHANGED:
1584 {
1585
1586/* undocumented SWP flags - from SDK 3.1 */
1587#define SWP_NOCLIENTSIZE 0x0800
1588#define SWP_NOCLIENTMOVE 0x1000
1589
1590 PWINDOWPOS wpos = (PWINDOWPOS)lParam;
1591 WPARAM wp = SIZE_RESTORED;
1592
1593 if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE))
1594 SendMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
1595
1596 if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE))
1597 {
1598 if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
1599 else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
1600
1601 SendMessageA(WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left,
1602 rectClient.bottom - rectClient.top));
1603 }
1604 return 0;
1605 }
1606 case WM_WINDOWPOSCHANGING:
1607 return HandleWindowPosChanging((WINDOWPOS *)lParam);
1608
1609 case WM_ERASEBKGND:
1610 case WM_ICONERASEBKGND:
1611 {
1612 RECT rect;
1613 int rc;
1614
1615 if (!windowClass || !windowClass->getBackgroundBrush()) return 0;
1616
1617 rc = GetClipBox( (HDC)wParam, &rect );
1618 if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
1619 FillRect( (HDC)wParam, &rect, windowClass->getBackgroundBrush());
1620
1621 return 1;
1622 }
1623 case WM_GETDLGCODE:
1624 return 0;
1625
1626 case WM_NCLBUTTONDOWN:
1627 case WM_NCLBUTTONUP:
1628 case WM_NCLBUTTONDBLCLK:
1629 case WM_NCRBUTTONUP:
1630 case WM_NCRBUTTONDOWN:
1631 case WM_NCRBUTTONDBLCLK:
1632 case WM_NCMBUTTONDOWN:
1633 case WM_NCMBUTTONUP:
1634 case WM_NCMBUTTONDBLCLK:
1635 return 0; //TODO: Send WM_SYSCOMMAND if required
1636
1637 case WM_NCHITTEST: //TODO: Calculate position of
1638 return HTCLIENT;
1639
1640 case WM_SYSCOMMAND:
1641 {
1642 POINT point;
1643
1644 point.x = LOWORD(lParam);
1645 point.y = HIWORD(lParam);
1646 return HandleSysCommand(wParam, &point);
1647 }
1648
1649 case WM_SYSKEYDOWN:
1650 if(wParam == VK_F4) /* try to close the window */
1651 {
1652 Win32BaseWindow *window = GetTopParent();
1653 if(window && !(window->getClass()->getStyle() & CS_NOCLOSE))
1654 window->PostMessageA(WM_SYSCOMMAND, SC_CLOSE, 0);
1655 }
1656
1657 Win32BaseWindow *siblingWindow;
1658 HWND sibling;
1659 char nameBuffer [40], mnemonic;
1660 int nameLength;
1661
1662 GetWindowTextA (nameBuffer, 40);
1663
1664 // search all sibling to see it this key is their mnemonic
1665 sibling = GetWindow (GW_HWNDFIRST);
1666 while (sibling != 0) {
1667 siblingWindow = GetWindowFromHandle (sibling);
1668 nameLength = siblingWindow->GetWindowTextA (nameBuffer, 40);
1669
1670 // find the siblings mnemonic
1671 mnemonic = '\0';
1672 for (int i=0 ; i<nameLength ; i++) {
1673 if (nameBuffer [i] == '&') {
1674 mnemonic = nameBuffer [i+1];
1675 if ((mnemonic >= 'a') && (mnemonic <= 'z'))
1676 mnemonic -= 32; // make it uppercase
1677 break; // stop searching
1678 }
1679 }
1680
1681 // key matches siblings mnemonic, send mouseclick
1682 if (mnemonic == (char) wParam) {
1683 siblingWindow->SendMessageA (BM_CLICK, 0, 0);
1684 }
1685
1686 sibling = siblingWindow->GetNextWindow (GW_HWNDNEXT);
1687 }
1688
1689 return 0;
1690
1691 case WM_QUERYOPEN:
1692 case WM_QUERYENDSESSION:
1693 return 1;
1694
1695 case WM_NOTIFYFORMAT:
1696 if (IsUnicode()) return NFR_UNICODE;
1697 else return NFR_ANSI;
1698
1699 case WM_SETICON:
1700 case WM_GETICON:
1701 {
1702 LRESULT result = 0;
1703 if (!windowClass) return result;
1704 int index = GCL_HICON;
1705
1706 if (wParam == ICON_SMALL)
1707 index = GCL_HICONSM;
1708
1709 result = windowClass->getClassLongA(index);
1710
1711 if (Msg == WM_SETICON)
1712 windowClass->setClassLongA(index, lParam);
1713
1714 return result;
1715 }
1716 case WM_NOTIFY:
1717 return 0; //comctl32 controls expect this
1718
1719 default:
1720 if(Msg > WM_USER) {
1721 return 0;
1722 }
1723 return 1;
1724 }
1725}
1726//******************************************************************************
1727//******************************************************************************
1728LRESULT Win32BaseWindow::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam)
1729{
1730 switch(Msg)
1731 {
1732 case WM_GETTEXTLENGTH:
1733 return wndNameLength;
1734
1735 case WM_GETTEXT: //TODO: SS_ICON controls
1736 {
1737 LRESULT result;
1738 char *str = (char *) malloc(wParam + 1);
1739 result = DefWindowProcA(Msg, wParam, (LPARAM)str );
1740 lstrcpynAtoW( (LPWSTR)lParam, str, wParam );
1741 free(str);
1742 return result;
1743 }
1744
1745 case WM_SETTEXT:
1746 {
1747 if(!fInternalMsg)
1748 {
1749 LRESULT result;
1750 char *aText = (char *) malloc((lstrlenW((LPWSTR)lParam)+1)*sizeof(WCHAR));
1751 *aText = 0;
1752 lstrcpyWtoA(aText, (LPWSTR) lParam);
1753 result = SetWindowTextA(aText);
1754 free(aText);
1755 return result;
1756 }
1757 else return 0;
1758 }
1759
1760 default:
1761 return DefWindowProcA(Msg, wParam, lParam);
1762 }
1763}
1764//******************************************************************************
1765//******************************************************************************
1766LRESULT Win32BaseWindow::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
1767{
1768 LRESULT rc;
1769 BOOL fInternalMsgBackup = fInternalMsg;
1770
1771 //SvL: Some Wine controls send WM_COMMAND messages when they receive the focus -> apps don't like to
1772 // receive those before they get their WM_CREATE message
1773 //NOTE: May need to refuse more messages
1774 if(fCreated == FALSE && Msg == WM_COMMAND) {
1775 dprintf(("SendMessageA BEFORE creation! %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
1776 return 0;
1777 }
1778
1779 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, FALSE);
1780
1781 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
1782 return(0);
1783 }
1784 fInternalMsg = FALSE;
1785 switch(Msg)
1786 {
1787 case WM_CREATE:
1788 {
1789 if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1790 dprintf(("WM_CREATE returned -1\n"));
1791 rc = -1; //don't create window
1792 break;
1793 }
1794 NotifyParent(Msg, wParam, lParam);
1795
1796 rc = 0;
1797 break;
1798 }
1799 case WM_SETTEXT:
1800 rc = CallWindowProcA(win32wndproc, getWindowHandle(), WM_SETTEXT, wParam, lParam);
1801 break;
1802
1803 case WM_LBUTTONDOWN:
1804 case WM_MBUTTONDOWN:
1805 case WM_RBUTTONDOWN:
1806 NotifyParent(Msg, wParam, lParam);
1807 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1808 break;
1809
1810 case WM_DESTROY:
1811 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
1812 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1813 break;
1814
1815 default:
1816 rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
1817 break;
1818 }
1819 fInternalMsg = fInternalMsgBackup;
1820 return rc;
1821}
1822//******************************************************************************
1823//******************************************************************************
1824LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
1825{
1826 LRESULT rc;
1827 BOOL fInternalMsgBackup = fInternalMsg;
1828
1829 //SvL: Some Wine controls send WM_COMMAND messages when they receive the focus -> apps don't like to
1830 // receive those before they get their WM_CREATE message
1831 //NOTE: May need to refuse more messages
1832 if(fCreated == FALSE && Msg == WM_COMMAND) {
1833 dprintf(("SendMessageA BEFORE creation! %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
1834 return 0;
1835 }
1836
1837 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, FALSE);
1838
1839 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
1840 return(0);
1841 }
1842 fInternalMsg = FALSE;
1843 switch(Msg)
1844 {
1845 case WM_CREATE:
1846 {
1847 if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1848 dprintf(("WM_CREATE returned -1\n"));
1849 rc = -1; //don't create window
1850 break;
1851 }
1852 NotifyParent(Msg, wParam, lParam);
1853
1854 rc = 0;
1855 break;
1856 }
1857 case WM_SETTEXT:
1858 rc = CallWindowProcW(win32wndproc, getWindowHandle(), WM_SETTEXT, wParam, lParam);
1859 break;
1860
1861 case WM_LBUTTONDOWN:
1862 case WM_MBUTTONDOWN:
1863 case WM_RBUTTONDOWN:
1864 NotifyParent(Msg, wParam, lParam);
1865 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1866 break;
1867
1868 case WM_DESTROY:
1869 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
1870 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1871 break;
1872
1873 default:
1874 rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
1875 break;
1876 }
1877 fInternalMsg = fInternalMsgBackup;
1878 return rc;
1879}
1880//******************************************************************************
1881//Called as a result of an OS/2 message
1882//******************************************************************************
1883LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
1884{
1885 LRESULT rc;
1886 BOOL fInternalMsgBackup = fInternalMsg;
1887
1888 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE);
1889
1890 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
1891 return(0);
1892 }
1893 fInternalMsg = TRUE;
1894 switch(Msg)
1895 {
1896 case WM_CREATE:
1897 {
1898 if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1899 dprintf(("WM_CREATE returned -1\n"));
1900 rc = -1; //don't create window
1901 break;
1902 }
1903 NotifyParent(Msg, wParam, lParam);
1904 rc = 0;
1905 break;
1906 }
1907 case WM_LBUTTONDOWN:
1908 case WM_MBUTTONDOWN:
1909 case WM_RBUTTONDOWN:
1910 NotifyParent(Msg, wParam, lParam);
1911 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1912 break;
1913
1914 case WM_DESTROY:
1915 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
1916 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1917 break;
1918 default:
1919 rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
1920 break;
1921 }
1922 fInternalMsg = fInternalMsgBackup;
1923 return rc;
1924}
1925//******************************************************************************
1926//Called as a result of an OS/2 message
1927//todo, unicode msgs (WM_SETTEXT etc)
1928//******************************************************************************
1929LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
1930{
1931 LRESULT rc;
1932 BOOL fInternalMsgBackup = fInternalMsg;
1933
1934 DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE);
1935
1936 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
1937 return(0);
1938 }
1939 fInternalMsg = TRUE;
1940 switch(Msg)
1941 {
1942 case WM_CREATE:
1943 {
1944 if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1945 dprintf(("WM_CREATE returned -1\n"));
1946 rc = -1; //don't create window
1947 break;
1948 }
1949 NotifyParent(Msg, wParam, lParam);
1950 rc = 0;
1951 break;
1952 }
1953 case WM_LBUTTONDOWN:
1954 case WM_MBUTTONDOWN:
1955 case WM_RBUTTONDOWN:
1956 NotifyParent(Msg, wParam, lParam);
1957 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1958 break;
1959
1960 case WM_DESTROY:
1961 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
1962 rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1963 break;
1964 default:
1965 rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
1966 break;
1967 }
1968 fInternalMsg = fInternalMsgBackup;
1969 return rc;
1970}
1971//******************************************************************************
1972//******************************************************************************
1973BOOL Win32BaseWindow::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam)
1974{
1975 return OSLibPostMessage(OS2Hwnd, WIN32APP_USERMSGBASE+msg, wParam, lParam);
1976}
1977//******************************************************************************
1978//******************************************************************************
1979BOOL Win32BaseWindow::PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam)
1980{
1981 return OSLibPostMessage(OS2Hwnd, WIN32APP_USERMSGBASE+msg, wParam, lParam);
1982}
1983//******************************************************************************
1984//TODO: do we need to inform the parent of the parent (etc) of the child window?
1985//******************************************************************************
1986void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
1987{
1988 Win32BaseWindow *window = this;
1989 Win32BaseWindow *parentwindow;
1990
1991 while(window)
1992 {
1993 if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
1994 {
1995 /* Notify the parent window only */
1996 parentwindow = window->getParent();
1997 if(parentwindow) {
1998 if(Msg == WM_CREATE || Msg == WM_DESTROY) {
1999 parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle());
2000 }
2001 else parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );
2002 }
2003 }
2004 else break;
2005
2006 window = parentwindow;
2007 }
2008}
2009//******************************************************************************
2010//******************************************************************************
2011BOOL Win32BaseWindow::SetMenu(HMENU hMenu)
2012{
2013
2014 dprintf(("SetMenu %x", hMenu));
2015 OS2HwndMenu = OSLibWinSetMenu(OS2HwndFrame, hMenu);
2016 if(OS2HwndMenu == 0) {
2017 dprintf(("Win32BaseWindow::SetMenu OS2HwndMenu == 0"));
2018 return FALSE;
2019 }
2020 return TRUE;
2021}
2022//******************************************************************************
2023//******************************************************************************
2024BOOL Win32BaseWindow::SetAccelTable(HACCEL hAccel)
2025{
2026 Win32Resource *winres = (Win32Resource *)hAccel;
2027 HANDLE accelhandle;
2028
2029 if(HIWORD(hAccel) == 0) {
2030 dprintf(("SetAccelTable: hAccel %x invalid", hAccel));
2031 SetLastError(ERROR_INVALID_PARAMETER);
2032 return FALSE;
2033 }
2034 acceltableResource = winres;
2035 accelhandle = OSLibWinSetAccelTable(OS2HwndFrame, winres->getOS2Handle(), winres->lockOS2Resource());
2036 winres->setOS2Handle(accelhandle);
2037 return(accelhandle != 0);
2038}
2039//******************************************************************************
2040//******************************************************************************
2041BOOL Win32BaseWindow::SetIcon(HICON hIcon)
2042{
2043 dprintf(("Win32BaseWindow::SetIcon %x", hIcon));
2044 if(OSLibWinSetIcon(OS2HwndFrame, hIcon) == TRUE) {
2045//TODO: Wine does't send these. Correct?
2046// SendMessageA(WM_SETICON, ICON_BIG, hIcon);
2047 return TRUE;
2048 }
2049 return FALSE;
2050}
2051//******************************************************************************
2052//******************************************************************************
2053BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow)
2054{
2055 ULONG showstate = 0;
2056 HWND hWinAfter;
2057
2058 dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
2059#if 1
2060 if (flags & WIN_NEED_SIZE)
2061 {
2062 /* should happen only in CreateWindowEx() */
2063 int wParam = SIZE_RESTORED;
2064
2065 flags &= ~WIN_NEED_SIZE;
2066 if (dwStyle & WS_MAXIMIZE)
2067 wParam = SIZE_MAXIMIZED;
2068 else
2069 if (dwStyle & WS_MINIMIZE)
2070 wParam = SIZE_MINIMIZED;
2071
2072 SendMessageA(WM_SIZE, wParam,
2073 MAKELONG(rectClient.right-rectClient.left,
2074 rectClient.bottom-rectClient.top));
2075 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
2076 }
2077#else
2078 if(fFirstShow) {
2079 if(isFrameWindow() && IS_OVERLAPPED(getStyle()) && !isChild()) {
2080 SendMessageA(WM_SIZE, SIZE_RESTORED,
2081 MAKELONG(rectClient.right-rectClient.left,
2082 rectClient.bottom-rectClient.top));
2083 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
2084
2085 }
2086 fFirstShow = FALSE;
2087 }
2088#endif
2089 switch(nCmdShow)
2090 {
2091 case SW_SHOW:
2092 case SW_SHOWDEFAULT: //todo
2093 showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
2094 break;
2095 case SW_HIDE:
2096 showstate = SWPOS_HIDE;
2097 break;
2098 case SW_RESTORE:
2099 showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
2100 break;
2101 case SW_MINIMIZE:
2102 showstate = SWPOS_MINIMIZE;
2103 break;
2104 case SW_SHOWMAXIMIZED:
2105 showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
2106 break;
2107 case SW_SHOWMINIMIZED:
2108 showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
2109 break;
2110 case SW_SHOWMINNOACTIVE:
2111 showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
2112 break;
2113 case SW_SHOWNA:
2114 showstate = SWPOS_SHOW;
2115 break;
2116 case SW_SHOWNOACTIVATE:
2117 showstate = SWPOS_SHOW;
2118 break;
2119 case SW_SHOWNORMAL:
2120 showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
2121 break;
2122 }
2123
2124 /* We can't activate a child window (WINE) */
2125 if(getStyle() & WS_CHILD)
2126 showstate &= ~SWPOS_ACTIVATE;
2127
2128 if(showstate & SWPOS_SHOW) {
2129 setStyle(getStyle() | WS_VISIBLE);
2130 }
2131 else setStyle(getStyle() & ~WS_VISIBLE);
2132
2133 BOOL rc = OSLibWinShowWindow(OS2HwndFrame, showstate);
2134 return rc;
2135}
2136//******************************************************************************
2137//******************************************************************************
2138BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
2139{
2140 BOOL rc = FALSE;
2141 Win32BaseWindow *window;
2142 HWND hParent = 0;
2143
2144 dprintf (("SetWindowPos %x %x (%d,%d)(%d,%d) %x", Win32Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
2145
2146 if (fuFlags &
2147 ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
2148 SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED |
2149 SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS |
2150 SWP_NOOWNERZORDER))
2151 {
2152 return FALSE;
2153 }
2154
2155 WINDOWPOS wpos;
2156 SWP swp, swpOld;
2157
2158 wpos.flags = fuFlags;
2159 wpos.cy = cy;
2160 wpos.cx = cx;
2161 wpos.x = x;
2162 wpos.y = y;
2163 wpos.hwndInsertAfter = hwndInsertAfter;
2164 wpos.hwnd = getWindowHandle();
2165
2166 if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
2167 {
2168 if (isChild())
2169 {
2170 hParent = getParent()->getOS2WindowHandle();
2171 }
2172 OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
2173 }
2174
2175 OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame);
2176 if (swp.fl == 0)
2177 return TRUE;
2178
2179// if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
2180 if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
2181 {
2182 Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
2183 if(wndBehind) {
2184 swp.hwndInsertBehind = wndBehind->getOS2WindowHandle();
2185 }
2186 else {
2187 dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
2188 swp.hwndInsertBehind = 0;
2189 }
2190 }
2191#if 0
2192 if (isFrameWindow())
2193 {
2194 if (!isChild())
2195 {
2196 POINT maxSize, maxPos, minTrack, maxTrack;
2197
2198 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
2199
2200 if (swp.cx > maxTrack.x) swp.cx = maxTrack.x;
2201 if (swp.cy > maxTrack.y) swp.cy = maxTrack.y;
2202 if (swp.cx < minTrack.x) swp.cx = minTrack.x;
2203 if (swp.cy < minTrack.y) swp.cy = minTrack.y;
2204 }
2205 swp.hwnd = OS2HwndFrame;
2206 }
2207 else
2208#endif
2209 swp.hwnd = OS2HwndFrame;
2210
2211 dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
2212
2213 rc = OSLibWinSetMultWindowPos(&swp, 1);
2214
2215 if (rc == FALSE)
2216 {
2217 dprintf(("OSLibWinSetMultWindowPos failed!"));
2218 }
2219 else
2220 {
2221 if (fuFlags & SWP_FRAMECHANGED_W)
2222 OSLibSendMessage (OS2HwndFrame, 0x42 /*WM_UPDATEFRAME*/, -1, 0);
2223 }
2224
2225 return (rc);
2226}
2227//******************************************************************************
2228//TODO: WPF_RESTOREMAXIMIZED
2229//******************************************************************************
2230BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *winpos)
2231{
2232 if(isFrameWindow())
2233 {
2234 // Set the minimized position
2235 if (winpos->flags & WPF_SETMINPOSITION)
2236 {
2237 OSLibSetWindowMinPos(OS2HwndFrame, winpos->ptMinPosition.x, winpos->ptMinPosition.y);
2238 }
2239
2240 //TODO: Max position
2241
2242 // Set the new restore position.
2243 OSLibSetWindowRestoreRect(OS2HwndFrame, &winpos->rcNormalPosition);
2244 }
2245
2246 return ShowWindow(winpos->showCmd);
2247}
2248//******************************************************************************
2249//Also destroys all the child windows (destroy parent, destroy children)
2250//******************************************************************************
2251BOOL Win32BaseWindow::DestroyWindow()
2252{
2253 return OSLibWinDestroyWindow(OS2HwndFrame);
2254}
2255//******************************************************************************
2256//******************************************************************************
2257HWND Win32BaseWindow::GetParent()
2258{
2259 if(getParent()) {
2260 return getParent()->getWindowHandle();
2261 }
2262 else return 0;
2263}
2264//******************************************************************************
2265//******************************************************************************
2266HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
2267{
2268 HWND oldhwnd;
2269 Win32BaseWindow *newparent;
2270
2271 if(getParent()) {
2272 oldhwnd = getParent()->getWindowHandle();
2273 getParent()->RemoveChild(this);
2274 }
2275 else oldhwnd = 0;
2276
2277 newparent = GetWindowFromHandle(hwndNewParent);
2278 if(newparent)
2279 {
2280 setParent(newparent);
2281 getParent()->AddChild(this);
2282 OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
2283 return oldhwnd;
2284 }
2285 SetLastError(ERROR_INVALID_PARAMETER);
2286 return 0;
2287}
2288//******************************************************************************
2289//******************************************************************************
2290BOOL Win32BaseWindow::IsChild(HWND hwndParent)
2291{
2292 if(getParent()) {
2293 return getParent()->getWindowHandle() == hwndParent;
2294 }
2295 else return 0;
2296}
2297//******************************************************************************
2298//******************************************************************************
2299HWND Win32BaseWindow::GetTopWindow()
2300{
2301 return GetWindow(GW_CHILD);
2302}
2303//******************************************************************************
2304// Get the top-level parent for a child window.
2305//******************************************************************************
2306Win32BaseWindow *Win32BaseWindow::GetTopParent()
2307{
2308 Win32BaseWindow *window = this;
2309
2310 while(window && (window->getStyle() & WS_CHILD))
2311 {
2312 window = window->getParent();
2313 }
2314 return window;
2315}
2316//******************************************************************************
2317//Don't call WinUpdateWindow as that one also updates the child windows
2318//Also need to send WM_PAINT directly to the window procedure, which doesn't
2319//always happen with WinUpdateWindow (could be posted if thread doesn't own window)
2320//******************************************************************************
2321BOOL Win32BaseWindow::UpdateWindow()
2322{
2323 RECT rect;
2324
2325 if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect))
2326 {//update region not empty
2327 HDC hdc;
2328
2329 hdc = O32_GetDC(OS2Hwnd);
2330 if (isIcon)
2331 {
2332 SendMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
2333 SendMessageA(WM_PAINTICON, 0, 0);
2334 } else
2335 {
2336 SendMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
2337 SendMessageA(WM_PAINT, 0, 0);
2338 }
2339 O32_ReleaseDC(OS2Hwnd, hdc);
2340 }
2341 return TRUE;
2342}
2343//******************************************************************************
2344//******************************************************************************
2345BOOL Win32BaseWindow::IsIconic()
2346{
2347 return OSLibWinIsIconic(OS2Hwnd);
2348}
2349//******************************************************************************
2350//TODO: Should not enumerate children that are created during the enumeration!
2351//******************************************************************************
2352BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
2353{
2354 BOOL rc = TRUE;
2355 HWND hwnd;
2356 Win32BaseWindow *prevchild = 0, *child = 0;
2357
2358 dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
2359 for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2360 {
2361 dprintf(("EnumChildWindows: enumerating child %x", child->getWindowHandle()));
2362 hwnd = child->getWindowHandle();
2363 if(lpfn(hwnd, lParam) == FALSE)
2364 {
2365 rc = FALSE;
2366 break;
2367 }
2368 //check if the window still exists
2369 if(!::IsWindow(hwnd))
2370 {
2371 child = prevchild;
2372 continue;
2373 }
2374 if(child->getFirstChild() != NULL)
2375 {
2376 dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle()));
2377 if(child->EnumChildWindows(lpfn, lParam) == FALSE)
2378 {
2379 rc = FALSE;
2380 break;
2381 }
2382 }
2383 prevchild = child;
2384 }
2385 return rc;
2386}
2387//******************************************************************************
2388//******************************************************************************
2389Win32BaseWindow *Win32BaseWindow::FindWindowById(int id)
2390{
2391 for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
2392 {
2393 if (child->getWindowId() == id)
2394 {
2395 return child;
2396 }
2397 }
2398 return 0;
2399}
2400//******************************************************************************
2401//TODO:
2402//We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
2403//the current process owns them.
2404//******************************************************************************
2405HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
2406 BOOL fUnicode)
2407{
2408 Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
2409 Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
2410
2411 if((hwndParent != OSLIB_HWND_DESKTOP && !parent) ||
2412 (hwndChildAfter != 0 && !child) ||
2413 (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0))
2414 {
2415 dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
2416 SetLastError(ERROR_INVALID_WINDOW_HANDLE);
2417 return 0;
2418 }
2419 if(hwndParent != OSLIB_HWND_DESKTOP)
2420 {//if the current process owns the window, just do a quick search
2421 child = (Win32BaseWindow *)parent->getFirstChild();
2422 if(hwndChildAfter != 0)
2423 {
2424 while(child)
2425 {
2426 if(child->getWindowHandle() == hwndChildAfter)
2427 {
2428 child = (Win32BaseWindow *)child->getNextChild();
2429 break;
2430 }
2431 child = (Win32BaseWindow *)child->getNextChild();
2432 }
2433 }
2434 while(child)
2435 {
2436 if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
2437 (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
2438 {
2439 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
2440 return child->getWindowHandle();
2441 }
2442 child = (Win32BaseWindow *)child->getNextChild();
2443 }
2444 }
2445 else {
2446 Win32BaseWindow *wnd;
2447 HWND henum, hwnd;
2448
2449 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
2450 hwnd = OSLibWinGetNextWindow(henum);
2451
2452 while(hwnd)
2453 {
2454 wnd = GetWindowFromOS2Handle(hwnd);
2455 if(wnd == NULL) {
2456 hwnd = OSLibWinQueryClientWindow(hwnd);
2457 if(hwnd) wnd = GetWindowFromOS2Handle(hwnd);
2458 if(!hwnd) wnd = GetWindowFromOS2FrameHandle(hwnd);
2459 }
2460
2461 if(wnd) {
2462 if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
2463 (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
2464 {
2465 OSLibWinEndEnumWindows(henum);
2466 dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
2467 return wnd->getWindowHandle();
2468 }
2469 }
2470 hwnd = OSLibWinGetNextWindow(henum);
2471 }
2472 OSLibWinEndEnumWindows(henum);
2473 }
2474 SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
2475 return 0;
2476}
2477//******************************************************************************
2478//******************************************************************************
2479HWND Win32BaseWindow::GetWindow(UINT uCmd)
2480{
2481 HWND hwndRelated = 0;
2482 Win32BaseWindow *window;
2483
2484 switch(uCmd)
2485 {
2486 case GW_HWNDFIRST:
2487 if(getParent()) {
2488 window = (Win32BaseWindow *)getParent()->getFirstChild();
2489 hwndRelated = window->getWindowHandle();
2490 }
2491 break;
2492
2493 case GW_HWNDLAST:
2494 if(getParent())
2495 {
2496 goto end;
2497 }
2498
2499 window = this;
2500 while(window)
2501 {
2502 window = (Win32BaseWindow *)window->getNextChild();
2503 }
2504 hwndRelated = window->getWindowHandle();
2505 break;
2506
2507 case GW_HWNDNEXT:
2508 window = (Win32BaseWindow *)getNextChild();
2509 if(window) {
2510 hwndRelated = window->getWindowHandle();
2511 }
2512 break;
2513
2514 case GW_HWNDPREV:
2515 if(!getParent())
2516 {
2517 goto end;
2518 }
2519 window = (Win32BaseWindow *)(getParent()->getFirstChild()); /* First sibling */
2520 if(window == this)
2521 {
2522 hwndRelated = 0; /* First in list */
2523 goto end;
2524 }
2525 while(window->getNextChild())
2526 {
2527 if (window->getNextChild() == this)
2528 {
2529 hwndRelated = window->getWindowHandle();
2530 goto end;
2531 }
2532 window = (Win32BaseWindow *)window->getNextChild();
2533 }
2534 break;
2535
2536 case GW_OWNER:
2537 if(getOwner()) {
2538 hwndRelated = getOwner()->getWindowHandle();
2539 }
2540 break;
2541
2542 case GW_CHILD:
2543 if(getFirstChild()) {
2544 hwndRelated = ((Win32BaseWindow *)getFirstChild())->getWindowHandle();
2545 }
2546 break;
2547 }
2548end:
2549 dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
2550 return hwndRelated;
2551}
2552//******************************************************************************
2553//******************************************************************************
2554HWND Win32BaseWindow::SetActiveWindow()
2555{
2556 return OSLibWinSetActiveWindow(OS2HwndFrame);
2557}
2558//******************************************************************************
2559//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
2560//******************************************************************************
2561BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
2562{
2563 return OSLibWinEnableWindow(OS2HwndFrame, fEnable);
2564}
2565//******************************************************************************
2566//******************************************************************************
2567BOOL Win32BaseWindow::CloseWindow()
2568{
2569 return OSLibWinMinimizeWindow(OS2HwndFrame);
2570}
2571//******************************************************************************
2572//******************************************************************************
2573HWND Win32BaseWindow::GetActiveWindow()
2574{
2575 HWND hwndActive;
2576 Win32BaseWindow *win32wnd;
2577 ULONG magic;
2578
2579 hwndActive = OSLibWinQueryActiveWindow();
2580
2581 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32WNDPTR);
2582 magic = OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32PM_MAGIC);
2583 if(CheckMagicDword(magic) && win32wnd)
2584 {
2585 return win32wnd->getWindowHandle();
2586 }
2587 return hwndActive;
2588}
2589//******************************************************************************
2590//******************************************************************************
2591BOOL Win32BaseWindow::IsWindowEnabled()
2592{
2593 return OSLibWinIsWindowEnabled(OS2HwndFrame);
2594}
2595//******************************************************************************
2596//******************************************************************************
2597BOOL Win32BaseWindow::IsWindowVisible()
2598{
2599#if 1
2600 return (dwStyle & WS_VISIBLE) == WS_VISIBLE;
2601#else
2602 return OSLibWinIsWindowVisible(OS2HwndFrame);
2603#endif
2604}
2605//******************************************************************************
2606//******************************************************************************
2607BOOL Win32BaseWindow::GetWindowRect(PRECT pRect)
2608{
2609 return OSLibWinQueryWindowRect(OS2HwndFrame, pRect, RELATIVE_TO_SCREEN);
2610}
2611//******************************************************************************
2612//******************************************************************************
2613BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
2614{
2615 if(wndname == NULL)
2616 return FALSE;
2617
2618 if(fUnicode) {
2619 return (lstrcmpW(windowNameW, (LPWSTR)wndname) == 0);
2620 }
2621 else return (strcmp(windowNameA, wndname) == 0);
2622}
2623//******************************************************************************
2624//******************************************************************************
2625int Win32BaseWindow::GetWindowTextLength()
2626{
2627 return wndNameLength;
2628}
2629//******************************************************************************
2630//******************************************************************************
2631int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
2632{
2633 if(windowNameA == NULL) {
2634 *lpsz = 0;
2635 return 0;
2636 }
2637 strncpy(lpsz, windowNameA, cch);
2638 return wndNameLength;
2639}
2640//******************************************************************************
2641//******************************************************************************
2642int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
2643{
2644 if(windowNameW == NULL) {
2645 *lpsz = 0;
2646 return 0;
2647 }
2648 lstrcpynW((LPWSTR)lpsz, windowNameW, cch);
2649 return wndNameLength;
2650}
2651//******************************************************************************
2652//******************************************************************************
2653BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
2654{
2655 if(lpsz == NULL)
2656 return FALSE;
2657
2658 if(windowNameA) free(windowNameA);
2659 if(windowNameW) free(windowNameW);
2660
2661 windowNameA = (LPSTR)_smalloc(strlen(lpsz)+1);
2662 strcpy(windowNameA, lpsz);
2663 windowNameW = (LPWSTR)_smalloc((strlen(lpsz)+1)*sizeof(WCHAR));
2664 lstrcpyAtoW(windowNameW, windowNameA);
2665 wndNameLength = strlen(windowNameA)+1; //including 0 terminator
2666
2667 if(OS2HwndFrame)
2668 return OSLibWinSetWindowText(OS2HwndFrame, (LPSTR)windowNameA);
2669
2670 return TRUE;
2671}
2672//******************************************************************************
2673//******************************************************************************
2674BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
2675{
2676 if(lpsz == NULL)
2677 return FALSE;
2678
2679 if(windowNameA) free(windowNameA);
2680 if(windowNameW) free(windowNameW);
2681
2682 windowNameW = (LPWSTR)_smalloc((lstrlenW((LPWSTR)lpsz)+1)*sizeof(WCHAR));
2683 lstrcpyW(windowNameW, (LPWSTR)lpsz);
2684 windowNameA = (LPSTR)_smalloc(lstrlenW((LPWSTR)lpsz)+1);
2685 lstrcpyWtoA(windowNameA, windowNameW);
2686 wndNameLength = strlen(windowNameA)+1; //including 0 terminator
2687
2688 if(OS2HwndFrame)
2689 return OSLibWinSetWindowText(OS2HwndFrame, (LPSTR)windowNameA);
2690
2691 return TRUE;
2692}
2693//******************************************************************************
2694//******************************************************************************
2695LONG Win32BaseWindow::SetWindowLongA(int index, ULONG value)
2696{
2697 LONG oldval;
2698
2699 dprintf2(("SetWindowLongA %x %d %x", getWindowHandle(), index, value));
2700 switch(index) {
2701 case GWL_EXSTYLE:
2702 {
2703 STYLESTRUCT ss;
2704
2705 if(dwExStyle == value)
2706 return value;
2707
2708 ss.styleOld = dwExStyle;
2709 ss.styleNew = value;
2710 dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
2711 SendMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
2712 setExStyle(ss.styleNew);
2713 SendMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
2714 return ss.styleOld;
2715 }
2716 case GWL_STYLE:
2717 {
2718 STYLESTRUCT ss;
2719
2720 if(dwStyle == value)
2721 return value;
2722
2723 ss.styleOld = dwStyle;
2724 ss.styleNew = value;
2725 dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), dwStyle, value));
2726 SendMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
2727 setStyle(ss.styleNew);
2728 if(!IsWindowDestroyed())
2729 OSLibSetWindowStyle(OS2HwndFrame, ss.styleNew);
2730 SendMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
2731 return ss.styleOld;
2732 }
2733 case GWL_WNDPROC:
2734 oldval = (LONG)getWindowProc();
2735 setWindowProc((WNDPROC)value);
2736 return oldval;
2737 case GWL_HINSTANCE:
2738 oldval = hInstance;
2739 hInstance = value;
2740 return oldval;
2741 case GWL_HWNDPARENT:
2742 return SetParent((HWND)value);
2743 case GWL_ID:
2744 oldval = getWindowId();
2745 setWindowId(value);
2746 return oldval;
2747 case GWL_USERDATA:
2748 oldval = userData;
2749 userData = value;
2750 return oldval;
2751 default:
2752 if(index >= 0 && index/4 < nrUserWindowLong)
2753 {
2754 oldval = userWindowLong[index/4];
2755 userWindowLong[index/4] = value;
2756 return oldval;
2757 }
2758 SetLastError(ERROR_INVALID_PARAMETER);
2759 return 0;
2760 }
2761}
2762//******************************************************************************
2763//******************************************************************************
2764ULONG Win32BaseWindow::GetWindowLongA(int index)
2765{
2766 ULONG value;
2767
2768 switch(index) {
2769 case GWL_EXSTYLE:
2770 value = dwExStyle;
2771 break;
2772 case GWL_STYLE:
2773 value = dwStyle;
2774 break;
2775 case GWL_WNDPROC:
2776 value = (ULONG)getWindowProc();
2777 break;
2778 case GWL_HINSTANCE:
2779 value = hInstance;
2780 break;
2781 case GWL_HWNDPARENT:
2782 if(getParent()) {
2783 value = getParent()->getWindowHandle();
2784 }
2785 else value = 0;
2786 break;
2787 case GWL_ID:
2788 value = getWindowId();
2789 break;
2790 case GWL_USERDATA:
2791 value = userData;
2792 break;
2793 default:
2794 if(index >= 0 && index/4 < nrUserWindowLong)
2795 {
2796 value = userWindowLong[index/4];
2797 break;
2798 }
2799 SetLastError(ERROR_INVALID_PARAMETER);
2800 return 0;
2801 }
2802 dprintf2(("GetWindowLongA %x %d %x", getWindowHandle(), index, value));
2803 return value;
2804}
2805//******************************************************************************
2806//******************************************************************************
2807WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
2808{
2809 WORD oldval;
2810
2811 if(index >= 0 && index/4 < nrUserWindowLong)
2812 {
2813 oldval = ((WORD *)userWindowLong)[index/2];
2814 ((WORD *)userWindowLong)[index/2] = value;
2815 return oldval;
2816 }
2817 SetLastError(ERROR_INVALID_PARAMETER);
2818 return 0;
2819}
2820//******************************************************************************
2821//******************************************************************************
2822WORD Win32BaseWindow::GetWindowWord(int index)
2823{
2824 if(index >= 0 && index/4 < nrUserWindowLong)
2825 {
2826 return ((WORD *)userWindowLong)[index/2];
2827 }
2828 SetLastError(ERROR_INVALID_PARAMETER);
2829 return 0;
2830}
2831//******************************************************************************
2832//******************************************************************************
2833void Win32BaseWindow::setWindowId(DWORD id)
2834{
2835 windowId = id;
2836 OSLibSetWindowID(OS2HwndFrame, id);
2837}
2838//******************************************************************************
2839//******************************************************************************
2840Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
2841{
2842 Win32BaseWindow *window;
2843
2844 if(hwnd == NULL && windowDesktop)
2845 return windowDesktop;
2846
2847 if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
2848 return window;
2849 }
2850 else return NULL;
2851}
2852//******************************************************************************
2853//******************************************************************************
2854Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd)
2855{
2856 Win32BaseWindow *win32wnd;
2857 DWORD magic;
2858
2859 if(hwnd == OSLIB_HWND_DESKTOP)
2860 {
2861 return windowDesktop;
2862 }
2863
2864 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
2865 magic = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
2866
2867 if(win32wnd && CheckMagicDword(magic)) {
2868 return win32wnd;
2869 }
2870 return 0;
2871}
2872//******************************************************************************
2873//******************************************************************************
2874Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
2875{
2876 return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
2877}
2878//******************************************************************************
2879//******************************************************************************
2880HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd)
2881{
2882 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
2883
2884 if(window) {
2885 return window->getOS2WindowHandle();
2886 }
2887 else return hwnd;
2888}
2889//******************************************************************************
2890//******************************************************************************
2891HWND Win32BaseWindow::Win32ToOS2FrameHandle(HWND hwnd)
2892{
2893 Win32BaseWindow *window = GetWindowFromHandle(hwnd);
2894
2895 if(window) {
2896 return window->getOS2FrameWindowHandle();
2897 }
2898 else return hwnd;
2899}
2900//******************************************************************************
2901//******************************************************************************
2902HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd)
2903{
2904 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
2905
2906 if(window) {
2907 return window->getWindowHandle();
2908 }
2909 window = GetWindowFromOS2FrameHandle(hwnd);
2910 if(window) {
2911 return window->getWindowHandle();
2912 }
2913 else return 0;
2914// else return hwnd; //OS/2 window handle
2915}
2916//******************************************************************************
2917// GetNextDlgTabItem32 (USER32.276)
2918//******************************************************************************
2919HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
2920{
2921 Win32BaseWindow *child, *nextchild, *lastchild;
2922 HWND retvalue;
2923
2924 if (hwndCtrl)
2925 {
2926 child = GetWindowFromHandle(hwndCtrl);
2927 if (!child)
2928 {
2929 retvalue = 0;
2930 goto END;
2931 }
2932 /* Make sure hwndCtrl is a top-level child */
2933 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
2934 {
2935 child = child->getParent();
2936 if(child == NULL) break;
2937 }
2938
2939 if (!child || child->getParent() != this)
2940 {
2941 retvalue = 0;
2942 goto END;
2943 }
2944 }
2945 else
2946 {
2947 /* No ctrl specified -> start from the beginning */
2948 child = (Win32BaseWindow *)getFirstChild();
2949 if (!child)
2950 {
2951 retvalue = 0;
2952 goto END;
2953 }
2954
2955 if (!fPrevious)
2956 {
2957 while (child->getNextChild())
2958 {
2959 child = (Win32BaseWindow *)child->getNextChild();
2960 }
2961 }
2962 }
2963
2964 lastchild = child;
2965 nextchild = (Win32BaseWindow *)child->getNextChild();
2966 while (TRUE)
2967 {
2968 if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild();
2969
2970 if (child == nextchild) break;
2971
2972 if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) &&
2973 !(nextchild->getStyle() & WS_DISABLED))
2974 {
2975 lastchild = nextchild;
2976 if (!fPrevious) break;
2977 }
2978 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
2979 }
2980 retvalue = lastchild->getWindowHandle();
2981
2982END:
2983 return retvalue;
2984}
2985//******************************************************************************
2986//******************************************************************************
2987HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
2988{
2989 Win32BaseWindow *child, *nextchild, *lastchild;
2990 HWND retvalue;
2991
2992 if (hwndCtrl)
2993 {
2994 child = GetWindowFromHandle(hwndCtrl);
2995 if (!child)
2996 {
2997 retvalue = 0;
2998 goto END;
2999 }
3000 /* Make sure hwndCtrl is a top-level child */
3001 while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
3002 {
3003 child = child->getParent();
3004 if(child == NULL) break;
3005 }
3006
3007 if (!child || child->getParent() != this)
3008 {
3009 retvalue = 0;
3010 goto END;
3011 }
3012 }
3013 else
3014 {
3015 /* No ctrl specified -> start from the beginning */
3016 child = (Win32BaseWindow *)getFirstChild();
3017 if (!child)
3018 {
3019 retvalue = 0;
3020 goto END;
3021 }
3022
3023 if (fPrevious)
3024 {
3025 while (child->getNextChild())
3026 {
3027 child = (Win32BaseWindow *)child->getNextChild();
3028 }
3029 }
3030 }
3031
3032 lastchild = child;
3033 nextchild = (Win32BaseWindow *)child->getNextChild();
3034 while (TRUE)
3035 {
3036 if (!nextchild || nextchild->getStyle() & WS_GROUP)
3037 {
3038 /* Wrap-around to the beginning of the group */
3039 Win32BaseWindow *pWndTemp;
3040
3041 nextchild = (Win32BaseWindow *)getFirstChild();
3042
3043 for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild())
3044 {
3045 if (pWndTemp->getStyle() & WS_GROUP)
3046 nextchild = pWndTemp;
3047
3048 if (pWndTemp == child)
3049 break;
3050 }
3051
3052 }
3053 if (nextchild == child)
3054 break;
3055
3056 if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED))
3057 {
3058 lastchild = nextchild;
3059
3060 if (!fPrevious)
3061 break;
3062 }
3063
3064 nextchild = (Win32BaseWindow *)nextchild->getNextChild();
3065 }
3066 retvalue = lastchild->getWindowHandle();
3067END:
3068 return retvalue;
3069}
3070//******************************************************************************
3071//******************************************************************************
3072#ifdef DEBUG
3073void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
3074{
3075 char style[256] = "";
3076 char exstyle[256] = "";
3077
3078 /* Window styles */
3079 if(dwStyle & WS_CHILD)
3080 strcat(style, "WS_CHILD ");
3081 if(dwStyle & WS_POPUP)
3082 strcat(style, "WS_POPUP ");
3083 if(dwStyle & WS_VISIBLE)
3084 strcat(style, "WS_VISIBLE ");
3085 if(dwStyle & WS_DISABLED)
3086 strcat(style, "WS_DISABLED ");
3087 if(dwStyle & WS_CLIPSIBLINGS)
3088 strcat(style, "WS_CLIPSIBLINGS ");
3089 if(dwStyle & WS_CLIPCHILDREN)
3090 strcat(style, "WS_CLIPCHILDREN ");
3091 if(dwStyle & WS_MAXIMIZE)
3092 strcat(style, "WS_MAXIMIZE ");
3093 if(dwStyle & WS_MINIMIZE)
3094 strcat(style, "WS_MINIMIZE ");
3095 if(dwStyle & WS_GROUP)
3096 strcat(style, "WS_GROUP ");
3097 if(dwStyle & WS_TABSTOP)
3098 strcat(style, "WS_TABSTOP ");
3099
3100 if((dwStyle & WS_CAPTION) == WS_CAPTION)
3101 strcat(style, "WS_CAPTION ");
3102 if(dwStyle & WS_DLGFRAME)
3103 strcat(style, "WS_DLGFRAME ");
3104 if(dwStyle & WS_BORDER)
3105 strcat(style, "WS_BORDER ");
3106
3107 if(dwStyle & WS_VSCROLL)
3108 strcat(style, "WS_VSCROLL ");
3109 if(dwStyle & WS_HSCROLL)
3110 strcat(style, "WS_HSCROLL ");
3111 if(dwStyle & WS_SYSMENU)
3112 strcat(style, "WS_SYSMENU ");
3113 if(dwStyle & WS_THICKFRAME)
3114 strcat(style, "WS_THICKFRAME ");
3115 if(dwStyle & WS_MINIMIZEBOX)
3116 strcat(style, "WS_MINIMIZEBOX ");
3117 if(dwStyle & WS_MAXIMIZEBOX)
3118 strcat(style, "WS_MAXIMIZEBOX ");
3119
3120 if(dwExStyle & WS_EX_DLGMODALFRAME)
3121 strcat(exstyle, "WS_EX_DLGMODALFRAME ");
3122 if(dwExStyle & WS_EX_ACCEPTFILES)
3123 strcat(exstyle, "WS_EX_ACCEPTFILES ");
3124 if(dwExStyle & WS_EX_NOPARENTNOTIFY)
3125 strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
3126 if(dwExStyle & WS_EX_TOPMOST)
3127 strcat(exstyle, "WS_EX_TOPMOST ");
3128 if(dwExStyle & WS_EX_TRANSPARENT)
3129 strcat(exstyle, "WS_EX_TRANSPARENT ");
3130
3131 if(dwExStyle & WS_EX_MDICHILD)
3132 strcat(exstyle, "WS_EX_MDICHILD ");
3133 if(dwExStyle & WS_EX_TOOLWINDOW)
3134 strcat(exstyle, "WS_EX_TOOLWINDOW ");
3135 if(dwExStyle & WS_EX_WINDOWEDGE)
3136 strcat(exstyle, "WS_EX_WINDOWEDGE ");
3137 if(dwExStyle & WS_EX_CLIENTEDGE)
3138 strcat(exstyle, "WS_EX_CLIENTEDGE ");
3139 if(dwExStyle & WS_EX_CONTEXTHELP)
3140 strcat(exstyle, "WS_EX_CONTEXTHELP ");
3141 if(dwExStyle & WS_EX_RIGHT)
3142 strcat(exstyle, "WS_EX_RIGHT ");
3143 if(dwExStyle & WS_EX_LEFT)
3144 strcat(exstyle, "WS_EX_LEFT ");
3145 if(dwExStyle & WS_EX_RTLREADING)
3146 strcat(exstyle, "WS_EX_RTLREADING ");
3147 if(dwExStyle & WS_EX_LTRREADING)
3148 strcat(exstyle, "WS_EX_LTRREADING ");
3149 if(dwExStyle & WS_EX_LEFTSCROLLBAR)
3150 strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
3151 if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
3152 strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
3153 if(dwExStyle & WS_EX_CONTROLPARENT)
3154 strcat(exstyle, "WS_EX_CONTROLPARENT ");
3155 if(dwExStyle & WS_EX_STATICEDGE)
3156 strcat(exstyle, "WS_EX_STATICEDGE ");
3157 if(dwExStyle & WS_EX_APPWINDOW)
3158 strcat(exstyle, "WS_EX_APPWINDOW ");
3159
3160 dprintf(("Window style: %x %s", dwStyle, style));
3161 dprintf(("Window exStyle: %x %s", dwExStyle, exstyle));
3162}
3163#endif
3164//******************************************************************************
3165//******************************************************************************
3166
3167GenericObject *Win32BaseWindow::windows = NULL;
Note: See TracBrowser for help on using the repository browser.