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