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

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

* empty log message *

File size: 41.9 KB
Line 
1/* $Id: win32wnd.cpp,v 1.8 1999-07-17 18:30:51 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
31#define HAS_DLGFRAME(style,exStyle) \
32 (((exStyle) & WS_EX_DLGMODALFRAME) || \
33 (((style) & WS_DLGFRAME) && !((style) & WS_BORDER)))
34
35#define HAS_THICKFRAME(style) \
36 (((style) & WS_THICKFRAME) && \
37 !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
38
39//******************************************************************************
40//******************************************************************************
41Win32Window::Win32Window(DWORD objType) : GenericObject(&windows, objType)
42{
43 Init();
44}
45//******************************************************************************
46//******************************************************************************
47Win32Window::Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
48 : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
49{
50 Init();
51 this->isUnicode = isUnicode;
52 CreateWindowExA(lpCreateStructA, classAtom);
53}
54//******************************************************************************
55//******************************************************************************
56void Win32Window::Init()
57{
58 isUnicode = FALSE;
59
60 windowName = NULL;
61 wndNameLength = 0;
62
63 windowText = NULL;;
64 wndTextLength = 0;
65
66 userWindowLong = NULL;;
67 nrUserWindowLong = 0;
68
69 magic = WIN32PM_MAGIC;
70 OS2Hwnd = 0;
71 OS2HwndFrame = 0;
72 OS2HwndMenu = 0;
73 Win32Hwnd = 0;
74
75 if(HMHandleAllocate(&Win32Hwnd, (ULONG)this) != 0)
76 {
77 dprintf(("Win32Window::Init HMHandleAllocate failed!!"));
78 DebugInt3();
79 }
80 Win32Hwnd &= 0xFFFF;
81 Win32Hwnd |= 0x68000000;
82
83 posx = posy = 0;
84 width = height = 0;
85
86 dwExStyle = 0;
87 dwStyle = 0;
88 win32wndproc = 0;
89 hInstance = 0;
90 windowId = 0xFFFFFFFF; //default = -1
91 userData = 0;
92
93 hwndLinkAfter = HWND_BOTTOM;
94 flags = 0;
95 isIcon = FALSE;
96 owner = NULL;
97 windowClass = 0;
98}
99//******************************************************************************
100//******************************************************************************
101Win32Window::~Win32Window()
102{
103 if(Win32Hwnd)
104 HMHandleFree(Win32Hwnd);
105 if(windowName)
106 free(windowName);
107 if(windowText)
108 free(windowText);
109 if(userWindowLong)
110 free(userWindowLong);
111}
112//******************************************************************************
113//******************************************************************************
114BOOL Win32Window::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom)
115{
116 char buffer[256];
117 INT sw = SW_SHOW;
118 POINT maxSize, maxPos, minTrack, maxTrack;
119
120 SetLastError(0);
121
122 /* Find the parent window */
123 if (cs->hwndParent)
124 {
125 Win32Window *window = GetWindowFromHandle(cs->hwndParent);
126 if(!window) {
127 dprintf(("Bad parent %04x\n", cs->hwndParent ));
128 SetLastError(ERROR_INVALID_PARAMETER);
129 return FALSE;
130 }
131 /* Make sure parent is valid */
132 if (!window->IsWindow() )
133 {
134 dprintf(("Bad parent %04x\n", cs->hwndParent ));
135 SetLastError(ERROR_INVALID_PARAMETER);
136 return FALSE;
137 }
138 }
139 else
140 if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
141 dprintf(("No parent for child window\n" ));
142 SetLastError(ERROR_INVALID_PARAMETER);
143 return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
144 }
145
146 /* Find the window class */
147 windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
148 if (!windowClass)
149 {
150 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
151 dprintf(("Bad class '%s'\n", buffer ));
152 return 0;
153 }
154
155 /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
156 * with an atom as the class name, put some programs expect to have a *REAL* string in
157 * lpszClass when the CREATESTRUCT is sent with WM_CREATE
158 */
159 if (!HIWORD(cs->lpszClass) ) {
160 if (isUnicode) {
161 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
162 }
163 else {
164 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
165 }
166 cs->lpszClass = buffer;
167 }
168
169 /* Fix the coordinates */
170 if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16)
171 {
172// PDB *pdb = PROCESS_Current();
173
174 /* Never believe Microsoft's documentation... CreateWindowEx doc says
175 * that if an overlapped window is created with WS_VISIBLE style bit
176 * set and the x parameter is set to CW_USEDEFAULT, the system ignores
177 * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
178 * reveals that
179 *
180 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
181 * 2) it does not ignore the y parameter as the docs claim; instead, it
182 * uses it as second parameter to ShowWindow() unless y is either
183 * CW_USEDEFAULT or CW_USEDEFAULT16.
184 *
185 * The fact that we didn't do 2) caused bogus windows pop up when wine
186 * was running apps that were using this obscure feature. Example -
187 * calc.exe that comes with Win98 (only Win98, it's different from
188 * the one that comes with Win95 and NT)
189 */
190 if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) sw = cs->y;
191
192 /* We have saved cs->y, now we can trash it */
193#if 0
194 if ( !(cs->style & (WS_CHILD | WS_POPUP))
195 && (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
196 {
197 cs->x = pdb->env_db->startup_info->dwX;
198 cs->y = pdb->env_db->startup_info->dwY;
199 }
200#endif
201 cs->x = 0;
202 cs->y = 0;
203// }
204 }
205 if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16)
206 {
207#if 0
208 PDB *pdb = PROCESS_Current();
209 if ( !(cs->style & (WS_CHILD | WS_POPUP))
210 && (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )
211 {
212 cs->cx = pdb->env_db->startup_info->dwXSize;
213 cs->cy = pdb->env_db->startup_info->dwYSize;
214 }
215 else
216 {
217#endif
218 cs->cx = 600; /* FIXME */
219 cs->cy = 400;
220// }
221 }
222
223 //Allocate window words
224 nrUserWindowLong = windowClass->getExtraWndWords();
225 if(nrUserWindowLong) {
226 userWindowLong = (ULONG *)malloc(nrUserWindowLong);
227 memset(userWindowLong, 0, nrUserWindowLong);
228 }
229
230 if ((cs->style & WS_CHILD) && cs->hwndParent)
231 {
232 SetParent(cs->hwndParent);
233 }
234 else
235 {
236 if (!cs->hwndParent) {
237 owner = NULL;
238 }
239 else
240 {
241 owner = GetWindowFromHandle(cs->hwndParent);
242 if(owner == NULL)
243 {
244 dprintf(("HMHandleTranslateToOS2 couldn't find owner window %x!!!", cs->hwndParent));
245 return FALSE;
246 }
247 }
248 }
249
250 setWindowProc(windowClass->getWindowProc());
251 hInstance = cs->hInstance;
252 dwStyle = cs->style & ~WS_VISIBLE;
253 dwExStyle = cs->dwExStyle;
254
255 hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
256 ? HWND_BOTTOM : HWND_TOP;
257
258#if 0
259//TODO
260 /* Call the WH_CBT hook */
261
262 if (HOOK_IsHooked( WH_CBT ))
263 {
264 CBT_CREATEWNDA cbtc;
265 LRESULT ret;
266
267 cbtc.lpcs = cs;
268 cbtc.hwndInsertAfter = hwndLinkAfter;
269 ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc)
270 : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc);
271 if (ret)
272 {
273 TRACE_(win)("CBT-hook returned 0\n");
274 wndPtr->pDriver->pFinalize(wndPtr);
275 retvalue = 0;
276 goto end;
277 }
278 }
279#endif
280
281 /* Increment class window counter */
282 windowClass->IncreaseWindowCount();
283
284 /* Correct the window style */
285 if (!(cs->style & WS_CHILD))
286 {
287 dwStyle |= WS_CLIPSIBLINGS;
288 if (!(cs->style & WS_POPUP))
289 {
290 dwStyle |= WS_CAPTION;
291 flags |= WIN_NEED_SIZE;
292 }
293 }
294 if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
295
296 //TODO?
297#if 0
298 /* Get class or window DC if needed */
299 if (classPtr->style & CS_OWNDC) dce = DCE_AllocDCE(hwnd,DCE_WINDOW_DC);
300 else if (classPtr->style & CS_CLASSDC) wndPtr->dce = classPtr->dce;
301 else wndPtr->dce = NULL;
302#endif
303
304 /* Send the WM_GETMINMAXINFO message and fix the size if needed */
305 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
306 {
307 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
308 if (maxSize.x < cs->cx) cs->cx = maxSize.x;
309 if (maxSize.y < cs->cy) cs->cy = maxSize.y;
310 if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
311 if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
312 }
313
314 if(cs->style & WS_CHILD)
315 {
316 if(cs->cx < 0) cs->cx = 0;
317 if(cs->cy < 0) cs->cy = 0;
318 }
319 else
320 {
321 if (cs->cx <= 0) cs->cx = 1;
322 if (cs->cy <= 0) cs->cy = 1;
323 }
324
325 rectWindow.left = cs->x;
326 rectWindow.top = cs->y;
327 rectWindow.right = cs->x + cs->cx;
328 rectWindow.bottom = cs->y + cs->cy;
329 rectClient = rectWindow;
330
331 DWORD dwOSWinStyle, dwOSFrameStyle;
332
333 OSLibWinConvertStyle(cs->style, &dwOSWinStyle, &dwOSFrameStyle);
334
335 OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : 0,
336 dwOSWinStyle, dwOSFrameStyle, (char *)cs->lpszName,
337 (owner) ? owner->getOS2WindowHandle() : 0,
338 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
339 &OS2HwndFrame);
340
341 if(OS2Hwnd == 0) {
342 dprintf(("Window creation failed!!"));
343 return FALSE;
344 }
345 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
346 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
347 return FALSE;
348 }
349 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
350 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
351 return FALSE;
352 }
353#if 0
354 if(OS2Hwnd != OS2HwndFrame) {
355 if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
356 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame));
357 return FALSE;
358 }
359 if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
360 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
361 return FALSE;
362 }
363 }
364#endif
365 /* Set the window menu */
366 if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
367 {
368 if (cs->hMenu) SetMenu(cs->hMenu);
369 else
370 {
371 if (windowClass->getMenuNameA()) {
372 cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
373 if (cs->hMenu) SetMenu(cs->hMenu );
374 }
375 }
376 }
377 else windowId = (UINT)cs->hMenu;
378
379 /* Send the WM_CREATE message
380 * Perhaps we shouldn't allow width/height changes as well.
381 * See p327 in "Internals".
382 */
383 maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
384
385 if(sendMessage(WM_NCCREATE, 0, (LPARAM)cs) )
386 {
387 SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
388 OffsetRect(&rectWindow, maxPos.x - rectWindow.left,
389 maxPos.y - rectWindow.top);
390 dprintf(("Sending WM_CREATE"));
391 if( (sendMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 )
392 {
393 SetWindowPos(HWND_TOP, rectClient.left, rectClient.top,
394 rectClient.right-rectClient.left,
395 rectClient.bottom-rectClient.top,
396 SWP_NOACTIVATE);
397
398 if (cs->style & WS_VISIBLE) ShowWindow( sw );
399
400#if 0
401 /* Call WH_SHELL hook */
402
403 if (!(dwStyle & WS_CHILD) && !owner)
404 HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
405#endif
406 return TRUE;
407 }
408 }
409 return FALSE;
410}
411#if 0
412/***********************************************************************
413 * WINPOS_MinMaximize
414 *
415 * Fill in lpRect and return additional flags to be used with SetWindowPos().
416 * This function assumes that 'cmd' is different from the current window
417 * state.
418 */
419UINT Win32Window::MinMaximize(UINT16 cmd, LPRECT16 lpRect )
420{
421 UINT swpFlags = 0;
422 POINT pt, size;
423 LPINTERNALPOS lpPos;
424
425 size.x = rectWindow.left; size.y = rectWindow.top;
426 lpPos = WINPOS_InitInternalPos( wndPtr, size, &rectWindow );
427
428 if (lpPos && !HOOK_CallHooks16(WH_CBT, HCBT_MINMAX, hwndSelf, cmd))
429 {
430 if( dwStyle & WS_MINIMIZE )
431 {
432 if( !SendMessageA(WM_QUERYOPEN, 0, 0L ) )
433 return (SWP_NOSIZE | SWP_NOMOVE);
434 swpFlags |= SWP_NOCOPYBITS;
435 }
436 switch( cmd )
437 {
438 case SW_MINIMIZE:
439 if( dwStyle & WS_MAXIMIZE)
440 {
441 flags |= WIN_RESTORE_MAX;
442 dwStyle &= ~WS_MAXIMIZE;
443 }
444 else
445 flags &= ~WIN_RESTORE_MAX;
446 dwStyle |= WS_MINIMIZE;
447
448#if 0
449 if( flags & WIN_NATIVE )
450 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) )
451 swpFlags |= MINMAX_NOSWP;
452#endif
453
454 lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
455
456 SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
457 GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
458 swpFlags |= SWP_NOCOPYBITS;
459 break;
460
461 case SW_MAXIMIZE:
462 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
463 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
464 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
465
466 if( dwStyle & WS_MINIMIZE )
467 {
468 if( flags & WIN_NATIVE )
469 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
470 swpFlags |= MINMAX_NOSWP;
471
472 WINPOS_ShowIconTitle( wndPtr, FALSE );
473 dwStyle &= ~WS_MINIMIZE;
474 }
475 dwStyle |= WS_MAXIMIZE;
476
477 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
478 size.x, size.y );
479 break;
480
481 case SW_RESTORE:
482 if( dwStyle & WS_MINIMIZE )
483 {
484 if( flags & WIN_NATIVE )
485 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
486 swpFlags |= MINMAX_NOSWP;
487
488 dwStyle &= ~WS_MINIMIZE;
489 WINPOS_ShowIconTitle( wndPtr, FALSE );
490
491 if( flags & WIN_RESTORE_MAX)
492 {
493 /* Restore to maximized position */
494 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
495 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
496 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
497 dwStyle |= WS_MAXIMIZE;
498 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
499 break;
500 }
501 }
502 else
503 if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
504 else dwStyle &= ~WS_MAXIMIZE;
505
506 /* Restore to normal position */
507
508 *lpRect = lpPos->rectNormal;
509 lpRect->right -= lpRect->left;
510 lpRect->bottom -= lpRect->top;
511
512 break;
513 }
514 } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
515 return swpFlags;
516}
517#endif
518/*******************************************************************
519 * GetMinMaxInfo
520 *
521 * Get the minimized and maximized information for a window.
522 */
523void Win32Window::GetMinMaxInfo(POINT *maxSize, POINT *maxPos,
524 POINT *minTrack, POINT *maxTrack )
525{
526 MINMAXINFO MinMax;
527 INT xinc, yinc;
528
529 /* Compute default values */
530
531 MinMax.ptMaxSize.x = GetSystemMetrics(SM_CXSCREEN);
532 MinMax.ptMaxSize.y = GetSystemMetrics(SM_CYSCREEN);
533 MinMax.ptMinTrackSize.x = GetSystemMetrics(SM_CXMINTRACK);
534 MinMax.ptMinTrackSize.y = GetSystemMetrics(SM_CYMINTRACK);
535 MinMax.ptMaxTrackSize.x = GetSystemMetrics(SM_CXSCREEN);
536 MinMax.ptMaxTrackSize.y = GetSystemMetrics(SM_CYSCREEN);
537
538 if (flags & WIN_MANAGED) xinc = yinc = 0;
539 else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
540 {
541 xinc = GetSystemMetrics(SM_CXDLGFRAME);
542 yinc = GetSystemMetrics(SM_CYDLGFRAME);
543 }
544 else
545 {
546 xinc = yinc = 0;
547 if (HAS_THICKFRAME(dwStyle))
548 {
549 xinc += GetSystemMetrics(SM_CXFRAME);
550 yinc += GetSystemMetrics(SM_CYFRAME);
551 }
552 if (dwStyle & WS_BORDER)
553 {
554 xinc += GetSystemMetrics(SM_CXBORDER);
555 yinc += GetSystemMetrics(SM_CYBORDER);
556 }
557 }
558 MinMax.ptMaxSize.x += 2 * xinc;
559 MinMax.ptMaxSize.y += 2 * yinc;
560
561#if 0
562 lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos );
563 if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
564 CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
565 else
566 {
567#endif
568 MinMax.ptMaxPosition.x = -xinc;
569 MinMax.ptMaxPosition.y = -yinc;
570// }
571
572 SendMessageA(WM_GETMINMAXINFO, 0, (LPARAM)&MinMax );
573
574 /* Some sanity checks */
575
576 dprintf(("GetMinMaxInfo: %ld %ld / %ld %ld / %ld %ld / %ld %ld\n",
577 MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
578 MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
579 MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
580 MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y));
581 MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
582 MinMax.ptMinTrackSize.x );
583 MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
584 MinMax.ptMinTrackSize.y );
585
586 if (maxSize) *maxSize = MinMax.ptMaxSize;
587 if (maxPos) *maxPos = MinMax.ptMaxPosition;
588 if (minTrack) *minTrack = MinMax.ptMinTrackSize;
589 if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize;
590}
591/***********************************************************************
592 * WINPOS_SendNCCalcSize
593 *
594 * Send a WM_NCCALCSIZE message to a window.
595 * All parameters are read-only except newClientRect.
596 * oldWindowRect, oldClientRect and winpos must be non-NULL only
597 * when calcValidRect is TRUE.
598 */
599LONG Win32Window::SendNCCalcSize(BOOL calcValidRect,
600 RECT *newWindowRect, RECT *oldWindowRect,
601 RECT *oldClientRect, WINDOWPOS *winpos,
602 RECT *newClientRect )
603{
604 NCCALCSIZE_PARAMS params;
605 WINDOWPOS winposCopy;
606 LONG result;
607
608 params.rgrc[0] = *newWindowRect;
609 if (calcValidRect)
610 {
611 winposCopy = *winpos;
612 params.rgrc[1] = *oldWindowRect;
613 params.rgrc[2] = *oldClientRect;
614 params.lppos = &winposCopy;
615 }
616 result = SendMessageA(WM_NCCALCSIZE, calcValidRect,
617 (LPARAM)&params );
618 *newClientRect = params.rgrc[0];
619 return result;
620}
621//******************************************************************************
622//******************************************************************************
623ULONG Win32Window::MsgCreate(HWND hwndOS2, ULONG initParam)
624{
625 OS2Hwnd = hwndOS2;
626 return SendMessageA(WM_CREATE, 0, initParam);
627}
628//******************************************************************************
629//******************************************************************************
630ULONG Win32Window::MsgQuit()
631{
632 return SendMessageA(WM_QUIT, 0, 0);
633}
634//******************************************************************************
635//******************************************************************************
636ULONG Win32Window::MsgClose()
637{
638 return SendMessageA(WM_CLOSE, 0, 0);
639}
640//******************************************************************************
641//******************************************************************************
642ULONG Win32Window::MsgDestroy()
643{
644 ULONG rc;
645
646 rc = SendMessageA(WM_DESTROY, 0, 0);
647 delete this;
648 return rc;
649}
650//******************************************************************************
651//******************************************************************************
652ULONG Win32Window::MsgEnable(BOOL fEnable)
653{
654 return SendMessageA(WM_ENABLE, fEnable, 0);
655}
656//******************************************************************************
657//TODO: SW_PARENTCLOSING/OPENING flag (lParam)
658//******************************************************************************
659ULONG Win32Window::MsgShow(BOOL fShow)
660{
661 return SendMessageA(WM_SHOWWINDOW, fShow, 0);
662}
663//******************************************************************************
664//******************************************************************************
665ULONG Win32Window::MsgMove(ULONG xParent, ULONG yParent)
666{
667 return 0;
668}
669//******************************************************************************
670//TODO: Send WM_NCCALCSIZE message here and correct size if necessary
671//******************************************************************************
672ULONG Win32Window::MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize)
673{
674 WORD fwSizeType = 0;
675
676 if(fMinimize) {
677 fwSizeType = SIZE_MINIMIZED;
678 }
679 else
680 if(fMaximize) {
681 fwSizeType = SIZE_MAXIMIZED;
682 }
683 else fwSizeType = SIZE_RESTORED;
684
685 return SendMessageA(WM_SIZE, fwSizeType, MAKELONG((USHORT)width, (USHORT)height));
686}
687//******************************************************************************
688//******************************************************************************
689ULONG Win32Window::MsgActivate(BOOL fActivate, HWND hwnd)
690{
691 return SendMessageA(WM_ACTIVATE, (fActivate) ? WA_ACTIVE : WA_INACTIVE, hwnd);
692}
693//******************************************************************************
694//******************************************************************************
695ULONG Win32Window::MsgSetFocus(HWND hwnd)
696{
697 return SendMessageA(WM_SETFOCUS, hwnd, 0);
698}
699//******************************************************************************
700//******************************************************************************
701ULONG Win32Window::MsgKillFocus(HWND hwnd)
702{
703 return SendMessageA(WM_KILLFOCUS, hwnd, 0);
704}
705//******************************************************************************
706//******************************************************************************
707ULONG Win32Window::MsgButton(ULONG msg, ULONG x, ULONG y)
708{
709 ULONG win32msg;
710
711 switch(msg) {
712 case BUTTON_LEFTDOWN:
713 win32msg = WM_LBUTTONDOWN;
714 break;
715 case BUTTON_LEFTUP:
716 win32msg = WM_LBUTTONUP;
717 break;
718 case BUTTON_LEFTDBLCLICK:
719 win32msg = WM_LBUTTONDBLCLK;
720 break;
721 case BUTTON_RIGHTUP:
722 win32msg = WM_RBUTTONUP;
723 break;
724 case BUTTON_RIGHTDOWN:
725 win32msg = WM_RBUTTONDOWN;
726 break;
727 case BUTTON_RIGHTDBLCLICK:
728 win32msg = WM_RBUTTONDBLCLK;
729 break;
730 default:
731 dprintf(("Win32Window::Button: invalid msg!!!!"));
732 return 1;
733 }
734 return SendMessageA(win32msg, 0, MAKELONG(x, MapOS2ToWin32Y(OS2Hwnd, y)));
735}
736//******************************************************************************
737//******************************************************************************
738ULONG Win32Window::MsgPaint(ULONG tmp1, ULONG tmp2)
739{
740 return SendMessageA(WM_PAINT, 0, 0);
741}
742//******************************************************************************
743//******************************************************************************
744ULONG Win32Window::MsgEraseBackGround(ULONG hps)
745{
746 return SendMessageA(WM_ERASEBKGND, hps, 0);
747}
748//******************************************************************************
749//******************************************************************************
750LRESULT Win32Window::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
751{
752 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
753 dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
754
755 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
756 return(0);
757 }
758 switch(Msg)
759 {
760 case WM_CREATE:
761 {
762 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
763 dprintf(("WM_NCCREATE returned FALSE\n"));
764 return(-1); //don't create window
765 }
766 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
767 dprintf(("WM_CREATE returned -1\n"));
768 return(-1); //don't create window
769 }
770 NotifyParent(Msg, wParam, lParam);
771
772 return(0);
773 }
774 case WM_LBUTTONDOWN:
775 case WM_MBUTTONDOWN:
776 case WM_RBUTTONDOWN:
777 NotifyParent(Msg, wParam, lParam);
778 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
779
780 case WM_DESTROY:
781 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
782 NotifyParent(Msg, wParam, lParam);
783 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
784 default:
785 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
786 }
787}
788//******************************************************************************
789//todo, unicode msgs
790//******************************************************************************
791LRESULT Win32Window::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
792{
793 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
794 dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
795
796 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
797 return(0);
798 }
799 switch(Msg)
800 {
801 case WM_CREATE:
802 {
803 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
804 dprintf(("WM_NCCREATE returned FALSE\n"));
805 return(0); //don't create window
806 }
807 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
808 dprintf(("WM_CREATE returned FALSE\n"));
809 return(0); //don't create window
810 }
811 NotifyParent(Msg, wParam, lParam);
812
813 return(1);
814 }
815 case WM_LBUTTONDOWN:
816 case WM_MBUTTONDOWN:
817 case WM_RBUTTONDOWN:
818 NotifyParent(Msg, wParam, lParam);
819 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
820
821 case WM_DESTROY:
822 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
823 NotifyParent(Msg, wParam, lParam);
824 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
825 default:
826 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
827 }
828}
829//******************************************************************************
830//******************************************************************************
831BOOL Win32Window::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam)
832{
833 POSTMSG_PACKET *postmsg;
834
835 postmsg = (POSTMSG_PACKET *)malloc(sizeof(POSTMSG_PACKET));
836 if(postmsg == NULL) {
837 dprintf(("Win32Window::PostMessageA: malloc returned NULL!!"));
838 return 0;
839 }
840 postmsg->Msg = msg;
841 postmsg->wParam = wParam;
842 postmsg->lParam = lParam;
843 return OSLibPostMessage(OS2Hwnd, WM_WIN32_POSTMESSAGEA, (ULONG)postmsg, 0);
844}
845//******************************************************************************
846//******************************************************************************
847BOOL Win32Window::PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam)
848{
849 POSTMSG_PACKET *postmsg;
850
851 postmsg = (POSTMSG_PACKET *)malloc(sizeof(POSTMSG_PACKET));
852 if(postmsg == NULL) {
853 dprintf(("Win32Window::PostMessageW: malloc returned NULL!!"));
854 return 0;
855 }
856 postmsg->Msg = msg;
857 postmsg->wParam = wParam;
858 postmsg->lParam = lParam;
859 return OSLibPostMessage(OS2Hwnd, WM_WIN32_POSTMESSAGEW, (ULONG)postmsg, 0);
860}
861//******************************************************************************
862//TODO: do we need to inform the parent of the parent (etc) of the child window?
863//******************************************************************************
864void Win32Window::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
865{
866 Win32Window *window = this;
867 Win32Window *parentwindow;
868
869 while(window)
870 {
871 if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
872 {
873 /* Notify the parent window only */
874 parentwindow = window->getParent();
875 if(parentwindow) {
876 if(Msg == WM_CREATE || Msg == WM_DESTROY) {
877 parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle());
878 }
879 else parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );
880 }
881 }
882 else break;
883
884 window = parentwindow;
885 }
886}
887//******************************************************************************
888//******************************************************************************
889BOOL Win32Window::SetMenu(ULONG hMenu)
890{
891 PVOID menutemplate;
892
893 if(HMHandleTranslateToOS2(hMenu, (PULONG)&menutemplate) == NO_ERROR)
894 {
895 OS2HwndMenu = OSLibWinCreateMenu(OS2HwndFrame, menutemplate);
896 if(OS2HwndMenu == 0) {
897 dprintf(("Win32Window::SetMenu OS2HwndMenu == 0"));
898 return FALSE;
899 }
900 }
901 dprintf(("Win32Window::SetMenu unknown hMenu (%x)", hMenu));
902 return FALSE;
903}
904//******************************************************************************
905//******************************************************************************
906BOOL Win32Window::ShowWindow(ULONG nCmdShow)
907{
908 ULONG showstate = 0;
909
910 switch(nCmdShow)
911 {
912 case SW_SHOW:
913 case SW_SHOWDEFAULT: //todo
914 showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
915 break;
916 case SW_HIDE:
917 showstate = SWPOS_HIDE;
918 break;
919 case SW_RESTORE:
920 showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
921 break;
922 case SW_MINIMIZE:
923 showstate = SWPOS_MINIMIZE;
924 break;
925 case SW_SHOWMAXIMIZED:
926 showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
927 break;
928 case SW_SHOWMINIMIZED:
929 showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
930 break;
931 case SW_SHOWMINNOACTIVE:
932 showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
933 break;
934 case SW_SHOWNA:
935 showstate = SWPOS_SHOW;
936 break;
937 case SW_SHOWNOACTIVATE:
938 showstate = SWPOS_SHOW;
939 break;
940 case SW_SHOWNORMAL:
941 showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
942 break;
943 }
944 return OSLibWinShowWindow(OS2Hwnd, showstate);
945}
946//******************************************************************************
947//******************************************************************************
948BOOL Win32Window::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
949{
950 Win32Window *window;
951 ULONG setstate = 0;
952
953 switch(hwndInsertAfter) {
954 case HWND_BOTTOM:
955 hwndInsertAfter = HWNDOS_BOTTOM;
956 break;
957 case HWND_TOPMOST: //TODO:
958 case HWND_NOTOPMOST: //TODO:
959 case HWND_TOP:
960 hwndInsertAfter = HWNDOS_TOP;
961 break;
962 default:
963 window = GetWindowFromHandle(hwndInsertAfter);
964 if(window) {
965 hwndInsertAfter = window->getOS2WindowHandle();
966 }
967 else {
968 dprintf(("Win32Window::SetWindowPos, unknown hwndInsertAfter %x", hwndInsertAfter));
969 hwndInsertAfter = 0;
970 }
971 break;
972
973 }
974 setstate = SWPOS_MOVE | SWPOS_SIZE | SWPOS_ACTIVATE | SWPOS_ZORDER;
975 if(fuFlags & SWP_DRAWFRAME)
976 setstate |= 0; //TODO
977 if(fuFlags & SWP_FRAMECHANGED)
978 setstate |= 0; //TODO
979 if(fuFlags & SWP_HIDEWINDOW)
980 setstate &= ~SWPOS_ZORDER;
981 if(fuFlags & SWP_NOACTIVATE)
982 setstate &= ~SWPOS_ACTIVATE;
983 if(fuFlags & SWP_NOCOPYBITS)
984 setstate |= 0; //TODO
985 if(fuFlags & SWP_NOMOVE)
986 setstate &= ~SWPOS_MOVE;
987 if(fuFlags & SWP_NOSIZE)
988 setstate &= ~SWPOS_SIZE;
989 if(fuFlags & SWP_NOREDRAW)
990 setstate |= SWPOS_NOREDRAW;
991 if(fuFlags & SWP_NOZORDER)
992 setstate &= ~SWPOS_ZORDER;
993 if(fuFlags & SWP_SHOWWINDOW)
994 setstate |= SWPOS_SHOW;
995
996 return OSLibWinSetWindowPos(OS2Hwnd, hwndInsertAfter, x, y, cx, cy, setstate);
997}
998//******************************************************************************
999//Also destroys all the child windows (destroy parent, destroy children)
1000//******************************************************************************
1001BOOL Win32Window::DestroyWindow()
1002{
1003 return OSLibWinDestroyWindow(OS2HwndFrame);
1004}
1005//******************************************************************************
1006//******************************************************************************
1007HWND Win32Window::GetParent()
1008{
1009 if(getParent()) {
1010 return getParent()->getWindowHandle();
1011 }
1012 else return 0;
1013}
1014//******************************************************************************
1015//******************************************************************************
1016HWND Win32Window::SetParent(HWND hwndNewParent)
1017{
1018 HWND oldhwnd;
1019 Win32Window *newparent;
1020
1021 if(getParent()) {
1022 oldhwnd = getParent()->getWindowHandle();
1023 }
1024 else oldhwnd = 0;
1025
1026 if(hwndNewParent == 0) {//desktop window = parent
1027 setParent(NULL);
1028 OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
1029 return oldhwnd;
1030 }
1031 newparent = GetWindowFromHandle(hwndNewParent);
1032 if(newparent)
1033 {
1034 setParent(newparent);
1035 OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
1036 return oldhwnd;
1037 }
1038 SetLastError(ERROR_INVALID_PARAMETER);
1039 return 0;
1040}
1041//******************************************************************************
1042//******************************************************************************
1043BOOL Win32Window::IsChild(HWND hwndParent)
1044{
1045 if(getParent()) {
1046 return getParent()->getWindowHandle() == hwndParent;
1047 }
1048 else return 0;
1049}
1050//******************************************************************************
1051//******************************************************************************
1052HWND Win32Window::GetTopWindow()
1053{
1054 return GetWindow(GW_CHILD);
1055}
1056//******************************************************************************
1057//Don't call WinUpdateWindow as that one also updates the child windows
1058//Also need to send WM_PAINT directly to the window procedure, which doesn't
1059//always happen with WinUpdateWindow (could be posted if thread doesn't own window)
1060//******************************************************************************
1061BOOL Win32Window::UpdateWindow()
1062{
1063 RECTL rect;
1064
1065 if(OSLibWinQueryUpdateRect(OS2Hwnd, (PVOID)&rect))
1066 {//update region not empty
1067 SendMessageA((isIcon) ? WM_PAINTICON : WM_PAINT, 0, 0);
1068 }
1069 return TRUE;
1070}
1071//******************************************************************************
1072//******************************************************************************
1073BOOL Win32Window::IsIconic()
1074{
1075 return OSLibWinIsIconic(OS2Hwnd);
1076}
1077//******************************************************************************
1078//TODO: not complete nor correct (distinction between top-level, top-most & child windows)
1079//******************************************************************************
1080HWND Win32Window::GetWindow(UINT uCmd)
1081{
1082 Win32Window *win32wnd;
1083 ULONG magic;
1084 ULONG getcmd = 0;
1085 HWND hwndRelated;
1086
1087 dprintf(("GetWindow %x %d NOT COMPLETE", getWindowHandle(), uCmd));
1088 switch(uCmd)
1089 {
1090 case GW_CHILD:
1091 getcmd = QWOS_TOP;
1092 break;
1093 case GW_HWNDFIRST:
1094 if(getParent()) {
1095 getcmd = QWOS_TOP; //top of child windows
1096 }
1097 else getcmd = QWOS_TOP; //TODO
1098 break;
1099 case GW_HWNDLAST:
1100 if(getParent()) {
1101 getcmd = QWOS_BOTTOM; //bottom of child windows
1102 }
1103 else getcmd = QWOS_BOTTOM; //TODO
1104 break;
1105 case GW_HWNDNEXT:
1106 getcmd = QWOS_NEXT;
1107 break;
1108 case GW_HWNDPREV:
1109 getcmd = QWOS_PREV;
1110 break;
1111 case GW_OWNER:
1112 if(owner) {
1113 return owner->getWindowHandle();
1114 }
1115 else return 0;
1116 }
1117 hwndRelated = OSLibWinQueryWindow(OS2Hwnd, getcmd);
1118 if(hwndRelated)
1119 {
1120 win32wnd = (Win32Window *)OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32WNDPTR);
1121 magic = OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC);
1122 if(CheckMagicDword(magic) && win32wnd)
1123 {
1124 return win32wnd->getWindowHandle();
1125 }
1126 }
1127 return 0;
1128}
1129//******************************************************************************
1130//******************************************************************************
1131HWND Win32Window::SetActiveWindow()
1132{
1133 return OSLibWinSetActiveWindow(OS2Hwnd);
1134}
1135//******************************************************************************
1136//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
1137//******************************************************************************
1138BOOL Win32Window::EnableWindow(BOOL fEnable)
1139{
1140 return OSLibWinEnableWindow(OS2Hwnd, fEnable);
1141}
1142//******************************************************************************
1143//******************************************************************************
1144BOOL Win32Window::BringWindowToTop()
1145{
1146 return SetWindowPos(HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
1147}
1148//******************************************************************************
1149//******************************************************************************
1150HWND Win32Window::GetActiveWindow()
1151{
1152 HWND hwndActive;
1153 Win32Window *win32wnd;
1154 ULONG magic;
1155
1156 hwndActive = OSLibWinQueryActiveWindow();
1157
1158 win32wnd = (Win32Window *)OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32WNDPTR);
1159 magic = OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32PM_MAGIC);
1160 if(CheckMagicDword(magic) && win32wnd)
1161 {
1162 return win32wnd->getWindowHandle();
1163 }
1164 return hwndActive;
1165}
1166//******************************************************************************
1167//******************************************************************************
1168BOOL Win32Window::IsWindow()
1169{
1170 return TRUE;
1171}
1172//******************************************************************************
1173//******************************************************************************
1174BOOL Win32Window::IsWindowEnabled()
1175{
1176 return OSLibWinIsWindowEnabled(OS2Hwnd);
1177}
1178//******************************************************************************
1179//******************************************************************************
1180BOOL Win32Window::IsWindowVisible()
1181{
1182 return OSLibWinIsWindowVisible(OS2Hwnd);
1183}
1184//******************************************************************************
1185//******************************************************************************
1186LONG Win32Window::SetWindowLongA(int index, ULONG value)
1187{
1188 LONG oldval;
1189
1190 switch(index) {
1191 case GWL_EXSTYLE:
1192 oldval = dwExStyle;
1193 dwExStyle = value;
1194 return oldval;
1195 case GWL_STYLE:
1196 oldval = dwStyle;
1197 dwStyle = value;
1198 return oldval;
1199 case GWL_WNDPROC:
1200 oldval = (LONG)getWindowProc();
1201 setWindowProc((WNDPROC)value);
1202 return oldval;
1203 case GWL_HINSTANCE:
1204 oldval = hInstance;
1205 hInstance = value;
1206 return oldval;
1207 case GWL_HWNDPARENT:
1208 return SetParent((HWND)value);
1209
1210 case GWL_ID:
1211 oldval = getWindowId();
1212 setWindowId(value);
1213 return oldval;
1214 case GWL_USERDATA:
1215 oldval = userData;
1216 userData = value;
1217 return oldval;
1218 default:
1219 if(index >= 0 && index/4 < nrUserWindowLong)
1220 {
1221 oldval = userWindowLong[index/4];
1222 userWindowLong[index/4] = value;
1223 return oldval;
1224 }
1225 SetLastError(ERROR_INVALID_PARAMETER);
1226 return 0;
1227 }
1228}
1229//******************************************************************************
1230//******************************************************************************
1231ULONG Win32Window::GetWindowLongA(int index)
1232{
1233 switch(index) {
1234 case GWL_EXSTYLE:
1235 return dwExStyle;
1236 case GWL_STYLE:
1237 return dwStyle;
1238 case GWL_WNDPROC:
1239 return (ULONG)getWindowProc();
1240 case GWL_HINSTANCE:
1241 return hInstance;
1242 case GWL_HWNDPARENT:
1243 if(getParent()) {
1244 return getParent()->getWindowHandle();
1245 }
1246 else return 0;
1247 case GWL_ID:
1248 return getWindowId();
1249 case GWL_USERDATA:
1250 return userData;
1251 default:
1252 if(index >= 0 && index/4 < nrUserWindowLong)
1253 {
1254 return userWindowLong[index/4];
1255 }
1256 SetLastError(ERROR_INVALID_PARAMETER);
1257 return 0;
1258 }
1259}
1260//******************************************************************************
1261//******************************************************************************
1262WORD Win32Window::SetWindowWord(int index, WORD value)
1263{
1264 WORD oldval;
1265
1266 if(index >= 0 && index/4 < nrUserWindowLong)
1267 {
1268 oldval = ((WORD *)userWindowLong)[index/2];
1269 ((WORD *)userWindowLong)[index/2] = value;
1270 return oldval;
1271 }
1272 SetLastError(ERROR_INVALID_PARAMETER);
1273 return 0;
1274}
1275//******************************************************************************
1276//******************************************************************************
1277WORD Win32Window::GetWindowWord(int index)
1278{
1279 if(index >= 0 && index/4 < nrUserWindowLong)
1280 {
1281 return ((WORD *)userWindowLong)[index/2];
1282 }
1283 SetLastError(ERROR_INVALID_PARAMETER);
1284 return 0;
1285}
1286//******************************************************************************
1287//******************************************************************************
1288Win32Window *Win32Window::GetWindowFromHandle(HWND hwnd)
1289{
1290 Win32Window *window;
1291
1292 if(HIWORD(hwnd) != 0x6800) {
1293 return NULL;
1294 }
1295
1296 if(HMHandleTranslateToOS2(LOWORD(hwnd), (PULONG)&window) == NO_ERROR) {
1297 return window;
1298 }
1299 else return NULL;
1300}
1301//******************************************************************************
1302//******************************************************************************
1303GenericObject *Win32Window::windows = NULL;
Note: See TracBrowser for help on using the repository browser.