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

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

SetWindowPos, UpdateWindow & WS_VISIBLE fixes/changes

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