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

Last change on this file since 1802 was 1802, checked in by achimha, 26 years ago

fixed combo box behavior, added NULL check in Combo_HandleText

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