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