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