1 | /* $Id: oslibwin.cpp,v 1.39 2000-01-16 18:17:11 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_STDCLASS:WIN32_STDCLASS2,
|
---|
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 | if(hParent)
|
---|
528 | {
|
---|
529 | WinMapWindowPoints(hParent, HWND_DESKTOP, &point, 1);
|
---|
530 | }
|
---|
531 | point.y = ScreenHeight-point.y-swpFrame.cy;
|
---|
532 |
|
---|
533 | cy = swpFrame.cy;
|
---|
534 | cx = swpFrame.cx;
|
---|
535 | x = point.x;
|
---|
536 | y = point.y;
|
---|
537 |
|
---|
538 | if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
|
---|
539 | flags |= SWP_NOMOVE_W;
|
---|
540 |
|
---|
541 | if ((pswp->cx == pswpOld->cx) && (pswp->cy == pswpOld->cy))
|
---|
542 | flags |= SWP_NOSIZE_W;
|
---|
543 |
|
---|
544 | if (fuFlags & SWP_SIZE)
|
---|
545 | {
|
---|
546 | if (pswp->cy != pswpOld->cy)
|
---|
547 | {
|
---|
548 | flags &= ~SWP_NOMOVE_W;
|
---|
549 | }
|
---|
550 | }
|
---|
551 | }
|
---|
552 |
|
---|
553 | pswpOld->x = pswp->x;
|
---|
554 | pswpOld->y = swpFrame.cy-pswp->y-pswp->cy;
|
---|
555 | pswpOld->cx = pswp->cx;
|
---|
556 | pswpOld->cy = pswp->cy;
|
---|
557 |
|
---|
558 | dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
|
---|
559 | x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
|
---|
560 |
|
---|
561 | pwpos->flags = (UINT)flags;
|
---|
562 | pwpos->cy = cy;
|
---|
563 | pwpos->cx = cx;
|
---|
564 | pwpos->x = x;
|
---|
565 | pwpos->y = y;
|
---|
566 | pwpos->hwndInsertAfter = hWinAfter;
|
---|
567 | pwpos->hwnd = hWindow;
|
---|
568 | }
|
---|
569 | //******************************************************************************
|
---|
570 | //******************************************************************************
|
---|
571 | void OSLibMapSWPtoWINDOWPOSFrame(PSWP pswp, struct tagWINDOWPOS *pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
|
---|
572 | {
|
---|
573 | HWND hWindow = pswp->hwnd;
|
---|
574 | HWND hWndInsertAfter = pswp->hwndInsertBehind;
|
---|
575 | long x = pswp->x;
|
---|
576 | long y = pswp->y;
|
---|
577 | long cx = pswp->cx;
|
---|
578 | long cy = pswp->cy;
|
---|
579 | UINT fuFlags = (UINT)pswp->fl;
|
---|
580 | ULONG parentHeight;
|
---|
581 |
|
---|
582 | HWND hWinAfter;
|
---|
583 | ULONG flags = 0;
|
---|
584 | SWP swpClient;
|
---|
585 | POINTL point;
|
---|
586 |
|
---|
587 | HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
|
---|
588 |
|
---|
589 | if (hWndInsertAfter == HWND_TOP)
|
---|
590 | hWinAfter = HWND_TOP_W;
|
---|
591 | else if (hWndInsertAfter == HWND_BOTTOM)
|
---|
592 | hWinAfter = HWND_BOTTOM_W;
|
---|
593 | else
|
---|
594 | hWinAfter = (HWND) hWndInsertAfter;
|
---|
595 |
|
---|
596 | //***********************************
|
---|
597 | // convert PM flags to Windows flags
|
---|
598 | //***********************************
|
---|
599 | if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
|
---|
600 | if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
|
---|
601 | if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
|
---|
602 | if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
|
---|
603 | if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
|
---|
604 | if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
|
---|
605 | if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
|
---|
606 | if ( fuFlags & SWP_NOADJUST) flags |= SWP_NOSENDCHANGING_W;
|
---|
607 |
|
---|
608 | WinQueryWindowPos(WinWindowFromID(hFrame, FID_CLIENT), &swpClient);
|
---|
609 |
|
---|
610 | if(fuFlags & (SWP_MOVE | SWP_SIZE))
|
---|
611 | {
|
---|
612 | point.x = x;
|
---|
613 | point.y = y;
|
---|
614 | if(hParent)
|
---|
615 | {
|
---|
616 | WinMapWindowPoints(hParent, HWND_DESKTOP, &point, 1);
|
---|
617 | }
|
---|
618 | point.y = ScreenHeight-point.y-cy;
|
---|
619 |
|
---|
620 | x = point.x;
|
---|
621 | y = point.y;
|
---|
622 |
|
---|
623 | if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
|
---|
624 | flags |= SWP_NOMOVE_W;
|
---|
625 |
|
---|
626 | if ((pswp->cx == pswpOld->cx) && (pswp->cy == pswpOld->cy))
|
---|
627 | flags |= SWP_NOSIZE_W;
|
---|
628 |
|
---|
629 | if (fuFlags & SWP_SIZE)
|
---|
630 | {
|
---|
631 | if (pswp->cy != pswpOld->cy)
|
---|
632 | {
|
---|
633 | flags &= ~SWP_NOMOVE_W;
|
---|
634 | }
|
---|
635 | }
|
---|
636 | }
|
---|
637 |
|
---|
638 | pswpOld->x = swpClient.x;
|
---|
639 | pswpOld->y = pswp->cy-swpClient.y-swpClient.cy;
|
---|
640 | pswpOld->cx = swpClient.cx;
|
---|
641 | pswpOld->cy = swpClient.cy;
|
---|
642 |
|
---|
643 | dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
|
---|
644 | x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
|
---|
645 |
|
---|
646 | pwpos->flags = (UINT)flags;
|
---|
647 | pwpos->cy = cy;
|
---|
648 | pwpos->cx = cx;
|
---|
649 | pwpos->x = x;
|
---|
650 | pwpos->y = y;
|
---|
651 | pwpos->hwndInsertAfter = hWinAfter;
|
---|
652 | pwpos->hwnd = hWindow;
|
---|
653 | }
|
---|
654 | //******************************************************************************
|
---|
655 | //******************************************************************************
|
---|
656 | void OSLibMapWINDOWPOStoSWP(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
|
---|
657 | {
|
---|
658 | BOOL fCvt = FALSE;
|
---|
659 |
|
---|
660 | HWND hWnd = pwpos->hwnd;
|
---|
661 | HWND hWndInsertAfter = pwpos->hwndInsertAfter;
|
---|
662 | long x = pwpos->x;
|
---|
663 | long y = pwpos->y;
|
---|
664 | long cx = pwpos->cx;
|
---|
665 | long cy = pwpos->cy;
|
---|
666 | UINT fuFlags = pwpos->flags;
|
---|
667 | ULONG parentHeight;
|
---|
668 |
|
---|
669 | HWND hWinAfter;
|
---|
670 | ULONG flags = 0;
|
---|
671 | HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
|
---|
672 |
|
---|
673 | if (hWndInsertAfter == HWND_TOPMOST_W)
|
---|
674 | // hWinAfter = HWND_TOPMOST;
|
---|
675 | hWinAfter = HWND_TOP;
|
---|
676 | else if (hWndInsertAfter == HWND_NOTOPMOST_W)
|
---|
677 | // hWinAfter = HWND_NOTOPMOST;
|
---|
678 | hWinAfter = HWND_TOP;
|
---|
679 | else if (hWndInsertAfter == HWND_TOP_W)
|
---|
680 | hWinAfter = HWND_TOP;
|
---|
681 | else if (hWndInsertAfter == HWND_BOTTOM_W)
|
---|
682 | hWinAfter = HWND_BOTTOM;
|
---|
683 | else
|
---|
684 | hWinAfter = (HWND) hWndInsertAfter;
|
---|
685 |
|
---|
686 | if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
|
---|
687 | if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
|
---|
688 | if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
|
---|
689 | if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
|
---|
690 | if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
|
---|
691 | if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
|
---|
692 | if ( fuFlags & SWP_HIDEWINDOW_W) flags |= SWP_HIDE;
|
---|
693 | if ( fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
|
---|
694 |
|
---|
695 | if (flags & (SWP_MOVE | SWP_SIZE))
|
---|
696 | {
|
---|
697 | if (hParent == NULLHANDLE)
|
---|
698 | parentHeight = ScreenHeight;
|
---|
699 | else
|
---|
700 | parentHeight = OSLibGetWindowHeight(hParent);
|
---|
701 |
|
---|
702 | if ((flags & SWP_MOVE) == 0)
|
---|
703 | {
|
---|
704 | x = pswpOld->x;
|
---|
705 | y = pswpOld->y;
|
---|
706 |
|
---|
707 | if (!((y == 0) && (pswpOld->cy == 0)))
|
---|
708 | {
|
---|
709 | y = parentHeight-y-pswpOld->cy;
|
---|
710 | }
|
---|
711 | }
|
---|
712 |
|
---|
713 | if (flags & SWP_SIZE)
|
---|
714 | {
|
---|
715 | if (cy != pswpOld->cy)
|
---|
716 | flags |= SWP_MOVE;
|
---|
717 | }
|
---|
718 | else
|
---|
719 | {
|
---|
720 | cx = pswpOld->cx;
|
---|
721 | cy = pswpOld->cy;
|
---|
722 | }
|
---|
723 | y = parentHeight-y-cy;
|
---|
724 |
|
---|
725 |
|
---|
726 | if ((pswpOld->x == x) && (pswpOld->y == y))
|
---|
727 | flags &= ~SWP_MOVE;
|
---|
728 |
|
---|
729 | if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
|
---|
730 | flags &= ~SWP_SIZE;
|
---|
731 | }
|
---|
732 |
|
---|
733 | pswp->fl = flags;
|
---|
734 | pswp->cy = cy;
|
---|
735 | pswp->cx = cx;
|
---|
736 | pswp->x = x;
|
---|
737 | pswp->y = y;
|
---|
738 | pswp->hwndInsertBehind = hWinAfter;
|
---|
739 | pswp->hwnd = hWindow;
|
---|
740 | pswp->ulReserved1 = 0;
|
---|
741 | pswp->ulReserved2 = 0;
|
---|
742 | }
|
---|
743 | //******************************************************************************
|
---|
744 | //Position in screen coordinates
|
---|
745 | //******************************************************************************
|
---|
746 | void OSLibMapWINDOWPOStoSWPFrame(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
|
---|
747 | {
|
---|
748 | BOOL fCvt = FALSE;
|
---|
749 |
|
---|
750 | HWND hWnd = pwpos->hwnd;
|
---|
751 | HWND hWndInsertAfter = pwpos->hwndInsertAfter;
|
---|
752 | long x = pwpos->x;
|
---|
753 | long y = pwpos->y;
|
---|
754 | long cx = pwpos->cx;
|
---|
755 | long cy = pwpos->cy;
|
---|
756 | UINT fuFlags = pwpos->flags;
|
---|
757 | ULONG parentHeight;
|
---|
758 | POINTL point;
|
---|
759 |
|
---|
760 | HWND hWinAfter;
|
---|
761 | ULONG flags = 0;
|
---|
762 | HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
|
---|
763 |
|
---|
764 | if (hWndInsertAfter == HWND_TOPMOST_W)
|
---|
765 | // hWinAfter = HWND_TOPMOST;
|
---|
766 | hWinAfter = HWND_TOP;
|
---|
767 | else if (hWndInsertAfter == HWND_NOTOPMOST_W)
|
---|
768 | // hWinAfter = HWND_NOTOPMOST;
|
---|
769 | hWinAfter = HWND_TOP;
|
---|
770 | else if (hWndInsertAfter == HWND_TOP_W)
|
---|
771 | hWinAfter = HWND_TOP;
|
---|
772 | else if (hWndInsertAfter == HWND_BOTTOM_W)
|
---|
773 | hWinAfter = HWND_BOTTOM;
|
---|
774 | else
|
---|
775 | hWinAfter = (HWND) hWndInsertAfter;
|
---|
776 |
|
---|
777 | if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
|
---|
778 | if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
|
---|
779 | if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
|
---|
780 | if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
|
---|
781 | if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
|
---|
782 | if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
|
---|
783 | if ( fuFlags & SWP_HIDEWINDOW_W) flags |= SWP_HIDE;
|
---|
784 | if ( fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
|
---|
785 |
|
---|
786 | if (flags & (SWP_MOVE | SWP_SIZE))
|
---|
787 | {
|
---|
788 | point.x = x;
|
---|
789 | point.y = y;
|
---|
790 |
|
---|
791 | if(hParent) {
|
---|
792 | parentHeight = OSLibGetWindowHeight(hParent);
|
---|
793 |
|
---|
794 | point.y = ScreenHeight-point.y-cy;
|
---|
795 | WinMapWindowPoints(HWND_DESKTOP, hParent, &point, 1);
|
---|
796 | point.y = parentHeight-point.y-cy;
|
---|
797 | }
|
---|
798 | else parentHeight = ScreenHeight;
|
---|
799 |
|
---|
800 | x = point.x;
|
---|
801 | y = point.y;
|
---|
802 |
|
---|
803 | if (flags & SWP_SIZE)
|
---|
804 | {
|
---|
805 | if (cy != pswpOld->cy)
|
---|
806 | flags |= SWP_MOVE;
|
---|
807 | }
|
---|
808 | else
|
---|
809 | {
|
---|
810 | cx = pswpOld->cx;
|
---|
811 | cy = pswpOld->cy;
|
---|
812 | }
|
---|
813 | y = parentHeight-y-cy;
|
---|
814 |
|
---|
815 |
|
---|
816 | if ((pswpOld->x == x) && (pswpOld->y == y))
|
---|
817 | flags &= ~SWP_MOVE;
|
---|
818 |
|
---|
819 | if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
|
---|
820 | flags &= ~SWP_SIZE;
|
---|
821 | }
|
---|
822 |
|
---|
823 | pswp->fl = flags;
|
---|
824 | pswp->cy = cy;
|
---|
825 | pswp->cx = cx;
|
---|
826 | pswp->x = x;
|
---|
827 | pswp->y = y;
|
---|
828 | pswp->hwndInsertBehind = hWinAfter;
|
---|
829 | pswp->hwnd = hWindow;
|
---|
830 | pswp->ulReserved1 = 0;
|
---|
831 | pswp->ulReserved2 = 0;
|
---|
832 | }
|
---|
833 | //******************************************************************************
|
---|
834 | //******************************************************************************
|
---|
835 | BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
|
---|
836 | {
|
---|
837 | BOOL rc;
|
---|
838 |
|
---|
839 | WinMapWindowPoints(hwndFrame, HWND_DESKTOP, (PPOINTL)pRect, 2);
|
---|
840 |
|
---|
841 | rc = WinCalcFrameRect(hwndFrame, (PRECTL)pRect, fClient);
|
---|
842 | WinMapWindowPoints(HWND_DESKTOP, hwndFrame, (PPOINTL)pRect, 2);
|
---|
843 |
|
---|
844 | return rc;
|
---|
845 | }
|
---|
846 | //******************************************************************************
|
---|
847 | //******************************************************************************
|
---|
848 | BOOL OSLibGetMinMaxInfo(HWND hwndFrame, MINMAXINFO *pMinMax)
|
---|
849 | {
|
---|
850 | TRACKINFO tinfo;
|
---|
851 |
|
---|
852 | memset(&tinfo, 0, sizeof(TRACKINFO));
|
---|
853 | WinSendMsg(hwndFrame, WM_QUERYTRACKINFO, (MPARAM)0,(MPARAM)&tinfo);
|
---|
854 |
|
---|
855 | pMinMax->ptMinTrackSize.x = tinfo.ptlMinTrackSize.x;
|
---|
856 | pMinMax->ptMinTrackSize.y = tinfo.ptlMinTrackSize.y;
|
---|
857 | pMinMax->ptMaxTrackSize.x = tinfo.ptlMaxTrackSize.x;
|
---|
858 | pMinMax->ptMaxTrackSize.y = tinfo.ptlMaxTrackSize.y;
|
---|
859 | return TRUE;
|
---|
860 | }
|
---|
861 | //******************************************************************************
|
---|
862 | //******************************************************************************
|
---|
863 | HWND OSLibWinBeginEnumWindows(HWND hwnd)
|
---|
864 | {
|
---|
865 | if(hwnd == OSLIB_HWND_DESKTOP) hwnd = HWND_DESKTOP;
|
---|
866 | else
|
---|
867 | if(hwnd == OSLIB_HWND_OBJECT) hwnd = HWND_OBJECT;
|
---|
868 |
|
---|
869 | return WinBeginEnumWindows(hwnd);
|
---|
870 | }
|
---|
871 | //******************************************************************************
|
---|
872 | //******************************************************************************
|
---|
873 | HWND OSLibWinGetNextWindow(HWND hwndEnum)
|
---|
874 | {
|
---|
875 | return WinGetNextWindow(hwndEnum);
|
---|
876 | }
|
---|
877 | //******************************************************************************
|
---|
878 | //******************************************************************************
|
---|
879 | HWND OSLibWinQueryClientWindow(HWND hwndFrame)
|
---|
880 | {
|
---|
881 | HWND hwndClient = 0;
|
---|
882 |
|
---|
883 | if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME)
|
---|
884 | hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
|
---|
885 |
|
---|
886 | return hwndClient;
|
---|
887 | }
|
---|
888 | //******************************************************************************
|
---|
889 | //******************************************************************************
|
---|
890 | BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
|
---|
891 | {
|
---|
892 | return WinEndEnumWindows(hwndEnum);
|
---|
893 | }
|
---|
894 | //******************************************************************************
|
---|
895 | //******************************************************************************
|
---|
896 | BOOL OSLibWinQueryWindowProcess(HWND hwnd, ULONG *pid, ULONG *tid)
|
---|
897 | {
|
---|
898 | return WinQueryWindowProcess(hwnd, pid, tid);
|
---|
899 | }
|
---|
900 | //******************************************************************************
|
---|
901 | //******************************************************************************
|
---|
902 | BOOL OSLibWinMapWindowPoints (HWND hwndFrom, HWND hwndTo, OSLIBPOINT *pptl, ULONG num)
|
---|
903 | {
|
---|
904 | return WinMapWindowPoints (hwndFrom, hwndTo, (PPOINTL)pptl, num);
|
---|
905 | }
|
---|
906 | //******************************************************************************
|
---|
907 | //******************************************************************************
|
---|
908 | HWND OSLibWinQueryObjectWindow(VOID)
|
---|
909 | {
|
---|
910 | return WinQueryObjectWindow(HWND_DESKTOP);
|
---|
911 | }
|
---|
912 | //******************************************************************************
|
---|
913 | //******************************************************************************
|
---|
914 | HWND OSLibWinObjectWindowFromID(HWND hwndOwner, ULONG ID)
|
---|
915 | {
|
---|
916 | HWND hwndNext, hwndFound=0;
|
---|
917 | HENUM henum;
|
---|
918 |
|
---|
919 | henum = WinBeginEnumWindows(HWND_OBJECT);
|
---|
920 | while ((hwndNext = WinGetNextWindow(henum)) != 0)
|
---|
921 | {
|
---|
922 | if(WinQueryWindow(hwndNext, QW_OWNER) == hwndOwner &&
|
---|
923 | WinQueryWindowUShort(hwndNext, QWS_ID) == ID)
|
---|
924 | {
|
---|
925 | hwndFound = hwndNext;
|
---|
926 | break;
|
---|
927 | }
|
---|
928 | }
|
---|
929 | WinEndEnumWindows(henum);
|
---|
930 | return hwndFound;
|
---|
931 | }
|
---|
932 | //******************************************************************************
|
---|
933 | //******************************************************************************
|
---|
934 | BOOL OSLibSetWindowID(HWND hwnd, ULONG value)
|
---|
935 | {
|
---|
936 | dprintf(("OSLibSetWindowID hwnd:%x ID:%x", hwnd, value));
|
---|
937 | return WinSetWindowULong(hwnd, QWS_ID, value);
|
---|
938 | }
|
---|
939 | //******************************************************************************
|
---|
940 | //******************************************************************************
|
---|
941 | PVOID OSLibWinSubclassWindow(HWND hwnd,PVOID newWndProc)
|
---|
942 | {
|
---|
943 | return WinSubclassWindow(hwnd,(PFNWP)newWndProc);
|
---|
944 | }
|
---|
945 | //******************************************************************************
|
---|
946 | //******************************************************************************
|
---|
947 | BOOL OSLibSetWindowRestoreRect(HWND hwnd, PRECT pRect)
|
---|
948 | {
|
---|
949 | ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
|
---|
950 |
|
---|
951 | WinSetWindowUShort(hwnd, QWS_XRESTORE, (USHORT)pRect->left );
|
---|
952 | WinSetWindowUShort(hwnd, QWS_YRESTORE, (USHORT)(yHeight - pRect->top -
|
---|
953 | (pRect->bottom - pRect->top)));
|
---|
954 | WinSetWindowUShort(hwnd, QWS_CXRESTORE, (USHORT)(pRect->right - pRect->left));
|
---|
955 | WinSetWindowUShort(hwnd, QWS_CYRESTORE, (USHORT)(pRect->bottom - pRect->top));
|
---|
956 | return TRUE;
|
---|
957 | }
|
---|
958 | //******************************************************************************
|
---|
959 | //******************************************************************************
|
---|
960 | BOOL OSLibSetWindowMinPos(HWND hwnd, ULONG x, ULONG y)
|
---|
961 | {
|
---|
962 | ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
|
---|
963 |
|
---|
964 | WinSetWindowUShort(hwnd, QWS_XMINIMIZE, (USHORT)x );
|
---|
965 | WinSetWindowUShort(hwnd, QWS_YMINIMIZE, (USHORT)(yHeight - y -
|
---|
966 | ( 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER)) -
|
---|
967 | WinQuerySysValue( HWND_DESKTOP, SV_CYICON)));
|
---|
968 | return TRUE;
|
---|
969 | }
|
---|
970 | //******************************************************************************
|
---|
971 | //******************************************************************************
|
---|
972 | BOOL OSLibWinGetKeyboardStateTable(unsigned char *PMKeyState)
|
---|
973 | {
|
---|
974 | return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)&PMKeyState, FALSE );
|
---|
975 | }
|
---|
976 | //******************************************************************************
|
---|
977 | //******************************************************************************
|
---|
978 | BOOL OSLibWinSetKeyboardStateTable(unsigned char *PMKeyState)
|
---|
979 | {
|
---|
980 | return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)&PMKeyState, TRUE );
|
---|
981 | }
|
---|
982 | //******************************************************************************
|
---|
983 | //******************************************************************************
|
---|
984 | BOOL OSLibWinEnableWindowUpdate(HWND hwnd,BOOL fEnable)
|
---|
985 | {
|
---|
986 | return WinEnableWindowUpdate(hwnd,fEnable);
|
---|
987 | }
|
---|
988 | //******************************************************************************
|
---|
989 | //******************************************************************************
|
---|
990 | ULONG OSLibWinGetLastError()
|
---|
991 | {
|
---|
992 | return WinGetLastError(GetThreadHAB()) & 0xFFFF;
|
---|
993 | }
|
---|
994 | //******************************************************************************
|
---|
995 | //******************************************************************************
|
---|
996 | void OSLibWinShowTaskList(HWND hwndFrame)
|
---|
997 | {
|
---|
998 | //CB: don't know if this works on all machines
|
---|
999 | WinSetActiveWindow(HWND_DESKTOP,0x8000000E);
|
---|
1000 | }
|
---|
1001 | //******************************************************************************
|
---|
1002 | //******************************************************************************
|
---|