1 | /* $Id: oslibwin.cpp,v 1.64 2000-01-26 18:02:34 cbratschi Exp $ */
|
---|
2 | /*
|
---|
3 | * Window API wrappers for OS/2
|
---|
4 | *
|
---|
5 | *
|
---|
6 | * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | * Copyright 1999 Daniela Engert (dani@ngrt.de)
|
---|
8 | *
|
---|
9 | *
|
---|
10 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
11 | *
|
---|
12 | */
|
---|
13 | #define INCL_WIN
|
---|
14 | #define INCL_PM
|
---|
15 | #include <os2.h>
|
---|
16 | #include <os2wrap.h>
|
---|
17 | #include <stdlib.h>
|
---|
18 | #include <string.h>
|
---|
19 |
|
---|
20 | #include <misc.h>
|
---|
21 | #include "win32type.h"
|
---|
22 | #include <winconst.h>
|
---|
23 | #include "oslibwin.h"
|
---|
24 | #include "oslibutil.h"
|
---|
25 | #include "oslibmsg.h"
|
---|
26 | #include "oslibgdi.h"
|
---|
27 | #include "pmwindow.h"
|
---|
28 |
|
---|
29 | //******************************************************************************
|
---|
30 | //******************************************************************************
|
---|
31 | BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw)
|
---|
32 | {
|
---|
33 | if(hwndParent == OSLIB_HWND_DESKTOP)
|
---|
34 | {
|
---|
35 | hwndParent = HWND_DESKTOP;
|
---|
36 | }
|
---|
37 | else
|
---|
38 | if(hwndParent == OSLIB_HWND_OBJECT) {
|
---|
39 | hwndParent = HWND_OBJECT;
|
---|
40 | }
|
---|
41 | return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
|
---|
42 | }
|
---|
43 | //******************************************************************************
|
---|
44 | //******************************************************************************
|
---|
45 | BOOL OSLibWinSetOwner(HWND hwnd, HWND hwndOwner)
|
---|
46 | {
|
---|
47 | return WinSetOwner(hwnd, hwndOwner);
|
---|
48 | }
|
---|
49 | //******************************************************************************
|
---|
50 | //******************************************************************************
|
---|
51 | HWND OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle,
|
---|
52 | char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame,
|
---|
53 | ULONG id, BOOL fTaskList,BOOL saveBits)
|
---|
54 | {
|
---|
55 | HWND hwndClient;
|
---|
56 |
|
---|
57 | dprintf(("WinCreateWindow %x %s", hwndParent, pszName));
|
---|
58 |
|
---|
59 | if(pszName && *pszName == 0) {
|
---|
60 | pszName = NULL;
|
---|
61 | }
|
---|
62 | if(hwndParent == OSLIB_HWND_DESKTOP) {
|
---|
63 | hwndParent = HWND_DESKTOP;
|
---|
64 | }
|
---|
65 | if(Owner == OSLIB_HWND_DESKTOP) {
|
---|
66 | Owner = HWND_DESKTOP;
|
---|
67 | }
|
---|
68 | ULONG dwClientStyle = 0;
|
---|
69 | ULONG dwFrameStyle = 0;
|
---|
70 | #if 1
|
---|
71 |
|
---|
72 | BOOL TopLevel = hwndParent == HWND_DESKTOP;
|
---|
73 |
|
---|
74 | FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
|
---|
75 |
|
---|
76 | dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP | WS_CLIPSIBLINGS);
|
---|
77 | if (saveBits) dwWinStyle |= WS_SAVEBITS;
|
---|
78 |
|
---|
79 | dwFrameStyle |= FCF_NOBYTEALIGN;
|
---|
80 | if(fTaskList)
|
---|
81 | {
|
---|
82 | dwFrameStyle |= FCF_TASKLIST | FCF_NOMOVEWITHOWNER;
|
---|
83 | }
|
---|
84 |
|
---|
85 | dwWinStyle &= ~WS_CLIPCHILDREN;
|
---|
86 | FCData.flCreateFlags = dwFrameStyle;
|
---|
87 |
|
---|
88 | *hwndFrame = WinCreateWindow (hwndParent,
|
---|
89 | TopLevel ? WC_FRAME : WIN32_INNERFRAME,
|
---|
90 | pszName, dwWinStyle, 0, 0, 0, 0,
|
---|
91 | hwndParent, HWND_TOP,
|
---|
92 | id, &FCData, NULL);
|
---|
93 |
|
---|
94 | if (*hwndFrame) {
|
---|
95 | hwndClient = WinCreateWindow (*hwndFrame,saveBits ? WIN32_STDCLASS2:WIN32_STDCLASS,
|
---|
96 | NULL, dwClientStyle, 0, 0, 0, 0,
|
---|
97 | *hwndFrame, HWND_TOP, FID_CLIENT, NULL, NULL);
|
---|
98 | return hwndClient;
|
---|
99 | }
|
---|
100 | dprintf(("OSLibWinCreateWindow: (FRAME) WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
|
---|
101 | return 0;
|
---|
102 | #else
|
---|
103 | dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
|
---|
104 |
|
---|
105 | dwFrameStyle |= FCF_NOBYTEALIGN;
|
---|
106 | if ((hwndParent == HWND_DESKTOP) && (dwFrameStyle & FCF_TITLEBAR))
|
---|
107 | dwFrameStyle |= FCF_TASKLIST | FCF_NOMOVEWITHOWNER;
|
---|
108 |
|
---|
109 | dwWinStyle &= ~WS_CLIPCHILDREN;
|
---|
110 |
|
---|
111 | *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
|
---|
112 | &dwFrameStyle, WIN32_STDCLASS,
|
---|
113 | "", dwClientStyle, 0, id, &hwndClient);
|
---|
114 | if(*hwndFrame) {
|
---|
115 | if(pszName) {
|
---|
116 | WinSetWindowText(*hwndFrame, pszName);
|
---|
117 | }
|
---|
118 | return hwndClient;
|
---|
119 | }
|
---|
120 | dprintf(("OSLibWinCreateWindow: (FRAME) WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
|
---|
121 | return 0;
|
---|
122 | #endif
|
---|
123 | }
|
---|
124 | //******************************************************************************
|
---|
125 | //******************************************************************************
|
---|
126 | BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG *dwExStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle, ULONG *borderWidth, ULONG *borderHeight)
|
---|
127 | {
|
---|
128 | *OSWinStyle = 0;
|
---|
129 | *OSFrameStyle = 0;
|
---|
130 | *borderWidth = 0;
|
---|
131 | *borderHeight = 0;
|
---|
132 |
|
---|
133 | /* Window styles */
|
---|
134 | if(dwStyle & WS_MINIMIZE_W)
|
---|
135 | *OSWinStyle |= WS_MINIMIZED;
|
---|
136 | //Done explicitely in CreateWindowExA
|
---|
137 | #if 1
|
---|
138 | if(dwStyle & WS_VISIBLE_W)
|
---|
139 | *OSWinStyle |= WS_VISIBLE;
|
---|
140 | #endif
|
---|
141 | if(dwStyle & WS_DISABLED_W)
|
---|
142 | *OSWinStyle |= WS_DISABLED;
|
---|
143 | if(dwStyle & WS_CLIPSIBLINGS_W)
|
---|
144 | *OSWinStyle |= WS_CLIPSIBLINGS;
|
---|
145 | if(dwStyle & WS_CLIPCHILDREN_W)
|
---|
146 | *OSWinStyle |= WS_CLIPCHILDREN;
|
---|
147 | if(dwStyle & WS_MAXIMIZE_W)
|
---|
148 | *OSWinStyle |= WS_MAXIMIZED;
|
---|
149 | if(dwStyle & WS_GROUP_W)
|
---|
150 | *OSWinStyle |= WS_GROUP;
|
---|
151 | if(dwStyle & WS_TABSTOP_W)
|
---|
152 | *OSWinStyle |= WS_TABSTOP;
|
---|
153 |
|
---|
154 | if(dwStyle & WS_CHILD_W && !((dwStyle & WS_CAPTION_W) == WS_CAPTION_W))
|
---|
155 | {
|
---|
156 | //SvL: Causes crash in VPBuddy if enabled -> find bug
|
---|
157 | #if 0
|
---|
158 | if (!HAS_3DFRAME(*dwExStyle) && (dwStyle & (WS_DLGFRAME_W | WS_THICKFRAME_W))) *dwExStyle |= WS_EX_DLGMODALFRAME_W;
|
---|
159 | #endif
|
---|
160 |
|
---|
161 | if (*dwExStyle & WS_EX_CLIENTEDGE_W)
|
---|
162 | {
|
---|
163 | *OSFrameStyle |= FCF_SIZEBORDER;
|
---|
164 | *borderHeight = *borderWidth = 2;
|
---|
165 | }
|
---|
166 | else
|
---|
167 | if (*dwExStyle & WS_EX_DLGMODALFRAME_W)
|
---|
168 | {
|
---|
169 | *OSFrameStyle |= FCF_SIZEBORDER;
|
---|
170 | *borderHeight = *borderWidth = 3;
|
---|
171 | }
|
---|
172 | else
|
---|
173 | if (*dwExStyle & WS_EX_STATICEDGE_W)
|
---|
174 | {
|
---|
175 | *OSFrameStyle |= FCF_SIZEBORDER;
|
---|
176 | *borderHeight = *borderWidth = 2;
|
---|
177 | }
|
---|
178 | else
|
---|
179 | if(dwStyle & WS_BORDER_W)
|
---|
180 | {
|
---|
181 | *OSFrameStyle |= FCF_BORDER;
|
---|
182 | *borderHeight = *borderWidth = 1;
|
---|
183 | }
|
---|
184 | else if (*dwExStyle & WS_EX_WINDOWEDGE_W); //no border
|
---|
185 |
|
---|
186 | if(dwStyle & WS_VSCROLL_W)
|
---|
187 | *OSFrameStyle |= FCF_VERTSCROLL;
|
---|
188 | if(dwStyle & WS_HSCROLL_W)
|
---|
189 | *OSFrameStyle |= FCF_HORZSCROLL;
|
---|
190 | }
|
---|
191 | else
|
---|
192 | {
|
---|
193 | if((dwStyle & WS_CAPTION_W) == WS_DLGFRAME_W)
|
---|
194 | *OSFrameStyle |= FCF_DLGBORDER;
|
---|
195 | else
|
---|
196 | {
|
---|
197 | if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W)
|
---|
198 | *OSFrameStyle |= (FCF_TITLEBAR | FCF_BORDER);
|
---|
199 | else
|
---|
200 | if(dwStyle & WS_BORDER_W)
|
---|
201 | *OSFrameStyle |= FCF_BORDER;
|
---|
202 | }
|
---|
203 |
|
---|
204 | if(dwStyle & WS_VSCROLL_W)
|
---|
205 | *OSFrameStyle |= FCF_VERTSCROLL;
|
---|
206 | if(dwStyle & WS_HSCROLL_W)
|
---|
207 | *OSFrameStyle |= FCF_HORZSCROLL;
|
---|
208 |
|
---|
209 | if(dwStyle & WS_SYSMENU_W)
|
---|
210 | *OSFrameStyle |= FCF_SYSMENU;
|
---|
211 | if(dwStyle & WS_THICKFRAME_W)
|
---|
212 | *OSFrameStyle |= FCF_SIZEBORDER; //??
|
---|
213 | if(dwStyle & WS_MINIMIZEBOX_W)
|
---|
214 | *OSFrameStyle |= FCF_MINBUTTON;
|
---|
215 | if(dwStyle & WS_MAXIMIZEBOX_W)
|
---|
216 | *OSFrameStyle |= FCF_MAXBUTTON;
|
---|
217 |
|
---|
218 | if(*dwExStyle & WS_EX_DLGMODALFRAME_W)
|
---|
219 | *OSFrameStyle |= FCF_DLGBORDER;
|
---|
220 | }
|
---|
221 |
|
---|
222 | //Clear certain frame bits when the window doesn't have a titlebar
|
---|
223 | if(!(*OSFrameStyle & FCF_TITLEBAR)) {
|
---|
224 | *OSFrameStyle &= ~(FCF_MINBUTTON|FCF_MAXBUTTON|FCF_SYSMENU);
|
---|
225 | }
|
---|
226 | return TRUE;
|
---|
227 | }
|
---|
228 | //******************************************************************************
|
---|
229 | //******************************************************************************
|
---|
230 | BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
|
---|
231 | {
|
---|
232 | if(offset == OSLIB_QWL_USER)
|
---|
233 | offset = QWL_USER;
|
---|
234 |
|
---|
235 | return WinSetWindowULong(hwnd, offset, value);
|
---|
236 | }
|
---|
237 | //******************************************************************************
|
---|
238 | //******************************************************************************
|
---|
239 | ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
|
---|
240 | {
|
---|
241 | if(offset == OSLIB_QWL_USER)
|
---|
242 | offset = QWL_USER;
|
---|
243 |
|
---|
244 | return WinQueryWindowULong(hwnd, offset);
|
---|
245 | }
|
---|
246 | //******************************************************************************
|
---|
247 | //******************************************************************************
|
---|
248 | BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle)
|
---|
249 | {
|
---|
250 | return WinAlarm(hwndDeskTop,flStyle);
|
---|
251 | }
|
---|
252 | //******************************************************************************
|
---|
253 | //******************************************************************************
|
---|
254 | APIRET OSLibDosBeep(ULONG freg,ULONG dur)
|
---|
255 | {
|
---|
256 | return DosBeep(freg,dur);
|
---|
257 | }
|
---|
258 | //******************************************************************************
|
---|
259 | //******************************************************************************
|
---|
260 | HWND OSLibWinQueryFocus(HWND hwndDeskTop)
|
---|
261 | {
|
---|
262 | return WinQueryFocus(hwndDeskTop);
|
---|
263 | }
|
---|
264 | //******************************************************************************
|
---|
265 | //******************************************************************************
|
---|
266 | HWND OSLibWinWindowFromID(HWND hwndParent,ULONG id)
|
---|
267 | {
|
---|
268 | return WinWindowFromID(hwndParent,id);
|
---|
269 | }
|
---|
270 | //******************************************************************************
|
---|
271 | //******************************************************************************
|
---|
272 | BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus, BOOL activate)
|
---|
273 | {
|
---|
274 | return WinFocusChange (hwndDeskTop, hwndNewFocus, activate ? FC_NOLOSEACTIVE : 0);
|
---|
275 | }
|
---|
276 | //******************************************************************************
|
---|
277 | //******************************************************************************
|
---|
278 | BOOL OSLibWinIsChild (HWND hwnd, HWND hwndOf)
|
---|
279 | {
|
---|
280 | return WinIsChild (hwnd, hwndOf);
|
---|
281 | }
|
---|
282 | //******************************************************************************
|
---|
283 | //******************************************************************************
|
---|
284 | ULONG OSLibGetWindowHeight(HWND hwnd)
|
---|
285 | {
|
---|
286 | RECTL rect;
|
---|
287 |
|
---|
288 | return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
|
---|
289 | }
|
---|
290 | //******************************************************************************
|
---|
291 | //******************************************************************************
|
---|
292 | LONG OSLibWinQuerySysValue(HWND hwndDeskTop,LONG iSysValue)
|
---|
293 | {
|
---|
294 | return WinQuerySysValue(hwndDeskTop,iSysValue);
|
---|
295 | }
|
---|
296 | //******************************************************************************
|
---|
297 | //******************************************************************************
|
---|
298 | ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer)
|
---|
299 | {
|
---|
300 | return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
|
---|
301 | }
|
---|
302 | //******************************************************************************
|
---|
303 | //******************************************************************************
|
---|
304 | BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText)
|
---|
305 | {
|
---|
306 | return WinSetDlgItemText(hwndDlg,idItem,pszText);
|
---|
307 | }
|
---|
308 | //******************************************************************************
|
---|
309 | //******************************************************************************
|
---|
310 | BOOL OSLibWinQueryPointerPos(HWND hwndDeskTop,PPOINT pptlPoint)
|
---|
311 | {
|
---|
312 | return WinQueryPointerPos(hwndDeskTop,(PPOINTL)pptlPoint);
|
---|
313 | }
|
---|
314 | //******************************************************************************
|
---|
315 | //******************************************************************************
|
---|
316 | HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
|
---|
317 | {
|
---|
318 | return WinQueryWindow(hwnd, lCode);
|
---|
319 | }
|
---|
320 | //******************************************************************************
|
---|
321 | //******************************************************************************
|
---|
322 | BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num)
|
---|
323 | {
|
---|
324 | return WinSetMultWindowPos(GetThreadHAB(), pswp, num);
|
---|
325 | }
|
---|
326 | //******************************************************************************
|
---|
327 | //******************************************************************************
|
---|
328 | BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
|
---|
329 | {
|
---|
330 | BOOL rc = 1;
|
---|
331 |
|
---|
332 | if(fl & SWP_SHOW) {
|
---|
333 | rc = WinShowWindow(hwnd, TRUE);
|
---|
334 | }
|
---|
335 | if(rc == 0)
|
---|
336 | dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
|
---|
337 | rc = WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, fl);
|
---|
338 | if(rc == 0)
|
---|
339 | dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
|
---|
340 | return rc;
|
---|
341 | }
|
---|
342 | //******************************************************************************
|
---|
343 | //******************************************************************************
|
---|
344 | BOOL OSLibWinDestroyWindow(HWND hwnd)
|
---|
345 | {
|
---|
346 | return WinDestroyWindow(hwnd);
|
---|
347 | }
|
---|
348 | //******************************************************************************
|
---|
349 | //******************************************************************************
|
---|
350 | BOOL OSLibWinQueryWindowRect(HWND hwnd, PRECT pRect, int RelativeTo)
|
---|
351 | {
|
---|
352 | BOOL rc;
|
---|
353 | RECTLOS2 rectl;
|
---|
354 |
|
---|
355 | rc = WinQueryWindowRect(hwnd, (PRECTL)&rectl);
|
---|
356 | if(rc) {
|
---|
357 | if(RelativeTo == RELATIVE_TO_SCREEN) {
|
---|
358 | mapOS2ToWin32Rect(hwnd,OSLIB_HWND_DESKTOP,&rectl,pRect);
|
---|
359 | }
|
---|
360 | else mapOS2ToWin32Rect(hwnd,&rectl,pRect);
|
---|
361 | }
|
---|
362 | else memset(pRect, 0, sizeof(RECT));
|
---|
363 | return rc;
|
---|
364 | }
|
---|
365 | //******************************************************************************
|
---|
366 | //******************************************************************************
|
---|
367 | BOOL OSLibWinIsIconic(HWND hwnd)
|
---|
368 | {
|
---|
369 | SWP swp;
|
---|
370 | BOOL rc;
|
---|
371 |
|
---|
372 | rc = WinQueryWindowPos(hwnd, &swp);
|
---|
373 | if(rc == FALSE) {
|
---|
374 | dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
|
---|
375 | return FALSE;
|
---|
376 | }
|
---|
377 |
|
---|
378 | if(swp.fl & SWP_MINIMIZE)
|
---|
379 | return TRUE;
|
---|
380 | else return FALSE;
|
---|
381 | }
|
---|
382 | //******************************************************************************
|
---|
383 | //******************************************************************************
|
---|
384 | BOOL OSLibWinSetActiveWindow(HWND hwnd)
|
---|
385 | {
|
---|
386 | return WinSetActiveWindow(HWND_DESKTOP, hwnd);
|
---|
387 | }
|
---|
388 | //******************************************************************************
|
---|
389 | //******************************************************************************
|
---|
390 | BOOL OSLibWinSetFocus(HWND hwnd)
|
---|
391 | {
|
---|
392 | return WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
393 | }
|
---|
394 | //******************************************************************************
|
---|
395 | //******************************************************************************
|
---|
396 | BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
|
---|
397 | {
|
---|
398 | BOOL rc;
|
---|
399 | HWND hwndClient;
|
---|
400 |
|
---|
401 | rc = WinEnableWindow(hwnd, fEnable);
|
---|
402 | hwndClient = WinWindowFromID(hwnd, FID_CLIENT);
|
---|
403 | if(hwndClient) {
|
---|
404 | WinEnableWindow(hwndClient, fEnable);
|
---|
405 | }
|
---|
406 | return rc;
|
---|
407 | }
|
---|
408 | //******************************************************************************
|
---|
409 | //******************************************************************************
|
---|
410 | BOOL OSLibWinIsWindowEnabled(HWND hwnd)
|
---|
411 | {
|
---|
412 | return WinIsWindowEnabled(hwnd);
|
---|
413 | }
|
---|
414 | //******************************************************************************
|
---|
415 | //******************************************************************************
|
---|
416 | BOOL OSLibWinIsWindowVisible(HWND hwnd)
|
---|
417 | {
|
---|
418 | return WinIsWindowVisible(hwnd);
|
---|
419 | }
|
---|
420 | //******************************************************************************
|
---|
421 | //******************************************************************************
|
---|
422 | BOOL OSLibWinQueryActiveWindow()
|
---|
423 | {
|
---|
424 | return WinQueryActiveWindow(HWND_DESKTOP);
|
---|
425 | }
|
---|
426 | //******************************************************************************
|
---|
427 | //******************************************************************************
|
---|
428 | LONG OSLibWinQueryWindowTextLength(HWND hwnd)
|
---|
429 | {
|
---|
430 | return WinQueryWindowTextLength(hwnd);
|
---|
431 | }
|
---|
432 | //******************************************************************************
|
---|
433 | //******************************************************************************
|
---|
434 | LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz)
|
---|
435 | {
|
---|
436 | return WinQueryWindowText(hwnd, length, lpsz);
|
---|
437 | }
|
---|
438 | //******************************************************************************
|
---|
439 | //******************************************************************************
|
---|
440 | BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz)
|
---|
441 | {
|
---|
442 | return WinSetWindowText(hwnd, lpsz);
|
---|
443 | }
|
---|
444 | //******************************************************************************
|
---|
445 | //******************************************************************************
|
---|
446 | BOOL OSLibWinFlashWindow(HWND hwnd, BOOL fFlash)
|
---|
447 | {
|
---|
448 | return WinFlashWindow(hwnd, fFlash);
|
---|
449 | }
|
---|
450 | //******************************************************************************
|
---|
451 | //******************************************************************************
|
---|
452 | HWND OSLibWinWindowFromPoint(HWND hwnd, PVOID ppoint)
|
---|
453 | {
|
---|
454 | return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE);
|
---|
455 | }
|
---|
456 | //******************************************************************************
|
---|
457 | //******************************************************************************
|
---|
458 | BOOL OSLibWinMinimizeWindow(HWND hwnd)
|
---|
459 | {
|
---|
460 | return WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_MINIMIZE);
|
---|
461 | }
|
---|
462 | //******************************************************************************
|
---|
463 | //******************************************************************************
|
---|
464 | BOOL OSLibWinGetBorderSize(HWND hwnd, OSLIBPOINT *pointl)
|
---|
465 | {
|
---|
466 | pointl->x = 0;
|
---|
467 | pointl->y = 0;
|
---|
468 | return (BOOL) WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP( &pointl), 0);
|
---|
469 | }
|
---|
470 | //******************************************************************************
|
---|
471 | //******************************************************************************
|
---|
472 | BOOL OSLibWinSetIcon(HWND hwnd, HANDLE hIcon)
|
---|
473 | {
|
---|
474 | return (BOOL) WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIcon, 0);
|
---|
475 | }
|
---|
476 | //******************************************************************************
|
---|
477 | //******************************************************************************
|
---|
478 | BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp)
|
---|
479 | {
|
---|
480 | return WinQueryWindowPos(hwnd, pswp);
|
---|
481 | }
|
---|
482 | //******************************************************************************
|
---|
483 | //******************************************************************************
|
---|
484 | void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
|
---|
485 | {
|
---|
486 | HWND hWindow = pswp->hwnd;
|
---|
487 | HWND hWndInsertAfter = pswp->hwndInsertBehind;
|
---|
488 | long x = pswp->x;
|
---|
489 | long y = pswp->y;
|
---|
490 | long cx = pswp->cx;
|
---|
491 | long cy = pswp->cy;
|
---|
492 | UINT fuFlags = (UINT)pswp->fl;
|
---|
493 | ULONG parentHeight;
|
---|
494 |
|
---|
495 | HWND hWinAfter;
|
---|
496 | ULONG flags = 0;
|
---|
497 | SWP swpFrame, swpClient;
|
---|
498 | POINTL point;
|
---|
499 |
|
---|
500 | HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
|
---|
501 |
|
---|
502 | if (hWndInsertAfter == HWND_TOP)
|
---|
503 | hWinAfter = HWND_TOP_W;
|
---|
504 | else if (hWndInsertAfter == HWND_BOTTOM)
|
---|
505 | hWinAfter = HWND_BOTTOM_W;
|
---|
506 | else
|
---|
507 | hWinAfter = (HWND) hWndInsertAfter;
|
---|
508 |
|
---|
509 | //***********************************
|
---|
510 | // convert PM flags to Windows flags
|
---|
511 | //***********************************
|
---|
512 | if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
|
---|
513 | if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
|
---|
514 | if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
|
---|
515 | if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
|
---|
516 | if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
|
---|
517 | if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
|
---|
518 | if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
|
---|
519 | if ( fuFlags & SWP_NOADJUST) flags |= SWP_NOSENDCHANGING_W;
|
---|
520 |
|
---|
521 | WinQueryWindowPos(hFrame, &swpFrame);
|
---|
522 |
|
---|
523 | if(fuFlags & (SWP_MOVE | SWP_SIZE))
|
---|
524 | {
|
---|
525 | point.x = swpFrame.x;
|
---|
526 | point.y = swpFrame.y;
|
---|
527 |
|
---|
528 | if (hParent)
|
---|
529 | {
|
---|
530 | RECTL parentRect;
|
---|
531 |
|
---|
532 | WinQueryWindowRect(hParent,&parentRect);
|
---|
533 | parentHeight = parentRect.yTop;
|
---|
534 | } else
|
---|
535 | {
|
---|
536 | parentHeight = ScreenHeight;
|
---|
537 | }
|
---|
538 |
|
---|
539 | point.y = parentHeight-point.y-swpFrame.cy;
|
---|
540 |
|
---|
541 | cy = swpFrame.cy;
|
---|
542 | cx = swpFrame.cx;
|
---|
543 | x = point.x;
|
---|
544 | y = point.y;
|
---|
545 |
|
---|
546 | if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
|
---|
547 | flags |= SWP_NOMOVE_W;
|
---|
548 |
|
---|
549 | if ((pswp->cx == pswpOld->cx) && (pswp->cy == pswpOld->cy))
|
---|
550 | flags |= SWP_NOSIZE_W;
|
---|
551 |
|
---|
552 | if (fuFlags & SWP_SIZE)
|
---|
553 | {
|
---|
554 | if (pswp->cy != pswpOld->cy)
|
---|
555 | {
|
---|
556 | flags &= ~SWP_NOMOVE_W;
|
---|
557 | }
|
---|
558 | }
|
---|
559 | }
|
---|
560 |
|
---|
561 | pswpOld->x = pswp->x;
|
---|
562 | pswpOld->y = swpFrame.cy-pswp->y-pswp->cy;
|
---|
563 | pswpOld->cx = pswp->cx;
|
---|
564 | pswpOld->cy = pswp->cy;
|
---|
565 |
|
---|
566 | dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
|
---|
567 | x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
|
---|
568 |
|
---|
569 | pwpos->flags = (UINT)flags;
|
---|
570 | pwpos->cy = cy;
|
---|
571 | pwpos->cx = cx;
|
---|
572 | pwpos->x = x;
|
---|
573 | pwpos->y = y;
|
---|
574 | pwpos->hwndInsertAfter = hWinAfter;
|
---|
575 | pwpos->hwnd = hWindow;
|
---|
576 | }
|
---|
577 | //******************************************************************************
|
---|
578 | //******************************************************************************
|
---|
579 | void OSLibMapSWPtoWINDOWPOSFrame(PSWP pswp, struct tagWINDOWPOS *pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
|
---|
580 | {
|
---|
581 | HWND hWindow = pswp->hwnd;
|
---|
582 | HWND hWndInsertAfter = pswp->hwndInsertBehind;
|
---|
583 | long x = pswp->x;
|
---|
584 | long y = pswp->y;
|
---|
585 | long cx = pswp->cx;
|
---|
586 | long cy = pswp->cy;
|
---|
587 | UINT fuFlags = (UINT)pswp->fl;
|
---|
588 | ULONG parentHeight;
|
---|
589 |
|
---|
590 | HWND hWinAfter;
|
---|
591 | ULONG flags = 0;
|
---|
592 | SWP swpClient;
|
---|
593 | POINTL point;
|
---|
594 |
|
---|
595 | HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
|
---|
596 |
|
---|
597 | if (hWndInsertAfter == HWND_TOP)
|
---|
598 | hWinAfter = HWND_TOP_W;
|
---|
599 | else if (hWndInsertAfter == HWND_BOTTOM)
|
---|
600 | hWinAfter = HWND_BOTTOM_W;
|
---|
601 | else
|
---|
602 | hWinAfter = (HWND) hWndInsertAfter;
|
---|
603 |
|
---|
604 | //***********************************
|
---|
605 | // convert PM flags to Windows flags
|
---|
606 | //***********************************
|
---|
607 | if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
|
---|
608 | if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
|
---|
609 | if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
|
---|
610 | if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
|
---|
611 | if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
|
---|
612 | if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
|
---|
613 | if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
|
---|
614 | if ( fuFlags & SWP_NOADJUST) flags |= SWP_NOSENDCHANGING_W;
|
---|
615 |
|
---|
616 | WinQueryWindowPos(WinWindowFromID(hFrame, FID_CLIENT), &swpClient);
|
---|
617 |
|
---|
618 | if(fuFlags & (SWP_MOVE | SWP_SIZE))
|
---|
619 | {
|
---|
620 | if (hParent)
|
---|
621 | {
|
---|
622 | RECTL parentRect;
|
---|
623 |
|
---|
624 | WinQueryWindowRect(hParent,&parentRect);
|
---|
625 | parentHeight = parentRect.yTop;
|
---|
626 | } else
|
---|
627 | {
|
---|
628 | parentHeight = ScreenHeight;
|
---|
629 | }
|
---|
630 |
|
---|
631 | point.x = x;
|
---|
632 | point.y = parentHeight-y-cy;
|
---|
633 |
|
---|
634 | x = point.x;
|
---|
635 | y = point.y;
|
---|
636 |
|
---|
637 | if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
|
---|
638 | flags |= SWP_NOMOVE_W;
|
---|
639 |
|
---|
640 | if ((pswp->cx == pswpOld->cx) && (pswp->cy == pswpOld->cy))
|
---|
641 | flags |= SWP_NOSIZE_W;
|
---|
642 |
|
---|
643 | if (fuFlags & SWP_SIZE)
|
---|
644 | {
|
---|
645 | if (pswp->cy != pswpOld->cy)
|
---|
646 | {
|
---|
647 | flags &= ~SWP_NOMOVE_W;
|
---|
648 | }
|
---|
649 | }
|
---|
650 | }
|
---|
651 |
|
---|
652 | pswpOld->x = swpClient.x;
|
---|
653 | pswpOld->y = pswp->cy-swpClient.y-swpClient.cy;
|
---|
654 | pswpOld->cx = swpClient.cx;
|
---|
655 | pswpOld->cy = swpClient.cy;
|
---|
656 |
|
---|
657 | dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
|
---|
658 | x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
|
---|
659 |
|
---|
660 | pwpos->flags = (UINT)flags;
|
---|
661 | pwpos->cy = cy;
|
---|
662 | pwpos->cx = cx;
|
---|
663 | pwpos->x = x;
|
---|
664 | pwpos->y = y;
|
---|
665 | pwpos->hwndInsertAfter = hWinAfter;
|
---|
666 | pwpos->hwnd = hWindow;
|
---|
667 | }
|
---|
668 | //******************************************************************************
|
---|
669 | //******************************************************************************
|
---|
670 | void OSLibMapWINDOWPOStoSWP(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
|
---|
671 | {
|
---|
672 | BOOL fCvt = FALSE;
|
---|
673 |
|
---|
674 | HWND hWnd = pwpos->hwnd;
|
---|
675 | HWND hWndInsertAfter = pwpos->hwndInsertAfter;
|
---|
676 | long x = pwpos->x;
|
---|
677 | long y = pwpos->y;
|
---|
678 | long cx = pwpos->cx;
|
---|
679 | long cy = pwpos->cy;
|
---|
680 | UINT fuFlags = pwpos->flags;
|
---|
681 | ULONG parentHeight;
|
---|
682 |
|
---|
683 | HWND hWinAfter;
|
---|
684 | ULONG flags = 0;
|
---|
685 | HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
|
---|
686 |
|
---|
687 | if (hWndInsertAfter == HWND_TOPMOST_W)
|
---|
688 | // hWinAfter = HWND_TOPMOST;
|
---|
689 | hWinAfter = HWND_TOP;
|
---|
690 | else if (hWndInsertAfter == HWND_NOTOPMOST_W)
|
---|
691 | // hWinAfter = HWND_NOTOPMOST;
|
---|
692 | hWinAfter = HWND_TOP;
|
---|
693 | else if (hWndInsertAfter == HWND_TOP_W)
|
---|
694 | hWinAfter = HWND_TOP;
|
---|
695 | else if (hWndInsertAfter == HWND_BOTTOM_W)
|
---|
696 | hWinAfter = HWND_BOTTOM;
|
---|
697 | else
|
---|
698 | hWinAfter = (HWND) hWndInsertAfter;
|
---|
699 |
|
---|
700 | if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
|
---|
701 | if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
|
---|
702 | if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
|
---|
703 | if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
|
---|
704 | if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
|
---|
705 | if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
|
---|
706 | if ( fuFlags & SWP_HIDEWINDOW_W) flags |= SWP_HIDE;
|
---|
707 | if ( fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
|
---|
708 |
|
---|
709 | if (flags & (SWP_MOVE | SWP_SIZE))
|
---|
710 | {
|
---|
711 | if (hParent == NULLHANDLE)
|
---|
712 | parentHeight = ScreenHeight;
|
---|
713 | else
|
---|
714 | parentHeight = OSLibGetWindowHeight(hParent);
|
---|
715 |
|
---|
716 | if ((flags & SWP_MOVE) == 0)
|
---|
717 | {
|
---|
718 | x = pswpOld->x;
|
---|
719 | y = pswpOld->y;
|
---|
720 |
|
---|
721 | y = parentHeight-y-pswpOld->cy;
|
---|
722 | }
|
---|
723 |
|
---|
724 | if (flags & SWP_SIZE)
|
---|
725 | {
|
---|
726 | if (cy != pswpOld->cy)
|
---|
727 | flags |= SWP_MOVE;
|
---|
728 | }
|
---|
729 | else
|
---|
730 | {
|
---|
731 | cx = pswpOld->cx;
|
---|
732 | cy = pswpOld->cy;
|
---|
733 | }
|
---|
734 | y = parentHeight-y-cy;
|
---|
735 |
|
---|
736 | if ((pswpOld->x == x) && (pswpOld->y == y))
|
---|
737 | flags &= ~SWP_MOVE;
|
---|
738 |
|
---|
739 | if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
|
---|
740 | flags &= ~SWP_SIZE;
|
---|
741 | }
|
---|
742 |
|
---|
743 | pswp->fl = flags;
|
---|
744 | pswp->cy = cy;
|
---|
745 | pswp->cx = cx;
|
---|
746 | pswp->x = x;
|
---|
747 | pswp->y = y;
|
---|
748 | pswp->hwndInsertBehind = hWinAfter;
|
---|
749 | pswp->hwnd = hWindow;
|
---|
750 | pswp->ulReserved1 = 0;
|
---|
751 | pswp->ulReserved2 = 0;
|
---|
752 | }
|
---|
753 | //******************************************************************************
|
---|
754 | //Position in screen coordinates
|
---|
755 | //******************************************************************************
|
---|
756 | void OSLibMapWINDOWPOStoSWPFrame(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
|
---|
757 | {
|
---|
758 | BOOL fCvt = FALSE;
|
---|
759 |
|
---|
760 | HWND hWnd = pwpos->hwnd;
|
---|
761 | HWND hWndInsertAfter = pwpos->hwndInsertAfter;
|
---|
762 | long x = pwpos->x;
|
---|
763 | long y = pwpos->y;
|
---|
764 | long cx = pwpos->cx;
|
---|
765 | long cy = pwpos->cy;
|
---|
766 | UINT fuFlags = pwpos->flags;
|
---|
767 | ULONG parentHeight;
|
---|
768 |
|
---|
769 | HWND hWinAfter;
|
---|
770 | ULONG flags = 0;
|
---|
771 | HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
|
---|
772 |
|
---|
773 | if (hWndInsertAfter == HWND_TOPMOST_W)
|
---|
774 | // hWinAfter = HWND_TOPMOST;
|
---|
775 | hWinAfter = HWND_TOP;
|
---|
776 | else if (hWndInsertAfter == HWND_NOTOPMOST_W)
|
---|
777 | // hWinAfter = HWND_NOTOPMOST;
|
---|
778 | hWinAfter = HWND_TOP;
|
---|
779 | else if (hWndInsertAfter == HWND_TOP_W)
|
---|
780 | hWinAfter = HWND_TOP;
|
---|
781 | else if (hWndInsertAfter == HWND_BOTTOM_W)
|
---|
782 | hWinAfter = HWND_BOTTOM;
|
---|
783 | else
|
---|
784 | hWinAfter = (HWND) hWndInsertAfter;
|
---|
785 |
|
---|
786 | if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
|
---|
787 | if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
|
---|
788 | if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
|
---|
789 | if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
|
---|
790 | if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
|
---|
791 | if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
|
---|
792 | if ( fuFlags & SWP_HIDEWINDOW_W) flags |= SWP_HIDE;
|
---|
793 | if ( fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
|
---|
794 |
|
---|
795 | if (flags & (SWP_MOVE | SWP_SIZE))
|
---|
796 | {
|
---|
797 | if (hParent)
|
---|
798 | {
|
---|
799 | RECTL parentRect;
|
---|
800 |
|
---|
801 | WinQueryWindowRect(hParent,&parentRect);
|
---|
802 | parentHeight = parentRect.yTop;
|
---|
803 | } else
|
---|
804 | {
|
---|
805 | parentHeight = ScreenHeight;
|
---|
806 | }
|
---|
807 |
|
---|
808 | if (flags & SWP_SIZE)
|
---|
809 | {
|
---|
810 | if (cy != pswpOld->cy)
|
---|
811 | flags |= SWP_MOVE;
|
---|
812 | }
|
---|
813 | else
|
---|
814 | {
|
---|
815 | cx = pswpOld->cx;
|
---|
816 | cy = pswpOld->cy;
|
---|
817 | }
|
---|
818 | y = parentHeight-y-cy;
|
---|
819 |
|
---|
820 | if ((pswpOld->x == x) && (pswpOld->y == y))
|
---|
821 | flags &= ~SWP_MOVE;
|
---|
822 |
|
---|
823 | if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
|
---|
824 | flags &= ~SWP_SIZE;
|
---|
825 | }
|
---|
826 |
|
---|
827 | pswp->fl = flags;
|
---|
828 | pswp->cy = cy;
|
---|
829 | pswp->cx = cx;
|
---|
830 | pswp->x = x;
|
---|
831 | pswp->y = y;
|
---|
832 | pswp->hwndInsertBehind = hWinAfter;
|
---|
833 | pswp->hwnd = hWindow;
|
---|
834 | pswp->ulReserved1 = 0;
|
---|
835 | pswp->ulReserved2 = 0;
|
---|
836 | }
|
---|
837 | //******************************************************************************
|
---|
838 | //******************************************************************************
|
---|
839 | BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
|
---|
840 | {
|
---|
841 | BOOL rc;
|
---|
842 |
|
---|
843 | WinMapWindowPoints(hwndFrame, HWND_DESKTOP, (PPOINTL)pRect, 2);
|
---|
844 |
|
---|
845 | rc = WinCalcFrameRect(hwndFrame, (PRECTL)pRect, fClient);
|
---|
846 | WinMapWindowPoints(HWND_DESKTOP, hwndFrame, (PPOINTL)pRect, 2);
|
---|
847 |
|
---|
848 | return rc;
|
---|
849 | }
|
---|
850 | //******************************************************************************
|
---|
851 | //******************************************************************************
|
---|
852 | BOOL OSLibGetMinMaxInfo(HWND hwndFrame, MINMAXINFO *pMinMax)
|
---|
853 | {
|
---|
854 | TRACKINFO tinfo;
|
---|
855 |
|
---|
856 | memset(&tinfo, 0, sizeof(TRACKINFO));
|
---|
857 | WinSendMsg(hwndFrame, WM_QUERYTRACKINFO, (MPARAM)0,(MPARAM)&tinfo);
|
---|
858 |
|
---|
859 | pMinMax->ptMinTrackSize.x = tinfo.ptlMinTrackSize.x;
|
---|
860 | pMinMax->ptMinTrackSize.y = tinfo.ptlMinTrackSize.y;
|
---|
861 | pMinMax->ptMaxTrackSize.x = tinfo.ptlMaxTrackSize.x;
|
---|
862 | pMinMax->ptMaxTrackSize.y = tinfo.ptlMaxTrackSize.y;
|
---|
863 | return TRUE;
|
---|
864 | }
|
---|
865 | //******************************************************************************
|
---|
866 | //******************************************************************************
|
---|
867 | HWND OSLibWinBeginEnumWindows(HWND hwnd)
|
---|
868 | {
|
---|
869 | if(hwnd == OSLIB_HWND_DESKTOP) hwnd = HWND_DESKTOP;
|
---|
870 | else
|
---|
871 | if(hwnd == OSLIB_HWND_OBJECT) hwnd = HWND_OBJECT;
|
---|
872 |
|
---|
873 | return WinBeginEnumWindows(hwnd);
|
---|
874 | }
|
---|
875 | //******************************************************************************
|
---|
876 | //******************************************************************************
|
---|
877 | HWND OSLibWinGetNextWindow(HWND hwndEnum)
|
---|
878 | {
|
---|
879 | return WinGetNextWindow(hwndEnum);
|
---|
880 | }
|
---|
881 | //******************************************************************************
|
---|
882 | //******************************************************************************
|
---|
883 | HWND OSLibWinQueryClientWindow(HWND hwndFrame)
|
---|
884 | {
|
---|
885 | HWND hwndClient = 0;
|
---|
886 |
|
---|
887 | if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME)
|
---|
888 | hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
|
---|
889 |
|
---|
890 | return hwndClient;
|
---|
891 | }
|
---|
892 | //******************************************************************************
|
---|
893 | //******************************************************************************
|
---|
894 | BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
|
---|
895 | {
|
---|
896 | return WinEndEnumWindows(hwndEnum);
|
---|
897 | }
|
---|
898 | //******************************************************************************
|
---|
899 | //******************************************************************************
|
---|
900 | BOOL OSLibWinQueryWindowProcess(HWND hwnd, ULONG *pid, ULONG *tid)
|
---|
901 | {
|
---|
902 | return WinQueryWindowProcess(hwnd, pid, tid);
|
---|
903 | }
|
---|
904 | //******************************************************************************
|
---|
905 | //******************************************************************************
|
---|
906 | BOOL OSLibWinMapWindowPoints (HWND hwndFrom, HWND hwndTo, OSLIBPOINT *pptl, ULONG num)
|
---|
907 | {
|
---|
908 | return WinMapWindowPoints (hwndFrom, hwndTo, (PPOINTL)pptl, num);
|
---|
909 | }
|
---|
910 | //******************************************************************************
|
---|
911 | //******************************************************************************
|
---|
912 | HWND OSLibWinQueryObjectWindow(VOID)
|
---|
913 | {
|
---|
914 | return WinQueryObjectWindow(HWND_DESKTOP);
|
---|
915 | }
|
---|
916 | //******************************************************************************
|
---|
917 | //******************************************************************************
|
---|
918 | HWND OSLibWinObjectWindowFromID(HWND hwndOwner, ULONG ID)
|
---|
919 | {
|
---|
920 | HWND hwndNext, hwndFound=0;
|
---|
921 | HENUM henum;
|
---|
922 |
|
---|
923 | henum = WinBeginEnumWindows(HWND_OBJECT);
|
---|
924 | while ((hwndNext = WinGetNextWindow(henum)) != 0)
|
---|
925 | {
|
---|
926 | if(WinQueryWindow(hwndNext, QW_OWNER) == hwndOwner &&
|
---|
927 | WinQueryWindowUShort(hwndNext, QWS_ID) == ID)
|
---|
928 | {
|
---|
929 | hwndFound = hwndNext;
|
---|
930 | break;
|
---|
931 | }
|
---|
932 | }
|
---|
933 | WinEndEnumWindows(henum);
|
---|
934 | return hwndFound;
|
---|
935 | }
|
---|
936 | //******************************************************************************
|
---|
937 | //******************************************************************************
|
---|
938 | BOOL OSLibSetWindowID(HWND hwnd, ULONG value)
|
---|
939 | {
|
---|
940 | dprintf(("OSLibSetWindowID hwnd:%x ID:%x", hwnd, value));
|
---|
941 | return WinSetWindowULong(hwnd, QWS_ID, value);
|
---|
942 | }
|
---|
943 | //******************************************************************************
|
---|
944 | //******************************************************************************
|
---|
945 | PVOID OSLibWinSubclassWindow(HWND hwnd,PVOID newWndProc)
|
---|
946 | {
|
---|
947 | return WinSubclassWindow(hwnd,(PFNWP)newWndProc);
|
---|
948 | }
|
---|
949 | //******************************************************************************
|
---|
950 | //******************************************************************************
|
---|
951 | BOOL OSLibSetWindowRestoreRect(HWND hwnd, PRECT pRect)
|
---|
952 | {
|
---|
953 | ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
|
---|
954 |
|
---|
955 | WinSetWindowUShort(hwnd, QWS_XRESTORE, (USHORT)pRect->left );
|
---|
956 | WinSetWindowUShort(hwnd, QWS_YRESTORE, (USHORT)(yHeight - pRect->top -
|
---|
957 | (pRect->bottom - pRect->top)));
|
---|
958 | WinSetWindowUShort(hwnd, QWS_CXRESTORE, (USHORT)(pRect->right - pRect->left));
|
---|
959 | WinSetWindowUShort(hwnd, QWS_CYRESTORE, (USHORT)(pRect->bottom - pRect->top));
|
---|
960 | return TRUE;
|
---|
961 | }
|
---|
962 | //******************************************************************************
|
---|
963 | //******************************************************************************
|
---|
964 | BOOL OSLibSetWindowMinPos(HWND hwnd, ULONG x, ULONG y)
|
---|
965 | {
|
---|
966 | ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
|
---|
967 |
|
---|
968 | WinSetWindowUShort(hwnd, QWS_XMINIMIZE, (USHORT)x );
|
---|
969 | WinSetWindowUShort(hwnd, QWS_YMINIMIZE, (USHORT)(yHeight - y -
|
---|
970 | ( 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER)) -
|
---|
971 | WinQuerySysValue( HWND_DESKTOP, SV_CYICON)));
|
---|
972 | return TRUE;
|
---|
973 | }
|
---|
974 | //******************************************************************************
|
---|
975 | //******************************************************************************
|
---|
976 | BOOL OSLibWinGetKeyboardStateTable(unsigned char *PMKeyState)
|
---|
977 | {
|
---|
978 | return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)&PMKeyState, FALSE );
|
---|
979 | }
|
---|
980 | //******************************************************************************
|
---|
981 | //******************************************************************************
|
---|
982 | BOOL OSLibWinSetKeyboardStateTable(unsigned char *PMKeyState)
|
---|
983 | {
|
---|
984 | return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)&PMKeyState, TRUE );
|
---|
985 | }
|
---|
986 | //******************************************************************************
|
---|
987 | //******************************************************************************
|
---|
988 | BOOL OSLibWinEnableWindowUpdate(HWND hwnd,BOOL fEnable)
|
---|
989 | {
|
---|
990 | return WinEnableWindowUpdate(hwnd,fEnable);
|
---|
991 | }
|
---|
992 | //******************************************************************************
|
---|
993 | //******************************************************************************
|
---|
994 | ULONG OSLibWinGetLastError()
|
---|
995 | {
|
---|
996 | return WinGetLastError(GetThreadHAB()) & 0xFFFF;
|
---|
997 | }
|
---|
998 | //******************************************************************************
|
---|
999 | //******************************************************************************
|
---|
1000 | void OSLibWinShowTaskList(HWND hwndFrame)
|
---|
1001 | {
|
---|
1002 | //CB: don't know if this works on all machines
|
---|
1003 | WinSetActiveWindow(HWND_DESKTOP,0x8000000E);
|
---|
1004 | }
|
---|
1005 | //******************************************************************************
|
---|
1006 | //******************************************************************************
|
---|