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

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

* empty log message *

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