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

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

fixed window text handling

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