source: trunk/src/user32/new/win32wnd.cpp@ 398

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

Lots of changes: Solitaire now displays cards correctly

File size: 63.1 KB
Line 
1/* $Id: win32wnd.cpp,v 1.24 1999-07-26 20:03:49 sandervl Exp $ */
2/*
3 * Win32 Window Code for OS/2
4 *
5 *
6 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 * Parts based on Wine Windows code (windows\win.c)
9 *
10 * Copyright 1993, 1994 Alexandre Julliard
11 *
12 *
13 * Project Odin Software License can be found in LICENSE.TXT
14 *
15 */
16#include <os2win.h>
17#include <win.h>
18#include <stdlib.h>
19#include <string.h>
20#include <stdarg.h>
21#include <assert.h>
22#include <misc.h>
23#include <handlemanager.h>
24#include <win32wnd.h>
25#include <spy.h>
26#include "wndmsg.h"
27#include "hooks.h"
28#include <oslibwin.h>
29#include <oslibutil.h>
30#include <oslibgdi.h>
31#include <oslibres.h>
32#include <winres.h>
33#include "syscolor.h"
34
35#define HAS_DLGFRAME(style,exStyle) \
36 (((exStyle) & WS_EX_DLGMODALFRAME) || \
37 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
38
39#define HAS_THICKFRAME(style) \
40 (((style) & WS_THICKFRAME) && \
41 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
42
43#define HAS_BORDER(style, exStyle) \
44 ((style & WS_BORDER) || HAS_THICKFRAME(style) || HAS_DLGFRAME(style,exStyle))
45
46#define IS_OVERLAPPED(style) \
47 !(style & (WS_CHILD | WS_POPUP))
48
49//******************************************************************************
50//******************************************************************************
51Win32Window::Win32Window(DWORD objType) : GenericObject(&windows, objType)
52{
53 Init();
54}
55//******************************************************************************
56//******************************************************************************
57Win32Window::Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
58 : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
59{
60 Init();
61 this->isUnicode = isUnicode;
62 CreateWindowExA(lpCreateStructA, classAtom);
63}
64//******************************************************************************
65//******************************************************************************
66void Win32Window::Init()
67{
68 isUnicode = FALSE;
69 fCreated = FALSE;
70 fFirstShow = TRUE;
71
72 memset(windowNameA, 0, MAX_WINDOW_NAMELENGTH);
73 memset(windowNameW, 0, MAX_WINDOW_NAMELENGTH*sizeof(WCHAR));
74 wndNameLength = 0;
75
76 userWindowLong = NULL;;
77 nrUserWindowLong = 0;
78
79 magic = WIN32PM_MAGIC;
80 OS2Hwnd = 0;
81 OS2HwndFrame = 0;
82 OS2HwndMenu = 0;
83 Win32Hwnd = 0;
84
85 if(HMHandleAllocate(&Win32Hwnd, (ULONG)this) != 0)
86 {
87 dprintf(("Win32Window::Init HMHandleAllocate failed!!"));
88 DebugInt3();
89 }
90 Win32Hwnd &= 0xFFFF;
91 Win32Hwnd |= 0x68000000;
92
93 posx = posy = 0;
94 width = height = 0;
95
96 dwExStyle = 0;
97 dwStyle = 0;
98 win32wndproc = 0;
99 hInstance = 0;
100 windowId = 0xFFFFFFFF; //default = -1
101 userData = 0;
102
103 hwndLinkAfter = HWND_BOTTOM;
104 flags = 0;
105 isIcon = FALSE;
106 lastHitTestVal = 0;
107 owner = NULL;
108 windowClass = 0;
109
110 acceltableResource = NULL;
111 menuResource = NULL;
112 iconResource = NULL;
113}
114//******************************************************************************
115//todo get rid of resources (menu, accel, icon etc)
116//******************************************************************************
117Win32Window::~Win32Window()
118{
119 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
120 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
121
122 if(Win32Hwnd)
123 HMHandleFree(Win32Hwnd & 0xFFFF);
124 if(userWindowLong)
125 free(userWindowLong);
126}
127//******************************************************************************
128//******************************************************************************
129BOOL Win32Window::isChild()
130{
131 return (dwStyle & WS_CHILD) != 0;
132}
133//******************************************************************************
134//******************************************************************************
135BOOL Win32Window::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom)
136{
137 char buffer[256];
138 INT sw = SW_SHOW;
139 POINT maxSize, maxPos, minTrack, maxTrack;
140
141 SetLastError(0);
142
143 /* Find the parent window */
144 if (cs->hwndParent)
145 {
146 Win32Window *window = GetWindowFromHandle(cs->hwndParent);
147 if(!window) {
148 dprintf(("Bad parent %04x\n", cs->hwndParent ));
149 SetLastError(ERROR_INVALID_PARAMETER);
150 return FALSE;
151 }
152 /* Make sure parent is valid */
153 if (!window->IsWindow() )
154 {
155 dprintf(("Bad parent %04x\n", cs->hwndParent ));
156 SetLastError(ERROR_INVALID_PARAMETER);
157 return FALSE;
158 }
159 }
160 else
161 if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
162 dprintf(("No parent for child window\n" ));
163 SetLastError(ERROR_INVALID_PARAMETER);
164 return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
165 }
166
167 /* Find the window class */
168 windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
169 if (!windowClass)
170 {
171 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
172 dprintf(("Bad class '%s'\n", buffer ));
173 return 0;
174 }
175
176 /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
177 * with an atom as the class name, put some programs expect to have a *REAL* string in
178 * lpszClass when the CREATESTRUCT is sent with WM_CREATE
179 */
180 if (!HIWORD(cs->lpszClass) ) {
181 if (isUnicode) {
182 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
183 }
184 else {
185 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
186 }
187 cs->lpszClass = buffer;
188 }
189
190 /* Fix the coordinates */
191 if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16)
192 {
193// PDB *pdb = PROCESS_Current();
194
195 /* Never believe Microsoft's documentation... CreateWindowEx doc says
196 * that if an overlapped window is created with WS_VISIBLE style bit
197 * set and the x parameter is set to CW_USEDEFAULT, the system ignores
198 * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
199 * reveals that
200 *
201 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
202 * 2) it does not ignore the y parameter as the docs claim; instead, it
203 * uses it as second parameter to ShowWindow() unless y is either
204 * CW_USEDEFAULT or CW_USEDEFAULT16.
205 *
206 * The fact that we didn't do 2) caused bogus windows pop up when wine
207 * was running apps that were using this obscure feature. Example -
208 * calc.exe that comes with Win98 (only Win98, it's different from
209 * the one that comes with Win95 and NT)
210 */
211 if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) sw = cs->y;
212
213 /* We have saved cs->y, now we can trash it */
214#if 0
215 if ( !(cs->style & (WS_CHILD | WS_POPUP))
216 && (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
217 {
218 cs->x = pdb->env_db->startup_info->dwX;
219 cs->y = pdb->env_db->startup_info->dwY;
220 }
221#endif
222 cs->x = 0;
223 cs->y = 0;
224// }
225 }
226 if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16)
227 {
228#if 0
229 PDB *pdb = PROCESS_Current();
230 if ( !(cs->style & (WS_CHILD | WS_POPUP))
231 && (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )
232 {
233 cs->cx = pdb->env_db->startup_info->dwXSize;
234 cs->cy = pdb->env_db->startup_info->dwYSize;
235 }
236 else
237 {
238#endif
239 cs->cx = 600; /* FIXME */
240 cs->cy = 400;
241// }
242 }
243
244 if (cs->x < 0) cs->x = 0;
245 if (cs->y < 0) cs->y = 0;
246
247 //Allocate window words
248 nrUserWindowLong = windowClass->getExtraWndWords();
249 if(nrUserWindowLong) {
250 userWindowLong = (ULONG *)malloc(nrUserWindowLong);
251 memset(userWindowLong, 0, nrUserWindowLong);
252 }
253
254 if ((cs->style & WS_CHILD) && cs->hwndParent)
255 {
256 SetParent(cs->hwndParent);
257 }
258 else
259 {
260 if (!cs->hwndParent) {
261 owner = NULL;
262 }
263 else
264 {
265 owner = GetWindowFromHandle(cs->hwndParent);
266 if(owner == NULL)
267 {
268 dprintf(("HMHandleTranslateToOS2 couldn't find owner window %x!!!", cs->hwndParent));
269 return FALSE;
270 }
271 }
272 }
273
274 setWindowProc(windowClass->getWindowProc());
275 hInstance = cs->hInstance;
276 dwStyle = cs->style & ~WS_VISIBLE;
277 dwExStyle = cs->dwExStyle;
278
279 hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
280 ? HWND_BOTTOM : HWND_TOP;
281
282#if 0
283//TODO
284 /* Call the WH_CBT hook */
285
286 if (HOOK_IsHooked( WH_CBT ))
287 {
288 CBT_CREATEWNDA cbtc;
289 LRESULT ret;
290
291 cbtc.lpcs = cs;
292 cbtc.hwndInsertAfter = hwndLinkAfter;
293 ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc)
294 : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc);
295 if (ret)
296 {
297 TRACE_(win)("CBT-hook returned 0\n");
298 wndPtr->pDriver->pFinalize(wndPtr);
299 retvalue = 0;
300 goto end;
301 }
302 }
303#endif
304
305 /* Increment class window counter */
306 windowClass->IncreaseWindowCount();
307
308 /* Correct the window style */
309 if (!(cs->style & WS_CHILD))
310 {
311 dwStyle |= WS_CLIPSIBLINGS;
312 if (!(cs->style & WS_POPUP))
313 {
314 dwStyle |= WS_CAPTION;
315 flags |= WIN_NEED_SIZE;
316 }
317 }
318 if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
319
320 //TODO?
321#if 0
322 /* Get class or window DC if needed */
323 if (classPtr->style & CS_OWNDC) dce = DCE_AllocDCE(hwnd,DCE_WINDOW_DC);
324 else if (classPtr->style & CS_CLASSDC) wndPtr->dce = classPtr->dce;
325 else wndPtr->dce = NULL;
326#endif
327
328 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
329 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
330 {
331 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
332 if (maxSize.x < cs->cx) cs->cx = maxSize.x;
333 if (maxSize.y < cs->cy) cs->cy = maxSize.y;
334 if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
335 if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
336 }
337
338 if(cs->style & WS_CHILD)
339 {
340 if(cs->cx < 0) cs->cx = 0;
341 if(cs->cy < 0) cs->cy = 0;
342 }
343 else
344 {
345 if (cs->cx <= 0) cs->cx = 1;
346 if (cs->cy <= 0) cs->cy = 1;
347 }
348
349 rectWindow.left = cs->x;
350 rectWindow.top = cs->y;
351 rectWindow.right = cs->x + cs->cx;
352 rectWindow.bottom = cs->y + cs->cy;
353 rectClient = rectWindow;
354
355 DWORD dwOSWinStyle, dwOSFrameStyle;
356
357 OSLibWinConvertStyle(cs->style, cs->dwExStyle, &dwOSWinStyle, &dwOSFrameStyle);
358
359 //TODO: Test
360#if 1
361 if(cs->style & WS_CHILD) {
362 dwOSFrameStyle = 0;
363 }
364#endif
365
366 OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2FrameWindowHandle() : OSLIB_HWND_DESKTOP,
367 dwOSWinStyle, dwOSFrameStyle, (char *)cs->lpszName,
368 (owner) ? owner->getOS2FrameWindowHandle() : OSLIB_HWND_DESKTOP,
369 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
370 &OS2HwndFrame);
371
372 if(OS2Hwnd == 0) {
373 dprintf(("Window creation failed!!"));
374 return FALSE;
375 }
376
377 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
378 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
379 return FALSE;
380 }
381 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
382 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
383 return FALSE;
384 }
385#if 0
386 if(OS2Hwnd != OS2HwndFrame) {
387 if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
388 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame));
389 return FALSE;
390 }
391 if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
392 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
393 return FALSE;
394 }
395 }
396#endif
397
398 /* Set the window menu */
399 if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
400 {
401 if (cs->hMenu) SetMenu(cs->hMenu);
402 else
403 {
404 if (windowClass->getMenuNameA()) {
405 cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
406 if (cs->hMenu) SetMenu(cs->hMenu );
407 }
408 }
409 }
410 else windowId = (UINT)cs->hMenu;
411
412 //Set icon from class
413 if(windowClass->getIcon())
414 SetIcon(windowClass->getIcon());
415
416 if(getParent()) {
417 SetWindowPos(getParent()->getWindowHandle(), rectClient.left, rectClient.top,
418 rectClient.right-rectClient.left,
419 rectClient.bottom-rectClient.top,
420 SWP_NOACTIVATE);
421 }
422 else {
423 SetWindowPos(HWND_TOP, rectClient.left, rectClient.top,
424 rectClient.right-rectClient.left,
425 rectClient.bottom-rectClient.top,
426 SWP_NOACTIVATE);
427 }
428 //Get the client window rectangle
429 GetClientRect(Win32Hwnd, &rectClient);
430
431 /* Send the WM_CREATE message
432 * Perhaps we shouldn't allow width/height changes as well.
433 * See p327 in "Internals".
434 */
435 maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
436
437 fCreated = TRUE; //Allow WM_SIZE messages now
438 if(SendInternalMessage(WM_NCCREATE, 0, (LPARAM)cs) )
439 {
440 //doesn't work right, messes up client rectangle
441#if 0
442 SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
443#endif
444 OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
445 dprintf(("Sending WM_CREATE"));
446 if( (SendInternalMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 )
447 {
448 if(!(flags & WIN_NEED_SIZE)) {
449 SendMessageA(WM_SIZE, SIZE_RESTORED,
450 MAKELONG(rectClient.right-rectClient.left,
451 rectClient.bottom-rectClient.top));
452 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
453 }
454 if (cs->style & WS_VISIBLE) ShowWindow( sw );
455
456#if 0
457 /* Call WH_SHELL hook */
458
459 if (!(dwStyle & WS_CHILD) && !owner)
460 HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
461#endif
462 SetLastError(0);
463 return TRUE;
464 }
465 }
466 fCreated = FALSE;
467 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
468 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
469 DestroyWindow();
470 return FALSE;
471}
472#if 0
473/***********************************************************************
474 * WINPOS_MinMaximize
475 *
476 * Fill in lpRect and return additional flags to be used with SetWindowPos().
477 * This function assumes that 'cmd' is different from the current window
478 * state.
479 */
480UINT Win32Window::MinMaximize(UINT cmd, LPRECT lpRect )
481{
482 UINT swpFlags = 0;
483 POINT pt, size;
484 LPINTERNALPOS lpPos;
485
486 size.x = rectWindow.left; size.y = rectWindow.top;
487 lpPos = WINPOS_InitInternalPos( wndPtr, size, &rectWindow );
488
489 if (lpPos && !HOOK_CallHooks16(WH_CBT, HCBT_MINMAX, hwndSelf, cmd))
490 {
491 if( dwStyle & WS_MINIMIZE )
492 {
493 if( !SendInternalMessageA(WM_QUERYOPEN, 0, 0L ) )
494 return (SWP_NOSIZE | SWP_NOMOVE);
495 swpFlags |= SWP_NOCOPYBITS;
496 }
497 switch( cmd )
498 {
499 case SW_MINIMIZE:
500 if( dwStyle & WS_MAXIMIZE)
501 {
502 flags |= WIN_RESTORE_MAX;
503 dwStyle &= ~WS_MAXIMIZE;
504 }
505 else
506 flags &= ~WIN_RESTORE_MAX;
507 dwStyle |= WS_MINIMIZE;
508
509#if 0
510 if( flags & WIN_NATIVE )
511 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) )
512 swpFlags |= MINMAX_NOSWP;
513#endif
514
515 lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
516
517 SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
518 GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
519 swpFlags |= SWP_NOCOPYBITS;
520 break;
521
522 case SW_MAXIMIZE:
523 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
524
525 if( dwStyle & WS_MINIMIZE )
526 {
527 if( flags & WIN_NATIVE )
528 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
529 swpFlags |= MINMAX_NOSWP;
530
531 WINPOS_ShowIconTitle( wndPtr, FALSE );
532 dwStyle &= ~WS_MINIMIZE;
533 }
534 dwStyle |= WS_MAXIMIZE;
535
536 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
537 size.x, size.y );
538 break;
539
540 case SW_RESTORE:
541 if( dwStyle & WS_MINIMIZE )
542 {
543 if( flags & WIN_NATIVE )
544 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
545 swpFlags |= MINMAX_NOSWP;
546
547 dwStyle &= ~WS_MINIMIZE;
548 WINPOS_ShowIconTitle( wndPtr, FALSE );
549
550 if( flags & WIN_RESTORE_MAX)
551 {
552 /* Restore to maximized position */
553 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
554 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
555 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
556 dwStyle |= WS_MAXIMIZE;
557 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
558 break;
559 }
560 }
561 else
562 if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
563 else dwStyle &= ~WS_MAXIMIZE;
564
565 /* Restore to normal position */
566
567 *lpRect = lpPos->rectNormal;
568 lpRect->right -= lpRect->left;
569 lpRect->bottom -= lpRect->top;
570
571 break;
572 }
573 } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
574 return swpFlags;
575}
576#endif
577/*******************************************************************
578 * GetMinMaxInfo
579 *
580 * Get the minimized and maximized information for a window.
581 */
582void Win32Window::GetMinMaxInfo(POINT *maxSize, POINT *maxPos,
583 POINT *minTrack, POINT *maxTrack )
584{
585 MINMAXINFO MinMax;
586 INT xinc, yinc;
587
588 /* Compute default values */
589
590 MinMax.ptMaxSize.x = GetSystemMetrics(SM_CXSCREEN);
591 MinMax.ptMaxSize.y = GetSystemMetrics(SM_CYSCREEN);
592 MinMax.ptMinTrackSize.x = GetSystemMetrics(SM_CXMINTRACK);
593 MinMax.ptMinTrackSize.y = GetSystemMetrics(SM_CYMINTRACK);
594 MinMax.ptMaxTrackSize.x = GetSystemMetrics(SM_CXSCREEN);
595 MinMax.ptMaxTrackSize.y = GetSystemMetrics(SM_CYSCREEN);
596
597 if (flags & WIN_MANAGED) xinc = yinc = 0;
598 else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
599 {
600 xinc = GetSystemMetrics(SM_CXDLGFRAME);
601 yinc = GetSystemMetrics(SM_CYDLGFRAME);
602 }
603 else
604 {
605 xinc = yinc = 0;
606 if (HAS_THICKFRAME(dwStyle))
607 {
608 xinc += GetSystemMetrics(SM_CXFRAME);
609 yinc += GetSystemMetrics(SM_CYFRAME);
610 }
611 if (dwStyle & WS_BORDER)
612 {
613 xinc += GetSystemMetrics(SM_CXBORDER);
614 yinc += GetSystemMetrics(SM_CYBORDER);
615 }
616 }
617 MinMax.ptMaxSize.x += 2 * xinc;
618 MinMax.ptMaxSize.y += 2 * yinc;
619
620#if 0
621 lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos );
622 if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
623 CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
624 else
625 {
626#endif
627 MinMax.ptMaxPosition.x = -xinc;
628 MinMax.ptMaxPosition.y = -yinc;
629// }
630
631 SendInternalMessageA(WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
632
633 /* Some sanity checks */
634
635 dprintf(("GetMinMaxInfo: %ld %ld / %ld %ld / %ld %ld / %ld %ld\n",
636 MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
637 MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
638 MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
639 MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y));
640 MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
641 MinMax.ptMinTrackSize.x );
642 MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
643 MinMax.ptMinTrackSize.y );
644
645 if (maxSize) *maxSize = MinMax.ptMaxSize;
646 if (maxPos) *maxPos = MinMax.ptMaxPosition;
647 if (minTrack) *minTrack = MinMax.ptMinTrackSize;
648 if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
649}
650/***********************************************************************
651 * WINPOS_SendNCCalcSize
652 *
653 * Send a WM_NCCALCSIZE message to a window.
654 * All parameters are read-only except newClientRect.
655 * oldWindowRect, oldClientRect and winpos must be non-NULL only
656 * when calcValidRect is TRUE.
657 */
658LONG Win32Window::SendNCCalcSize(BOOL calcValidRect, RECT *newWindowRect, RECT *oldWindowRect,
659 RECT *oldClientRect, WINDOWPOS *winpos,
660 RECT *newClientRect )
661{
662 NCCALCSIZE_PARAMS params;
663 WINDOWPOS winposCopy;
664 LONG result;
665
666 params.rgrc[0] = *newWindowRect;
667 if (calcValidRect)
668 {
669 winposCopy = *winpos;
670 params.rgrc[1] = *oldWindowRect;
671 params.rgrc[2] = *oldClientRect;
672 params.lppos = &winposCopy;
673 }
674 result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect,
675 (LPARAM)&params );
676 *newClientRect = params.rgrc[0];
677 return result;
678}
679//******************************************************************************
680//******************************************************************************
681ULONG Win32Window::MsgCreate(HWND hwndOS2, ULONG initParam)
682{
683 OS2Hwnd = hwndOS2;
684 return SendInternalMessageA(WM_CREATE, 0, initParam);
685}
686//******************************************************************************
687//******************************************************************************
688ULONG Win32Window::MsgQuit()
689{
690 return SendInternalMessageA(WM_QUIT, 0, 0);
691}
692//******************************************************************************
693//******************************************************************************
694ULONG Win32Window::MsgClose()
695{
696 if(SendInternalMessageA(WM_CLOSE, 0, 0) == 0) {
697 return 0; //app handles this message
698 }
699 delete this;
700 return 1;
701}
702//******************************************************************************
703//******************************************************************************
704ULONG Win32Window::MsgDestroy()
705{
706 ULONG rc;
707
708 rc = SendInternalMessageA(WM_DESTROY, 0, 0);
709 delete this;
710 return rc;
711}
712//******************************************************************************
713//******************************************************************************
714ULONG Win32Window::MsgEnable(BOOL fEnable)
715{
716 return SendInternalMessageA(WM_ENABLE, fEnable, 0);
717}
718//******************************************************************************
719//TODO: SW_PARENTCLOSING/OPENING flag (lParam)
720//******************************************************************************
721ULONG Win32Window::MsgShow(BOOL fShow)
722{
723 return SendInternalMessageA(WM_SHOWWINDOW, fShow, 0);
724}
725//******************************************************************************
726//******************************************************************************
727ULONG Win32Window::MsgMove(ULONG x, ULONG y)
728{
729 dprintf(("MsgMove to (%d,%d)", x, y));
730 if(fCreated == FALSE) {
731 return 1;
732 }
733
734 return SendInternalMessageA(WM_MOVE, 0, MAKELONG((USHORT)x, (USHORT)y));
735}
736//******************************************************************************
737//******************************************************************************
738ULONG Win32Window::MsgCommand(ULONG cmd, ULONG Id, HWND hwnd)
739{
740 switch(cmd) {
741 case CMD_MENU:
742 return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0);
743 case CMD_CONTROL:
744 return 0; //todo
745 case CMD_ACCELERATOR:
746 dprintf(("accelerator command"));
747 return 0; //todo
748 }
749 return 0;
750}
751//******************************************************************************
752//******************************************************************************
753ULONG Win32Window::MsgHitTest(ULONG x, ULONG y)
754{
755 lastHitTestVal = SendInternalMessageA(WM_NCHITTEST, 0, MAKELONG((USHORT)x, (USHORT)y));
756 return 1; //TODO: May need to change this
757}
758//******************************************************************************
759//TODO: Send WM_NCCALCSIZE message here and correct size if necessary
760//******************************************************************************
761ULONG Win32Window::MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize)
762{
763 WORD fwSizeType = 0;
764
765 if(fCreated == FALSE) {//Solitaire crashes if it receives a WM_SIZE during CreateWindowEx (normal or our fault?)
766 return 1;
767 }
768
769 if(fMinimize) {
770 fwSizeType = SIZE_MINIMIZED;
771 }
772 else
773 if(fMaximize) {
774 fwSizeType = SIZE_MAXIMIZED;
775 }
776 else fwSizeType = SIZE_RESTORED;
777
778 return SendInternalMessageA(WM_SIZE, fwSizeType, MAKELONG((USHORT)width, (USHORT)height));
779}
780//******************************************************************************
781//******************************************************************************
782ULONG Win32Window::MsgActivate(BOOL fActivate, HWND hwnd)
783{
784 if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE)
785 {
786 if(!fActivate) {
787 return 1;
788 }
789 }
790 return SendInternalMessageA(WM_ACTIVATE, (fActivate) ? WA_ACTIVE : WA_INACTIVE, hwnd);
791}
792//******************************************************************************
793//******************************************************************************
794ULONG Win32Window::MsgSysCommand(ULONG win32sc, ULONG x, ULONG y)
795{
796 return SendInternalMessageA(WM_SYSCOMMAND, win32sc, MAKELONG((USHORT)x, (USHORT)y));
797}
798//******************************************************************************
799//TODO: virtual key & (possibly) scancode translation, extended keyboard bit & Unicode
800//******************************************************************************
801ULONG Win32Window::MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags)
802{
803 ULONG lParam = 0;
804
805 lParam = repeatcnt;
806 lParam |= (scancode << 16);
807 if(keyflags & KEY_ALTDOWN)
808 lParam |= (1<<29);
809 if(keyflags & KEY_PREVDOWN)
810 lParam |= (1<<30);
811 if(keyflags & KEY_UP)
812 lParam |= (1<<31);
813 if(keyflags & KEY_DEADKEY) {
814 dprintf(("WM_DEADCHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
815 return SendInternalMessageA(WM_DEADCHAR, cmd, lParam);
816 }
817 else {
818 dprintf(("WM_CHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
819 return SendInternalMessageA(WM_CHAR, cmd, lParam);
820 }
821}
822//******************************************************************************
823//******************************************************************************
824ULONG Win32Window::MsgSetFocus(HWND hwnd)
825{
826 if(hwnd == 0) {
827 //other app lost focus
828 SendInternalMessageA(WM_ACTIVATEAPP, TRUE, 0); //TODO: Need thread id from hwnd app
829 }
830 return SendInternalMessageA(WM_SETFOCUS, hwnd, 0);
831}
832//******************************************************************************
833//******************************************************************************
834ULONG Win32Window::MsgKillFocus(HWND hwnd)
835{
836 if(hwnd == 0) {
837 //other app lost focus
838 SendInternalMessageA(WM_ACTIVATEAPP, FALSE, 0); //TODO: Need thread id from hwnd app
839 }
840 return SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
841}
842//******************************************************************************
843//******************************************************************************
844ULONG Win32Window::MsgButton(ULONG msg, ULONG x, ULONG y)
845{
846 ULONG win32msg;
847 ULONG win32ncmsg;
848
849 dprintf(("MsgButton to (%d,%d)", x, y));
850 switch(msg) {
851 case BUTTON_LEFTDOWN:
852 win32msg = WM_LBUTTONDOWN;
853 win32ncmsg = WM_NCLBUTTONDOWN;
854 break;
855 case BUTTON_LEFTUP:
856 win32msg = WM_LBUTTONUP;
857 win32ncmsg = WM_NCLBUTTONUP;
858 break;
859 case BUTTON_LEFTDBLCLICK:
860 win32msg = WM_LBUTTONDBLCLK;
861 win32ncmsg = WM_NCLBUTTONDBLCLK;
862 break;
863 case BUTTON_RIGHTUP:
864 win32msg = WM_RBUTTONUP;
865 win32ncmsg = WM_NCRBUTTONUP;
866 break;
867 case BUTTON_RIGHTDOWN:
868 win32msg = WM_RBUTTONDOWN;
869 win32ncmsg = WM_NCRBUTTONDOWN;
870 break;
871 case BUTTON_RIGHTDBLCLICK:
872 win32msg = WM_RBUTTONDBLCLK;
873 win32ncmsg = WM_NCRBUTTONDBLCLK;
874 break;
875 case BUTTON_MIDDLEUP:
876 win32msg = WM_MBUTTONUP;
877 win32ncmsg = WM_NCMBUTTONUP;
878 break;
879 case BUTTON_MIDDLEDOWN:
880 win32msg = WM_MBUTTONDOWN;
881 win32ncmsg = WM_NCMBUTTONDOWN;
882 break;
883 case BUTTON_MIDDLEDBLCLICK:
884 win32msg = WM_MBUTTONDBLCLK;
885 win32ncmsg = WM_NCMBUTTONDBLCLK;
886 break;
887 default:
888 dprintf(("Win32Window::Button: invalid msg!!!!"));
889 return 1;
890 }
891 if(win32msg == WM_MBUTTONDBLCLK || win32msg == WM_RBUTTONDBLCLK || win32msg == WM_LBUTTONDBLCLK) {
892 if(!(windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)) {
893 return 1;
894 }
895 }
896 SendInternalMessageA(win32ncmsg, lastHitTestVal, MAKELONG(x, y)); //TODO:
897 return SendInternalMessageA(win32msg, 0, MAKELONG(x, y));
898}
899//******************************************************************************
900//******************************************************************************
901ULONG Win32Window::MsgMouseMove(ULONG keystate, ULONG x, ULONG y)
902{
903 ULONG winstate = 0;
904
905 if(keystate & WMMOVE_LBUTTON)
906 winstate |= MK_LBUTTON;
907 if(keystate & WMMOVE_RBUTTON)
908 winstate |= MK_RBUTTON;
909 if(keystate & WMMOVE_MBUTTON)
910 winstate |= MK_MBUTTON;
911 if(keystate & WMMOVE_SHIFT)
912 winstate |= MK_SHIFT;
913 if(keystate & WMMOVE_CTRL)
914 winstate |= MK_CONTROL;
915
916 return SendInternalMessageA(WM_MOUSEMOVE, keystate, MAKELONG(x, y));
917}
918//******************************************************************************
919//******************************************************************************
920ULONG Win32Window::MsgPaint(ULONG tmp1, ULONG tmp2)
921{
922 return SendInternalMessageA(WM_PAINT, 0, 0);
923}
924//******************************************************************************
925//******************************************************************************
926ULONG Win32Window::MsgEraseBackGround(ULONG hps)
927{
928 if(isIcon) {
929 return SendInternalMessageA(WM_ICONERASEBKGND, hps, 0);
930 }
931 else return SendInternalMessageA(WM_ERASEBKGND, hps, 0);
932}
933//******************************************************************************
934//******************************************************************************
935ULONG Win32Window::MsgSetText(LPSTR lpsz, LONG cch)
936{
937 if(isUnicode) {
938 return SendInternalMessageW(WM_SETTEXT, 0, (LPARAM)lpsz);
939 }
940 else return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
941}
942//******************************************************************************
943//TODO: in- or excluding terminating 0?
944//******************************************************************************
945ULONG Win32Window::MsgGetTextLength()
946{
947 return SendInternalMessageA(WM_GETTEXTLENGTH, 0, 0);
948}
949//******************************************************************************
950//******************************************************************************
951char *Win32Window::MsgGetText()
952{
953 if(isUnicode) {
954 SendInternalMessageW(WM_GETTEXT, MAX_WINDOW_NAMELENGTH, (LPARAM)windowNameW);
955 }
956 else {
957 SendInternalMessageA(WM_GETTEXT, MAX_WINDOW_NAMELENGTH, (LPARAM)windowNameA);
958 }
959 return windowNameA;
960}
961//******************************************************************************
962//******************************************************************************
963LRESULT Win32Window::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam)
964{
965 switch(Msg)
966 {
967 case WM_GETTEXTLENGTH:
968 return wndNameLength;
969
970 case WM_GETTEXT: //TODO: SS_ICON controls
971 strncpy((LPSTR)lParam, windowNameA, wParam);
972 return min(wndNameLength, wParam);
973
974 case WM_SETTEXT:
975 return 0;
976
977 case WM_SETREDRAW:
978 if(wParam)
979 SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) | WS_VISIBLE);
980 else SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE);
981
982 return 0; //TODO
983
984 case WM_NCCREATE:
985 return(TRUE);
986
987 case WM_CTLCOLORMSGBOX:
988 case WM_CTLCOLOREDIT:
989 case WM_CTLCOLORLISTBOX:
990 case WM_CTLCOLORBTN:
991 case WM_CTLCOLORDLG:
992 case WM_CTLCOLORSTATIC:
993 case WM_CTLCOLORSCROLLBAR:
994 SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
995 SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
996 return GetSysColorBrush(COLOR_BTNFACE);
997
998 case WM_PARENTNOTIFY:
999 return 0;
1000
1001 case WM_MOUSEACTIVATE:
1002 {
1003 DWORD dwStyle = GetWindowLongA(GWL_STYLE);
1004 DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
1005 dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
1006 if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
1007 {
1008 if(getParent()) {
1009 LRESULT rc = getParent()->SendMessageA(WM_MOUSEACTIVATE, wParam, lParam );
1010 if(rc) return rc;
1011 }
1012 }
1013 return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
1014 }
1015 case WM_SETCURSOR:
1016 {
1017 DWORD dwStyle = GetWindowLongA(GWL_STYLE);
1018 DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
1019 dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
1020 if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
1021 {
1022 if(getParent()) {
1023 LRESULT rc = getParent()->SendMessageA(WM_SETCURSOR, wParam, lParam);
1024 if(rc) return rc;
1025 }
1026 }
1027 return 1;
1028 }
1029 case WM_MOUSEMOVE:
1030 return 0;
1031
1032 case WM_ERASEBKGND:
1033 case WM_ICONERASEBKGND:
1034 return 0;
1035
1036 case WM_NCLBUTTONDOWN:
1037 case WM_NCLBUTTONUP:
1038 case WM_NCLBUTTONDBLCLK:
1039 case WM_NCRBUTTONUP:
1040 case WM_NCRBUTTONDOWN:
1041 case WM_NCRBUTTONDBLCLK:
1042 case WM_NCMBUTTONDOWN:
1043 case WM_NCMBUTTONUP:
1044 case WM_NCMBUTTONDBLCLK:
1045 return 0; //TODO: Send WM_SYSCOMMAND if required
1046
1047 case WM_NCHITTEST: //TODO:
1048 return 0;
1049
1050 default:
1051 return 1;
1052 }
1053}
1054//******************************************************************************
1055//******************************************************************************
1056LRESULT Win32Window::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam)
1057{
1058 switch(Msg)
1059 {
1060 case WM_GETTEXTLENGTH:
1061 return wndNameLength;
1062
1063 case WM_GETTEXT: //TODO: SS_ICON controls
1064 lstrcpynW((LPWSTR)lParam, windowNameW, wParam);
1065 return min(wndNameLength, wParam);
1066
1067 default:
1068 return DefWindowProcA(Msg, wParam, lParam);
1069 }
1070}
1071//******************************************************************************
1072//******************************************************************************
1073LRESULT Win32Window::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
1074{
1075 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
1076 dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
1077
1078 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
1079 return(0);
1080 }
1081 switch(Msg)
1082 {
1083 case WM_CREATE:
1084 {
1085 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
1086 dprintf(("WM_NCCREATE returned FALSE\n"));
1087 return(-1); //don't create window
1088 }
1089 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
1090 dprintf(("WM_CREATE returned -1\n"));
1091 return(-1); //don't create window
1092 }
1093 NotifyParent(Msg, wParam, lParam);
1094
1095 return(0);
1096 }
1097 case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
1098 return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
1099
1100 case WM_LBUTTONDOWN:
1101 case WM_MBUTTONDOWN:
1102 case WM_RBUTTONDOWN:
1103 NotifyParent(Msg, wParam, lParam);
1104 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1105
1106 case WM_DESTROY:
1107 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
1108 NotifyParent(Msg, wParam, lParam);
1109 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1110 default:
1111 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1112 }
1113}
1114//******************************************************************************
1115//******************************************************************************
1116LRESULT Win32Window::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
1117{
1118 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
1119 dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
1120
1121 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
1122 return(0);
1123 }
1124 switch(Msg)
1125 {
1126 case WM_CREATE:
1127 {
1128 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
1129 dprintf(("WM_NCCREATE returned FALSE\n"));
1130 return(0); //don't create window
1131 }
1132 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
1133 dprintf(("WM_CREATE returned FALSE\n"));
1134 return(0); //don't create window
1135 }
1136 NotifyParent(Msg, wParam, lParam);
1137
1138 return(1);
1139 }
1140 case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
1141 return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
1142
1143 case WM_LBUTTONDOWN:
1144 case WM_MBUTTONDOWN:
1145 case WM_RBUTTONDOWN:
1146 NotifyParent(Msg, wParam, lParam);
1147 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1148
1149 case WM_DESTROY:
1150 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
1151 NotifyParent(Msg, wParam, lParam);
1152 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1153
1154 default:
1155 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1156 }
1157}
1158//******************************************************************************
1159//Called as a result of an OS/2 message
1160//******************************************************************************
1161LRESULT Win32Window::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
1162{
1163 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
1164 dprintf(("SendInternalMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
1165
1166 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
1167 return(0);
1168 }
1169 switch(Msg)
1170 {
1171 case WM_CREATE:
1172 {
1173 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
1174 dprintf(("WM_NCCREATE returned FALSE\n"));
1175 return(0); //don't create window
1176 }
1177 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
1178 dprintf(("WM_CREATE returned FALSE\n"));
1179 return(0); //don't create window
1180 }
1181 NotifyParent(Msg, wParam, lParam);
1182
1183 return(1);
1184 }
1185 case WM_LBUTTONDOWN:
1186 case WM_MBUTTONDOWN:
1187 case WM_RBUTTONDOWN:
1188 NotifyParent(Msg, wParam, lParam);
1189 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1190
1191 case WM_DESTROY:
1192 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
1193 NotifyParent(Msg, wParam, lParam);
1194 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1195 default:
1196 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1197 }
1198}
1199//******************************************************************************
1200//Called as a result of an OS/2 message
1201//todo, unicode msgs (WM_SETTEXT etc)
1202//******************************************************************************
1203LRESULT Win32Window::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
1204{
1205 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
1206 dprintf(("SendInternalMessageW %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
1207
1208 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
1209 return(0);
1210 }
1211 switch(Msg)
1212 {
1213 case WM_CREATE:
1214 {
1215 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
1216 dprintf(("WM_NCCREATE returned FALSE\n"));
1217 return(0); //don't create window
1218 }
1219 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
1220 dprintf(("WM_CREATE returned FALSE\n"));
1221 return(0); //don't create window
1222 }
1223 NotifyParent(Msg, wParam, lParam);
1224
1225 return(1);
1226 }
1227 case WM_LBUTTONDOWN:
1228 case WM_MBUTTONDOWN:
1229 case WM_RBUTTONDOWN:
1230 NotifyParent(Msg, wParam, lParam);
1231 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1232
1233 case WM_DESTROY:
1234 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
1235 NotifyParent(Msg, wParam, lParam);
1236 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
1237 default:
1238 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
1239 }
1240}
1241//******************************************************************************
1242//******************************************************************************
1243BOOL Win32Window::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam)
1244{
1245 POSTMSG_PACKET *postmsg;
1246
1247 postmsg = (POSTMSG_PACKET *)malloc(sizeof(POSTMSG_PACKET));
1248 if(postmsg == NULL) {
1249 dprintf(("Win32Window::PostMessageA: malloc returned NULL!!"));
1250 return 0;
1251 }
1252 postmsg->Msg = msg;
1253 postmsg->wParam = wParam;
1254 postmsg->lParam = lParam;
1255 return OSLibPostMessage(OS2Hwnd, WM_WIN32_POSTMESSAGEA, (ULONG)postmsg, 0);
1256}
1257//******************************************************************************
1258//******************************************************************************
1259BOOL Win32Window::PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam)
1260{
1261 POSTMSG_PACKET *postmsg;
1262
1263 postmsg = (POSTMSG_PACKET *)malloc(sizeof(POSTMSG_PACKET));
1264 if(postmsg == NULL) {
1265 dprintf(("Win32Window::PostMessageW: malloc returned NULL!!"));
1266 return 0;
1267 }
1268 postmsg->Msg = msg;
1269 postmsg->wParam = wParam;
1270 postmsg->lParam = lParam;
1271 return OSLibPostMessage(OS2Hwnd, WM_WIN32_POSTMESSAGEW, (ULONG)postmsg, 0);
1272}
1273//******************************************************************************
1274//TODO: do we need to inform the parent of the parent (etc) of the child window?
1275//******************************************************************************
1276void Win32Window::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
1277{
1278 Win32Window *window = this;
1279 Win32Window *parentwindow;
1280
1281 while(window)
1282 {
1283 if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
1284 {
1285 /* Notify the parent window only */
1286 parentwindow = window->getParent();
1287 if(parentwindow) {
1288 if(Msg == WM_CREATE || Msg == WM_DESTROY) {
1289 parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle());
1290 }
1291 else parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );
1292 }
1293 }
1294 else break;
1295
1296 window = parentwindow;
1297 }
1298}
1299//******************************************************************************
1300//******************************************************************************
1301BOOL Win32Window::SetMenu(HMENU hMenu)
1302{
1303 PVOID menutemplate;
1304 Win32Resource *winres = (Win32Resource *)hMenu;
1305
1306 dprintf(("SetMenu %x", hMenu));
1307 if(HIWORD(winres) == 0) {
1308 dprintf(("Win32Window:: Win32Resource *winres == 0"));
1309 SetLastError(ERROR_INVALID_PARAMETER);
1310 return FALSE;
1311 }
1312 menutemplate = winres->lockOS2Resource();
1313 if(menutemplate == NULL)
1314 {
1315 dprintf(("Win32Window::SetMenu menutemplate == 0"));
1316 return FALSE;
1317 }
1318 OS2HwndMenu = OSLibWinCreateMenu(OS2HwndFrame, menutemplate);
1319 if(OS2HwndMenu == 0) {
1320 dprintf(("Win32Window::SetMenu OS2HwndMenu == 0"));
1321 return FALSE;
1322 }
1323 menuResource = winres;
1324 return TRUE;
1325}
1326//******************************************************************************
1327//******************************************************************************
1328BOOL Win32Window::SetAccelTable(HACCEL hAccel)
1329{
1330 Win32Resource *winres = (Win32Resource *)hAccel;
1331 HANDLE accelhandle;
1332
1333 if(HIWORD(hAccel) == 0) {
1334 dprintf(("SetAccelTable: hAccel %x invalid", hAccel));
1335 SetLastError(ERROR_INVALID_PARAMETER);
1336 return FALSE;
1337 }
1338 acceltableResource = winres;
1339 accelhandle = OSLibWinSetAccelTable(OS2HwndFrame, winres->getOS2Handle(), winres->lockOS2Resource());
1340 winres->setOS2Handle(accelhandle);
1341 return(accelhandle != 0);
1342}
1343//******************************************************************************
1344//******************************************************************************
1345BOOL Win32Window::SetIcon(HICON hIcon)
1346{
1347 Win32Resource *winres = (Win32Resource *)hIcon;
1348 HANDLE iconhandle;
1349
1350 if(HIWORD(hIcon) == 0) {
1351 dprintf(("SetIcon: hIcon %x invalid", hIcon));
1352 SetLastError(ERROR_INVALID_PARAMETER);
1353 return FALSE;
1354 }
1355 dprintf(("Win32Window::SetIcon %x", hIcon));
1356 iconResource = winres;
1357 iconhandle = OSLibWinSetIcon(OS2HwndFrame, winres->getOS2Handle(), winres->lockOS2Resource());
1358 winres->setOS2Handle(iconhandle);
1359 return(iconhandle != 0);
1360}
1361//******************************************************************************
1362//******************************************************************************
1363BOOL Win32Window::ShowWindow(ULONG nCmdShow)
1364{
1365 ULONG showstate = 0;
1366
1367 dprintf(("ShowWindow %x", nCmdShow));
1368 if(fFirstShow) {
1369 if(isFrameWindow() && IS_OVERLAPPED(getStyle())) {
1370 SendMessageA(WM_SIZE, SIZE_RESTORED,
1371 MAKELONG(rectClient.right-rectClient.left,
1372 rectClient.bottom-rectClient.top));
1373 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
1374
1375 }
1376 fFirstShow = FALSE;
1377 }
1378 switch(nCmdShow)
1379 {
1380 case SW_SHOW:
1381 case SW_SHOWDEFAULT: //todo
1382 showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
1383 break;
1384 case SW_HIDE:
1385 showstate = SWPOS_HIDE;
1386 break;
1387 case SW_RESTORE:
1388 showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
1389 break;
1390 case SW_MINIMIZE:
1391 showstate = SWPOS_MINIMIZE;
1392 break;
1393 case SW_SHOWMAXIMIZED:
1394 showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
1395 break;
1396 case SW_SHOWMINIMIZED:
1397 showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
1398 break;
1399 case SW_SHOWMINNOACTIVE:
1400 showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
1401 break;
1402 case SW_SHOWNA:
1403 showstate = SWPOS_SHOW;
1404 break;
1405 case SW_SHOWNOACTIVATE:
1406 showstate = SWPOS_SHOW;
1407 break;
1408 case SW_SHOWNORMAL:
1409 showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
1410 break;
1411 }
1412 return OSLibWinShowWindow(OS2HwndFrame, showstate);
1413}
1414//******************************************************************************
1415//******************************************************************************
1416BOOL Win32Window::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
1417{
1418 Win32Window *window;
1419 ULONG setstate = 0;
1420
1421 switch(hwndInsertAfter) {
1422 case HWND_BOTTOM:
1423 hwndInsertAfter = HWNDOS_BOTTOM;
1424 break;
1425 case HWND_TOPMOST: //TODO
1426 case HWND_NOTOPMOST: //TODO:
1427 case HWND_TOP:
1428 hwndInsertAfter = HWNDOS_TOP;
1429 break;
1430 default:
1431 window = GetWindowFromHandle(hwndInsertAfter);
1432 if(window) {
1433 hwndInsertAfter = window->getOS2WindowHandle();
1434 PRECT clientRect = window->getClientRect();
1435
1436#if 1
1437 if(x+cx > clientRect->right - clientRect->left) {
1438 dprintf(("Adjusting cx from %d to %d", cx, (clientRect->right - clientRect->left) - x));
1439 cx = (clientRect->right - clientRect->left) - x;
1440 }
1441 if(y+cy > clientRect->bottom - clientRect->top) {
1442 dprintf(("Adjusting cy from %d to %d", cy, (clientRect->bottom - clientRect->top) - y));
1443 cy = (clientRect->bottom - clientRect->top) - y;
1444 }
1445#endif
1446 //Correct coordinates if parent is a frame window (border adjustment)
1447 //TODO: Not quite right (Solitaire child window placement slightly wrong)
1448 if (window->isFrameWindow() && !(fuFlags & SWP_NOMOVE)) {
1449 if (HAS_DLGFRAME(window->getStyle(), window->getExStyle() ))
1450 {
1451 x += GetSystemMetrics(SM_CXDLGFRAME);
1452 y -= GetSystemMetrics(SM_CYDLGFRAME);
1453 }
1454 else
1455 {
1456 if (HAS_THICKFRAME(window->getStyle()))
1457 {
1458 x += GetSystemMetrics(SM_CXFRAME);
1459 y -= GetSystemMetrics(SM_CYFRAME);
1460 }
1461 else
1462 if (window->getStyle() & WS_BORDER)
1463 {
1464 x += GetSystemMetrics(SM_CXBORDER);
1465 y -= GetSystemMetrics(SM_CYBORDER);
1466 }
1467 }
1468 }
1469 }
1470 else {
1471 dprintf(("Win32Window::SetWindowPos, unknown hwndInsertAfter %x", hwndInsertAfter));
1472 hwndInsertAfter = 0;
1473 }
1474
1475 break;
1476
1477 }
1478 setstate = SWPOS_MOVE | SWPOS_SIZE | SWPOS_ACTIVATE | SWPOS_ZORDER;
1479 if(fuFlags & SWP_DRAWFRAME)
1480 setstate |= 0; //TODO
1481 if(fuFlags & SWP_FRAMECHANGED)
1482 setstate |= 0; //TODO
1483 if(fuFlags & SWP_HIDEWINDOW)
1484 setstate &= ~SWPOS_ZORDER;
1485 if(fuFlags & SWP_NOACTIVATE)
1486 setstate &= ~SWPOS_ACTIVATE;
1487 if(fuFlags & SWP_NOCOPYBITS)
1488 setstate |= 0; //TODO
1489 if(fuFlags & SWP_NOMOVE)
1490 setstate &= ~SWPOS_MOVE;
1491 if(fuFlags & SWP_NOSIZE)
1492 setstate &= ~SWPOS_SIZE;
1493 if(fuFlags & SWP_NOREDRAW)
1494 setstate |= SWPOS_NOREDRAW;
1495 if(fuFlags & SWP_NOZORDER)
1496 setstate &= ~SWPOS_ZORDER;
1497 if(fuFlags & SWP_SHOWWINDOW)
1498 setstate |= SWPOS_SHOW;
1499
1500 //TODO send NCCREATE if size changed or SWP_FRAMECHANGED flag specified.
1501 return OSLibWinSetWindowPos(OS2HwndFrame, hwndInsertAfter, x, y, cx, cy, setstate);
1502}
1503//******************************************************************************
1504//Also destroys all the child windows (destroy parent, destroy children)
1505//******************************************************************************
1506BOOL Win32Window::DestroyWindow()
1507{
1508 return OSLibWinDestroyWindow(OS2HwndFrame);
1509}
1510//******************************************************************************
1511//******************************************************************************
1512HWND Win32Window::GetParent()
1513{
1514 if(getParent()) {
1515 return getParent()->getWindowHandle();
1516 }
1517 else return 0;
1518}
1519//******************************************************************************
1520//******************************************************************************
1521HWND Win32Window::SetParent(HWND hwndNewParent)
1522{
1523 HWND oldhwnd;
1524 Win32Window *newparent;
1525
1526 if(getParent()) {
1527 oldhwnd = getParent()->getWindowHandle();
1528 }
1529 else oldhwnd = 0;
1530
1531 if(hwndNewParent == 0) {//desktop window = parent
1532 setParent(NULL);
1533 OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
1534 return oldhwnd;
1535 }
1536 newparent = GetWindowFromHandle(hwndNewParent);
1537 if(newparent)
1538 {
1539 setParent(newparent);
1540 OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
1541 return oldhwnd;
1542 }
1543 SetLastError(ERROR_INVALID_PARAMETER);
1544 return 0;
1545}
1546//******************************************************************************
1547//******************************************************************************
1548BOOL Win32Window::IsChild(HWND hwndParent)
1549{
1550 if(getParent()) {
1551 return getParent()->getWindowHandle() == hwndParent;
1552 }
1553 else return 0;
1554}
1555//******************************************************************************
1556//******************************************************************************
1557HWND Win32Window::GetTopWindow()
1558{
1559 return GetWindow(GW_CHILD);
1560}
1561//******************************************************************************
1562//Don't call WinUpdateWindow as that one also updates the child windows
1563//Also need to send WM_PAINT directly to the window procedure, which doesn't
1564//always happen with WinUpdateWindow (could be posted if thread doesn't own window)
1565//******************************************************************************
1566BOOL Win32Window::UpdateWindow()
1567{
1568 RECT rect;
1569
1570 if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect))
1571 {//update region not empty
1572 SendInternalMessageA((isIcon) ? WM_PAINTICON : WM_PAINT, 0, 0);
1573 }
1574 return TRUE;
1575}
1576//******************************************************************************
1577//******************************************************************************
1578BOOL Win32Window::IsIconic()
1579{
1580 return OSLibWinIsIconic(OS2Hwnd);
1581}
1582//******************************************************************************
1583//TODO: not complete nor correct (distinction between top-level, top-most & child windows)
1584//******************************************************************************
1585HWND Win32Window::GetWindow(UINT uCmd)
1586{
1587 Win32Window *win32wnd;
1588 ULONG magic;
1589 ULONG getcmd = 0;
1590 HWND hwndRelated;
1591
1592 dprintf(("GetWindow %x %d NOT COMPLETE", getWindowHandle(), uCmd));
1593 switch(uCmd)
1594 {
1595 case GW_CHILD:
1596 getcmd = QWOS_TOP;
1597 break;
1598 case GW_HWNDFIRST:
1599 if(getParent()) {
1600 getcmd = QWOS_TOP; //top of child windows
1601 }
1602 else getcmd = QWOS_TOP; //TODO
1603 break;
1604 case GW_HWNDLAST:
1605 if(getParent()) {
1606 getcmd = QWOS_BOTTOM; //bottom of child windows
1607 }
1608 else getcmd = QWOS_BOTTOM; //TODO
1609 break;
1610 case GW_HWNDNEXT:
1611 getcmd = QWOS_NEXT;
1612 break;
1613 case GW_HWNDPREV:
1614 getcmd = QWOS_PREV;
1615 break;
1616 case GW_OWNER:
1617 if(owner) {
1618 return owner->getWindowHandle();
1619 }
1620 else return 0;
1621 }
1622 hwndRelated = OSLibWinQueryWindow(OS2Hwnd, getcmd);
1623 if(hwndRelated)
1624 {
1625 win32wnd = (Win32Window *)OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32WNDPTR);
1626 magic = OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC);
1627 if(CheckMagicDword(magic) && win32wnd)
1628 {
1629 return win32wnd->getWindowHandle();
1630 }
1631 }
1632 return 0;
1633}
1634//******************************************************************************
1635//******************************************************************************
1636HWND Win32Window::SetActiveWindow()
1637{
1638 return OSLibWinSetActiveWindow(OS2Hwnd);
1639}
1640//******************************************************************************
1641//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
1642//******************************************************************************
1643BOOL Win32Window::EnableWindow(BOOL fEnable)
1644{
1645 return OSLibWinEnableWindow(OS2Hwnd, fEnable);
1646}
1647//******************************************************************************
1648//******************************************************************************
1649BOOL Win32Window::CloseWindow()
1650{
1651 return OSLibWinMinimizeWindow(OS2Hwnd);
1652}
1653//******************************************************************************
1654//******************************************************************************
1655HWND Win32Window::GetActiveWindow()
1656{
1657 HWND hwndActive;
1658 Win32Window *win32wnd;
1659 ULONG magic;
1660
1661 hwndActive = OSLibWinQueryActiveWindow();
1662
1663 win32wnd = (Win32Window *)OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32WNDPTR);
1664 magic = OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32PM_MAGIC);
1665 if(CheckMagicDword(magic) && win32wnd)
1666 {
1667 return win32wnd->getWindowHandle();
1668 }
1669 return hwndActive;
1670}
1671//******************************************************************************
1672//******************************************************************************
1673BOOL Win32Window::IsWindow()
1674{
1675 return TRUE;
1676}
1677//******************************************************************************
1678//******************************************************************************
1679BOOL Win32Window::IsWindowEnabled()
1680{
1681 return OSLibWinIsWindowEnabled(OS2Hwnd);
1682}
1683//******************************************************************************
1684//******************************************************************************
1685BOOL Win32Window::IsWindowVisible()
1686{
1687 return OSLibWinIsWindowVisible(OS2Hwnd);
1688}
1689//******************************************************************************
1690//******************************************************************************
1691BOOL Win32Window::GetWindowRect(PRECT pRect)
1692{
1693 return OSLibWinQueryWindowRect(OS2Hwnd, pRect, RELATIVE_TO_SCREEN);
1694}
1695//******************************************************************************
1696//******************************************************************************
1697int Win32Window::GetWindowTextLengthA()
1698{
1699 return OSLibWinQueryWindowTextLength(OS2Hwnd);
1700}
1701//******************************************************************************
1702//******************************************************************************
1703int Win32Window::GetWindowTextA(LPSTR lpsz, int cch)
1704{
1705 return OSLibWinQueryWindowText(OS2Hwnd, cch, lpsz);
1706}
1707//******************************************************************************
1708//******************************************************************************
1709BOOL Win32Window::SetWindowTextA(LPCSTR lpsz)
1710{
1711 return OSLibWinSetWindowText(OS2Hwnd, (LPSTR)lpsz);
1712}
1713//******************************************************************************
1714//******************************************************************************
1715LONG Win32Window::SetWindowLongA(int index, ULONG value)
1716{
1717 LONG oldval;
1718
1719 switch(index) {
1720 case GWL_EXSTYLE:
1721 oldval = dwExStyle;
1722 dwExStyle = value;
1723 return oldval;
1724 case GWL_STYLE:
1725 oldval = dwStyle;
1726 dwStyle = value;
1727 return oldval;
1728 case GWL_WNDPROC:
1729 oldval = (LONG)getWindowProc();
1730 setWindowProc((WNDPROC)value);
1731 return oldval;
1732 case GWL_HINSTANCE:
1733 oldval = hInstance;
1734 hInstance = value;
1735 return oldval;
1736 case GWL_HWNDPARENT:
1737 return SetParent((HWND)value);
1738
1739 case GWL_ID:
1740 oldval = getWindowId();
1741 setWindowId(value);
1742 return oldval;
1743 case GWL_USERDATA:
1744 oldval = userData;
1745 userData = value;
1746 return oldval;
1747 default:
1748 if(index >= 0 && index/4 < nrUserWindowLong)
1749 {
1750 oldval = userWindowLong[index/4];
1751 userWindowLong[index/4] = value;
1752 return oldval;
1753 }
1754 SetLastError(ERROR_INVALID_PARAMETER);
1755 return 0;
1756 }
1757}
1758//******************************************************************************
1759//******************************************************************************
1760ULONG Win32Window::GetWindowLongA(int index)
1761{
1762 switch(index) {
1763 case GWL_EXSTYLE:
1764 return dwExStyle;
1765 case GWL_STYLE:
1766 return dwStyle;
1767 case GWL_WNDPROC:
1768 return (ULONG)getWindowProc();
1769 case GWL_HINSTANCE:
1770 return hInstance;
1771 case GWL_HWNDPARENT:
1772 if(getParent()) {
1773 return getParent()->getWindowHandle();
1774 }
1775 else return 0;
1776 case GWL_ID:
1777 return getWindowId();
1778 case GWL_USERDATA:
1779 return userData;
1780 default:
1781 if(index >= 0 && index/4 < nrUserWindowLong)
1782 {
1783 return userWindowLong[index/4];
1784 }
1785 SetLastError(ERROR_INVALID_PARAMETER);
1786 return 0;
1787 }
1788}
1789//******************************************************************************
1790//******************************************************************************
1791WORD Win32Window::SetWindowWord(int index, WORD value)
1792{
1793 WORD oldval;
1794
1795 if(index >= 0 && index/4 < nrUserWindowLong)
1796 {
1797 oldval = ((WORD *)userWindowLong)[index/2];
1798 ((WORD *)userWindowLong)[index/2] = value;
1799 return oldval;
1800 }
1801 SetLastError(ERROR_INVALID_PARAMETER);
1802 return 0;
1803}
1804//******************************************************************************
1805//******************************************************************************
1806WORD Win32Window::GetWindowWord(int index)
1807{
1808 if(index >= 0 && index/4 < nrUserWindowLong)
1809 {
1810 return ((WORD *)userWindowLong)[index/2];
1811 }
1812 SetLastError(ERROR_INVALID_PARAMETER);
1813 return 0;
1814}
1815//******************************************************************************
1816//******************************************************************************
1817Win32Window *Win32Window::GetWindowFromHandle(HWND hwnd)
1818{
1819 Win32Window *window;
1820
1821 if(HIWORD(hwnd) != 0x6800) {
1822 return NULL;
1823 }
1824
1825 if(HMHandleTranslateToOS2(LOWORD(hwnd), (PULONG)&window) == NO_ERROR) {
1826 return window;
1827 }
1828 else return NULL;
1829}
1830//******************************************************************************
1831//******************************************************************************
1832Win32Window *Win32Window::GetWindowFromOS2Handle(HWND hwnd)
1833{
1834 Win32Window *win32wnd;
1835 DWORD magic;
1836
1837 win32wnd = (Win32Window *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
1838 magic = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
1839
1840 if(win32wnd && CheckMagicDword(magic)) {
1841 return win32wnd;
1842 }
1843 return 0;
1844}
1845//******************************************************************************
1846//******************************************************************************
1847GenericObject *Win32Window::windows = NULL;
Note: See TracBrowser for help on using the repository browser.