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

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

* empty log message *

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