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