1 | /* $Id: oslibwin.cpp,v 1.108 2001-07-29 18:59:27 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 | #define INCL_WINSWITCHLIST
|
---|
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 <winuser32.h>
|
---|
24 | #include "oslibwin.h"
|
---|
25 | #include "oslibutil.h"
|
---|
26 | #include "oslibmsg.h"
|
---|
27 | #include "oslibgdi.h"
|
---|
28 | #include "pmwindow.h"
|
---|
29 | #include "initterm.h"
|
---|
30 |
|
---|
31 | #define DBG_LOCALLOG DBG_oslibwin
|
---|
32 | #include "dbglocal.h"
|
---|
33 |
|
---|
34 | //******************************************************************************
|
---|
35 | //******************************************************************************
|
---|
36 | BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw)
|
---|
37 | {
|
---|
38 | if(hwndParent == OSLIB_HWND_DESKTOP)
|
---|
39 | {
|
---|
40 | hwndParent = HWND_DESKTOP;
|
---|
41 | }
|
---|
42 | else
|
---|
43 | if(hwndParent == OSLIB_HWND_OBJECT) {
|
---|
44 | hwndParent = HWND_OBJECT;
|
---|
45 | }
|
---|
46 | return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
|
---|
47 | }
|
---|
48 | //******************************************************************************
|
---|
49 | //******************************************************************************
|
---|
50 | BOOL OSLibWinSetOwner(HWND hwnd, HWND hwndOwner)
|
---|
51 | {
|
---|
52 | return WinSetOwner(hwnd, hwndOwner);
|
---|
53 | }
|
---|
54 | //******************************************************************************
|
---|
55 | //******************************************************************************
|
---|
56 | HWND OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle, ULONG dwOSFrameStyle,
|
---|
57 | char *pszName, HWND Owner, ULONG fHWND_BOTTOM,
|
---|
58 | ULONG id, BOOL fTaskList,BOOL fShellPosition,
|
---|
59 | int classStyle, HWND *hwndFrame)
|
---|
60 | {
|
---|
61 | HWND hwndClient;
|
---|
62 | ULONG dwFrameStyle = 0;
|
---|
63 |
|
---|
64 | if(pszName && *pszName == 0) {
|
---|
65 | pszName = NULL;
|
---|
66 | }
|
---|
67 | if(hwndParent == OSLIB_HWND_DESKTOP) {
|
---|
68 | hwndParent = HWND_DESKTOP;
|
---|
69 | }
|
---|
70 | if(Owner == OSLIB_HWND_DESKTOP) {
|
---|
71 | Owner = HWND_DESKTOP;
|
---|
72 | }
|
---|
73 |
|
---|
74 | if(classStyle & CS_SAVEBITS_W) dwWinStyle |= WS_SAVEBITS;
|
---|
75 | if(classStyle & CS_PARENTDC_W) dwWinStyle |= WS_PARENTCLIP;
|
---|
76 |
|
---|
77 | dwWinStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
|
---|
78 |
|
---|
79 | if(fTaskList)
|
---|
80 | {
|
---|
81 | dwFrameStyle |= FCF_NOMOVEWITHOWNER;
|
---|
82 | }
|
---|
83 | if (fShellPosition) dwFrameStyle |= FCF_SHELLPOSITION;
|
---|
84 |
|
---|
85 | FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
|
---|
86 | FCData.flCreateFlags = dwFrameStyle;
|
---|
87 |
|
---|
88 | dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x winstyle %x bottom %d", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle, dwWinStyle, fHWND_BOTTOM));
|
---|
89 |
|
---|
90 | //Must not use WS_CLIPCHILDREN style with frame window. Transparency won't work otherwise.
|
---|
91 | //Eg: dialog parent, groupbox; invalidate part of groupbox -> painting algorithm stops when it finds
|
---|
92 | // a window with WS_CLIPCHILDREN -> result: dialog window won't update groupbox background as groupbox only draws the border
|
---|
93 | *hwndFrame = WinCreateWindow(hwndParent,
|
---|
94 | WIN32_STDFRAMECLASS,
|
---|
95 | pszName, (dwWinStyle & ~WS_CLIPCHILDREN), 0, 0, 0, 0,
|
---|
96 | Owner, (fHWND_BOTTOM) ? HWND_BOTTOM : HWND_TOP,
|
---|
97 | id, (PVOID)&FCData, NULL);
|
---|
98 | if(fOS2Look && *hwndFrame) {
|
---|
99 | FCData.flCreateFlags = dwOSFrameStyle;
|
---|
100 | // FCData.flCreateFlags = FCF_TITLEBAR|FCF_SYSMENU|FCF_MINMAX;
|
---|
101 | WinCreateFrameControls(*hwndFrame, &FCData, NULL);
|
---|
102 | }
|
---|
103 | hwndClient = WinCreateWindow (*hwndFrame, WIN32_STDCLASS,
|
---|
104 | NULL, dwWinStyle | WS_VISIBLE, 0, 0, 0, 0,
|
---|
105 | *hwndFrame, HWND_TOP, FID_CLIENT, NULL, NULL);
|
---|
106 |
|
---|
107 | return hwndClient;
|
---|
108 | }
|
---|
109 | //******************************************************************************
|
---|
110 | //Note: Also check OSLibSetWindowStyle when changing this!!
|
---|
111 | //******************************************************************************
|
---|
112 | BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle)
|
---|
113 | {
|
---|
114 | *OSWinStyle = 0;
|
---|
115 | *OSFrameStyle = 0;
|
---|
116 |
|
---|
117 | /* Window styles */
|
---|
118 | if(dwStyle & WS_DISABLED_W)
|
---|
119 | *OSWinStyle |= WS_DISABLED;
|
---|
120 | if(dwStyle & WS_CLIPSIBLINGS_W)
|
---|
121 | *OSWinStyle |= WS_CLIPSIBLINGS;
|
---|
122 | if(dwStyle & WS_CLIPCHILDREN_W)
|
---|
123 | *OSWinStyle |= WS_CLIPCHILDREN;
|
---|
124 |
|
---|
125 | if(fOS2Look) {
|
---|
126 | if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W) {
|
---|
127 | *OSFrameStyle = FCF_TITLEBAR;
|
---|
128 | if((dwStyle & WS_SYSMENU_W) && !(dwExStyle & WS_EX_TOOLWINDOW_W))
|
---|
129 | {
|
---|
130 | *OSFrameStyle |= FCF_SYSMENU;
|
---|
131 | }
|
---|
132 | if((dwStyle & WS_MINIMIZEBOX_W) || (dwStyle & WS_MAXIMIZEBOX_W)) {
|
---|
133 | *OSFrameStyle |= FCF_MINMAX;
|
---|
134 | }
|
---|
135 | else
|
---|
136 | if(dwStyle & WS_SYSMENU_W) {
|
---|
137 | *OSFrameStyle |= FCF_CLOSEBUTTON;
|
---|
138 | }
|
---|
139 | }
|
---|
140 | }
|
---|
141 | return TRUE;
|
---|
142 | }
|
---|
143 | //******************************************************************************
|
---|
144 | //******************************************************************************
|
---|
145 | BOOL OSLibWinPositionFrameControls(HWND hwndFrame, RECTLOS2 *pRect, DWORD dwStyle,
|
---|
146 | DWORD dwExStyle, HICON hSysMenuIcon)
|
---|
147 | {
|
---|
148 | SWP swp[3];
|
---|
149 | HWND hwndControl;
|
---|
150 | int i = 0;
|
---|
151 | static int minmaxwidth = 0;
|
---|
152 | static int minmaxheight = 0;
|
---|
153 |
|
---|
154 | if(minmaxwidth == 0) {
|
---|
155 | minmaxwidth = WinQuerySysValue(HWND_DESKTOP, SV_CXMINMAXBUTTON);
|
---|
156 | minmaxheight = WinQuerySysValue(HWND_DESKTOP, SV_CYMINMAXBUTTON);
|
---|
157 | }
|
---|
158 |
|
---|
159 | #if 0
|
---|
160 | hwndControl = WinWindowFromID(hwndFrame, FID_SYSMENU);
|
---|
161 | if(hwndControl) {
|
---|
162 | swp[i].hwnd = hwndControl;
|
---|
163 | swp[i].hwndInsertBehind = HWND_TOP;
|
---|
164 | swp[i].x = pRect->xLeft;
|
---|
165 | swp[i].y = pRect->yBottom;
|
---|
166 | if(pRect->yTop - pRect->yBottom > minmaxheight) {
|
---|
167 | swp[i].y += pRect->yTop - pRect->yBottom - minmaxheight;
|
---|
168 | }
|
---|
169 | swp[i].cx = minmaxwidth/2;
|
---|
170 | swp[i].cy = minmaxheight;;
|
---|
171 | swp[i].fl = SWP_SIZE | SWP_MOVE | SWP_SHOW;
|
---|
172 | dprintf(("FID_SYSMENU (%d,%d)(%d,%d)", swp[i].x, swp[i].y, swp[i].cx, swp[i].cy));
|
---|
173 | pRect->xLeft += minmaxwidth/2;
|
---|
174 | i++;
|
---|
175 | }
|
---|
176 | #else
|
---|
177 | if((dwStyle & WS_SYSMENU_W) && !(dwExStyle & WS_EX_TOOLWINDOW_W) && hSysMenuIcon) {
|
---|
178 | pRect->xLeft += minmaxwidth/2;
|
---|
179 | }
|
---|
180 | #endif
|
---|
181 | if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W) {
|
---|
182 | hwndControl = WinWindowFromID(hwndFrame, FID_TITLEBAR);
|
---|
183 | if(hwndControl) {
|
---|
184 | swp[i].hwnd = hwndControl;
|
---|
185 | swp[i].hwndInsertBehind = HWND_TOP;
|
---|
186 | swp[i].x = pRect->xLeft;
|
---|
187 | swp[i].y = pRect->yBottom;
|
---|
188 | if(pRect->yTop - pRect->yBottom > minmaxheight) {
|
---|
189 | swp[i].y += pRect->yTop - pRect->yBottom - minmaxheight;
|
---|
190 | }
|
---|
191 | swp[i].cx = pRect->xRight - pRect->xLeft;
|
---|
192 | if((dwStyle & WS_MINIMIZEBOX_W) || (dwStyle & WS_MAXIMIZEBOX_W)) {
|
---|
193 | swp[i].cx -= minmaxwidth;
|
---|
194 | }
|
---|
195 | //there is no close button in warp 3
|
---|
196 | if((dwStyle & WS_SYSMENU_W) && !fVersionWarp3) {
|
---|
197 | swp[i].cx -= minmaxwidth/2;
|
---|
198 | }
|
---|
199 | swp[i].cy = minmaxheight;
|
---|
200 | swp[i].fl = SWP_SIZE | SWP_MOVE | SWP_SHOW;
|
---|
201 | dprintf(("FID_TITLEBAR (%d,%d)(%d,%d)", swp[i].x, swp[i].y, swp[i].cx, swp[i].cy));
|
---|
202 | pRect->xLeft += swp[i].cx;
|
---|
203 | i++;
|
---|
204 | }
|
---|
205 | else return FALSE; //no titlebar -> no frame controls
|
---|
206 | }
|
---|
207 | if((dwStyle & WS_MINIMIZEBOX_W) || (dwStyle & WS_MAXIMIZEBOX_W) || (dwStyle & WS_SYSMENU_W)) {
|
---|
208 | hwndControl = WinWindowFromID(hwndFrame, FID_MINMAX);
|
---|
209 | if(hwndControl) {
|
---|
210 | swp[i].hwnd = hwndControl;
|
---|
211 | swp[i].hwndInsertBehind = HWND_TOP;
|
---|
212 | swp[i].x = pRect->xLeft;
|
---|
213 | swp[i].y = pRect->yBottom;
|
---|
214 | if(pRect->yTop - pRect->yBottom > minmaxheight) {
|
---|
215 | swp[i].y += pRect->yTop - pRect->yBottom - minmaxheight;
|
---|
216 | }
|
---|
217 | swp[i].cx = 0;
|
---|
218 | if((dwStyle & WS_MINIMIZEBOX_W) || (dwStyle & WS_MAXIMIZEBOX_W)) {
|
---|
219 | swp[i].cx += minmaxwidth;
|
---|
220 | }
|
---|
221 | //there is no close button in warp 3
|
---|
222 | if((dwStyle & WS_SYSMENU_W) && !fVersionWarp3) {
|
---|
223 | swp[i].cx += minmaxwidth/2;
|
---|
224 | }
|
---|
225 | swp[i].cy = minmaxheight;
|
---|
226 | swp[i].fl = SWP_SIZE | SWP_MOVE | SWP_SHOW;
|
---|
227 | dprintf(("FID_MINMAX (%d,%d)(%d,%d)", swp[i].x, swp[i].y, swp[i].cx, swp[i].cy));
|
---|
228 | pRect->xLeft += swp[i].cx;
|
---|
229 | i++;
|
---|
230 | }
|
---|
231 | }
|
---|
232 | return WinSetMultWindowPos(GetThreadHAB(), swp, i);
|
---|
233 | }
|
---|
234 | //******************************************************************************
|
---|
235 | //******************************************************************************
|
---|
236 | BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
|
---|
237 | {
|
---|
238 | if(offset == OSLIB_QWL_USER)
|
---|
239 | offset = QWL_USER;
|
---|
240 |
|
---|
241 | return WinSetWindowULong(hwnd, offset, value);
|
---|
242 | }
|
---|
243 | //******************************************************************************
|
---|
244 | //******************************************************************************
|
---|
245 | ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
|
---|
246 | {
|
---|
247 | if(offset == OSLIB_QWL_USER)
|
---|
248 | offset = QWL_USER;
|
---|
249 |
|
---|
250 | return WinQueryWindowULong(hwnd, offset);
|
---|
251 | }
|
---|
252 | //******************************************************************************
|
---|
253 | //******************************************************************************
|
---|
254 | BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle)
|
---|
255 | {
|
---|
256 | return WinAlarm(hwndDeskTop,flStyle);
|
---|
257 | }
|
---|
258 | //******************************************************************************
|
---|
259 | HWND OSLibWinQueryFocus(HWND hwndDeskTop)
|
---|
260 | {
|
---|
261 | return WinQueryFocus(hwndDeskTop);
|
---|
262 | }
|
---|
263 | //******************************************************************************
|
---|
264 | //******************************************************************************
|
---|
265 | HWND OSLibWinWindowFromID(HWND hwndParent,ULONG id)
|
---|
266 | {
|
---|
267 | return WinWindowFromID(hwndParent,id);
|
---|
268 | }
|
---|
269 | //******************************************************************************
|
---|
270 | //******************************************************************************
|
---|
271 | BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus, BOOL activate)
|
---|
272 | {
|
---|
273 | return WinFocusChange (hwndDeskTop, hwndNewFocus, activate ? 0 : FC_NOSETACTIVE);
|
---|
274 | }
|
---|
275 | //******************************************************************************
|
---|
276 | //******************************************************************************
|
---|
277 | BOOL OSLibWinIsChild (HWND hwnd, HWND hwndOf)
|
---|
278 | {
|
---|
279 | return WinIsChild (hwnd, hwndOf);
|
---|
280 | }
|
---|
281 | //******************************************************************************
|
---|
282 | //******************************************************************************
|
---|
283 | ULONG OSLibGetWindowHeight(HWND hwnd)
|
---|
284 | {
|
---|
285 | RECTL rect;
|
---|
286 |
|
---|
287 | return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
|
---|
288 | }
|
---|
289 | //******************************************************************************
|
---|
290 | //******************************************************************************
|
---|
291 | LONG OSLibWinQuerySysValue(LONG iSysValue)
|
---|
292 | {
|
---|
293 | return WinQuerySysValue(HWND_DESKTOP,iSysValue);
|
---|
294 | }
|
---|
295 | //******************************************************************************
|
---|
296 | //******************************************************************************
|
---|
297 | BOOL OSLibWinSetSysValue(LONG iSysValue, ULONG val)
|
---|
298 | {
|
---|
299 | return WinQuerySysValue(iSysValue, val);
|
---|
300 | }
|
---|
301 | //******************************************************************************
|
---|
302 | //******************************************************************************
|
---|
303 | ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer)
|
---|
304 | {
|
---|
305 | return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
|
---|
306 | }
|
---|
307 | //******************************************************************************
|
---|
308 | //******************************************************************************
|
---|
309 | BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText)
|
---|
310 | {
|
---|
311 | return WinSetDlgItemText(hwndDlg,idItem,pszText);
|
---|
312 | }
|
---|
313 | //******************************************************************************
|
---|
314 | //******************************************************************************
|
---|
315 | BOOL OSLibWinQueryPointerPos(PPOINT pptlPoint)
|
---|
316 | {
|
---|
317 | return WinQueryPointerPos(HWND_DESKTOP,(PPOINTL)pptlPoint);
|
---|
318 | }
|
---|
319 | //******************************************************************************
|
---|
320 | //******************************************************************************
|
---|
321 | BOOL OSLibWinSetPointerPos(int x, int y)
|
---|
322 | {
|
---|
323 | return WinSetPointerPos(HWND_DESKTOP, x, y);
|
---|
324 | }
|
---|
325 | //******************************************************************************
|
---|
326 | //******************************************************************************
|
---|
327 | HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
|
---|
328 | {
|
---|
329 | return WinQueryWindow(hwnd, lCode);
|
---|
330 | }
|
---|
331 | //******************************************************************************
|
---|
332 | //******************************************************************************
|
---|
333 | BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num)
|
---|
334 | {
|
---|
335 | return WinSetMultWindowPos(GetThreadHAB(), pswp, num);
|
---|
336 | }
|
---|
337 | //******************************************************************************
|
---|
338 | //******************************************************************************
|
---|
339 | BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
|
---|
340 | {
|
---|
341 | BOOL rc = 1;
|
---|
342 |
|
---|
343 | if(fl & SWP_SHOW) {
|
---|
344 | rc = WinShowWindow(hwnd, TRUE);
|
---|
345 | }
|
---|
346 | if(rc == 0)
|
---|
347 | dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
|
---|
348 | rc = WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, fl);
|
---|
349 | if(rc == 0)
|
---|
350 | dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
|
---|
351 | return rc;
|
---|
352 | }
|
---|
353 | //******************************************************************************
|
---|
354 | //******************************************************************************
|
---|
355 | BOOL OSLibWinDestroyWindow(HWND hwnd)
|
---|
356 | {
|
---|
357 | return WinDestroyWindow(hwnd);
|
---|
358 | }
|
---|
359 | //******************************************************************************
|
---|
360 | //******************************************************************************
|
---|
361 | #if 0
|
---|
362 | BOOL OSLibWinQueryWindowRect(Win32BaseWindow *window, PRECT pRect, int RelativeTo)
|
---|
363 | {
|
---|
364 | BOOL rc;
|
---|
365 | RECTLOS2 rectl;
|
---|
366 |
|
---|
367 | rc = WinQueryWindowRect(window->getOS2WindowHandle(), (PRECTL)&rectl);
|
---|
368 | if(rc) {
|
---|
369 | if(RelativeTo == RELATIVE_TO_SCREEN) {
|
---|
370 | mapOS2ToWin32RectFrame(window,windowDesktop,&rectl,pRect);
|
---|
371 | }
|
---|
372 | else mapOS2ToWin32RectFrame(window,&rectl,pRect);
|
---|
373 | }
|
---|
374 | else memset(pRect, 0, sizeof(RECT));
|
---|
375 | return rc;
|
---|
376 | }
|
---|
377 | #endif
|
---|
378 | //******************************************************************************
|
---|
379 | //******************************************************************************
|
---|
380 | BOOL OSLibWinIsIconic(HWND hwnd)
|
---|
381 | {
|
---|
382 | SWP swp;
|
---|
383 | BOOL rc;
|
---|
384 |
|
---|
385 | rc = WinQueryWindowPos(hwnd, &swp);
|
---|
386 | if(rc == FALSE) {
|
---|
387 | dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
|
---|
388 | return FALSE;
|
---|
389 | }
|
---|
390 |
|
---|
391 | if(swp.fl & SWP_MINIMIZE)
|
---|
392 | return TRUE;
|
---|
393 | else return FALSE;
|
---|
394 | }
|
---|
395 | //******************************************************************************
|
---|
396 | //******************************************************************************
|
---|
397 | BOOL OSLibWinSetActiveWindow(HWND hwnd)
|
---|
398 | {
|
---|
399 | BOOL rc;
|
---|
400 |
|
---|
401 | rc = WinSetActiveWindow(HWND_DESKTOP, hwnd);
|
---|
402 | if(rc == FALSE) {
|
---|
403 | dprintf(("WinSetActiveWindow %x failure: %x", hwnd, OSLibWinGetLastError()));
|
---|
404 | }
|
---|
405 | return rc;
|
---|
406 | }
|
---|
407 | //******************************************************************************
|
---|
408 | //******************************************************************************
|
---|
409 | BOOL OSLibWinSetFocus(HWND hwnd)
|
---|
410 | {
|
---|
411 | return WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
412 | }
|
---|
413 | //******************************************************************************
|
---|
414 | //******************************************************************************
|
---|
415 | BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
|
---|
416 | {
|
---|
417 | BOOL rc;
|
---|
418 | HWND hwndClient;
|
---|
419 |
|
---|
420 | rc = WinEnableWindow(hwnd, fEnable);
|
---|
421 | hwndClient = WinWindowFromID(hwnd, FID_CLIENT);
|
---|
422 | if(hwndClient) {
|
---|
423 | WinEnableWindow(hwndClient, fEnable);
|
---|
424 | }
|
---|
425 | return rc;
|
---|
426 | }
|
---|
427 | //******************************************************************************
|
---|
428 | //******************************************************************************
|
---|
429 | BOOL OSLibWinIsWindowEnabled(HWND hwnd)
|
---|
430 | {
|
---|
431 | return WinIsWindowEnabled(hwnd);
|
---|
432 | }
|
---|
433 | //******************************************************************************
|
---|
434 | //******************************************************************************
|
---|
435 | BOOL OSLibWinIsWindowVisible(HWND hwnd)
|
---|
436 | {
|
---|
437 | return WinIsWindowVisible(hwnd);
|
---|
438 | }
|
---|
439 | //******************************************************************************
|
---|
440 | //******************************************************************************
|
---|
441 | HWND OSLibWinQueryActiveWindow()
|
---|
442 | {
|
---|
443 | return WinQueryActiveWindow(HWND_DESKTOP);
|
---|
444 | }
|
---|
445 | //******************************************************************************
|
---|
446 | //******************************************************************************
|
---|
447 | LONG OSLibWinQueryWindowTextLength(HWND hwnd)
|
---|
448 | {
|
---|
449 | return WinQueryWindowTextLength(hwnd);
|
---|
450 | }
|
---|
451 | //******************************************************************************
|
---|
452 | //******************************************************************************
|
---|
453 | LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz)
|
---|
454 | {
|
---|
455 | return WinQueryWindowText(hwnd, length, lpsz);
|
---|
456 | }
|
---|
457 | //******************************************************************************
|
---|
458 | //******************************************************************************
|
---|
459 | BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz)
|
---|
460 | {
|
---|
461 | return WinSetWindowText(hwnd, lpsz);
|
---|
462 | }
|
---|
463 | //******************************************************************************
|
---|
464 | //******************************************************************************
|
---|
465 | BOOL OSLibWinSetTitleBarText(HWND hwnd, LPSTR lpsz)
|
---|
466 | {
|
---|
467 | return WinSetWindowText(WinWindowFromID(hwnd, FID_TITLEBAR), lpsz);
|
---|
468 | }
|
---|
469 | //******************************************************************************
|
---|
470 | //******************************************************************************
|
---|
471 | BOOL OSLibWinFlashWindow(HWND hwnd, BOOL fFlash)
|
---|
472 | {
|
---|
473 | return WinFlashWindow(hwnd, fFlash);
|
---|
474 | }
|
---|
475 | //******************************************************************************
|
---|
476 | //******************************************************************************
|
---|
477 | HWND OSLibWinWindowFromPoint(HWND hwnd, PVOID ppoint)
|
---|
478 | {
|
---|
479 | return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE);
|
---|
480 | }
|
---|
481 | //******************************************************************************
|
---|
482 | //******************************************************************************
|
---|
483 | BOOL OSLibWinMinimizeWindow(HWND hwnd)
|
---|
484 | {
|
---|
485 | return WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_MINIMIZE);
|
---|
486 | }
|
---|
487 | //******************************************************************************
|
---|
488 | //******************************************************************************
|
---|
489 | BOOL OSLibWinGetBorderSize(HWND hwnd, OSLIBPOINT *pointl)
|
---|
490 | {
|
---|
491 | pointl->x = 0;
|
---|
492 | pointl->y = 0;
|
---|
493 | return (BOOL) WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP( &pointl), 0);
|
---|
494 | }
|
---|
495 | //******************************************************************************
|
---|
496 | //******************************************************************************
|
---|
497 | BOOL OSLibWinSetIcon(HWND hwnd, HANDLE hIcon)
|
---|
498 | {
|
---|
499 | ULONG hIconOS2 = GetOS2Icon(hIcon);
|
---|
500 | if(hIconOS2)
|
---|
501 | return (BOOL) WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIconOS2, 0);
|
---|
502 | return FALSE;
|
---|
503 | }
|
---|
504 | //******************************************************************************
|
---|
505 | //******************************************************************************
|
---|
506 | BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp)
|
---|
507 | {
|
---|
508 | return WinQueryWindowPos(hwnd, pswp);
|
---|
509 | }
|
---|
510 | //******************************************************************************
|
---|
511 | //******************************************************************************
|
---|
512 | void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld,
|
---|
513 | int parentHeight, HWND hwnd)
|
---|
514 | {
|
---|
515 | HWND hWindow = pswp->hwnd;
|
---|
516 | HWND hWndInsertAfter = pswp->hwndInsertBehind;
|
---|
517 | long x = pswp->x;
|
---|
518 | long y = pswp->y;
|
---|
519 | long cx = pswp->cx;
|
---|
520 | long cy = pswp->cy;
|
---|
521 | UINT fuFlags = (UINT)pswp->fl;
|
---|
522 |
|
---|
523 | HWND hWinAfter;
|
---|
524 | ULONG flags = 0;
|
---|
525 |
|
---|
526 | HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
|
---|
527 |
|
---|
528 | if (hWndInsertAfter == HWND_TOP)
|
---|
529 | hWinAfter = HWND_TOP_W;
|
---|
530 | else if (hWndInsertAfter == HWND_BOTTOM)
|
---|
531 | hWinAfter = HWND_BOTTOM_W;
|
---|
532 | else
|
---|
533 | hWinAfter = (HWND) hWndInsertAfter;
|
---|
534 |
|
---|
535 | //***********************************
|
---|
536 | // convert PM flags to Windows flags
|
---|
537 | //***********************************
|
---|
538 | if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
|
---|
539 | if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
|
---|
540 | if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
|
---|
541 | if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
|
---|
542 | if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
|
---|
543 | if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
|
---|
544 | if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
|
---|
545 | if ( fuFlags & SWP_NOADJUST) flags |= SWP_NOSENDCHANGING_W;
|
---|
546 |
|
---|
547 | if(fuFlags & (SWP_MOVE | SWP_SIZE))
|
---|
548 | {
|
---|
549 | y = parentHeight - y - pswp->cy;
|
---|
550 |
|
---|
551 | if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
|
---|
552 | flags |= SWP_NOMOVE_W;
|
---|
553 |
|
---|
554 | if ((pswp->cx == pswpOld->cx) && (pswp->cy == pswpOld->cy))
|
---|
555 | flags |= SWP_NOSIZE_W;
|
---|
556 |
|
---|
557 | if (fuFlags & SWP_SIZE)
|
---|
558 | {
|
---|
559 | if (pswp->cy != pswpOld->cy)
|
---|
560 | {
|
---|
561 | flags &= ~SWP_NOMOVE_W;
|
---|
562 | }
|
---|
563 | }
|
---|
564 | }
|
---|
565 |
|
---|
566 | pswpOld->x = pswp->x;
|
---|
567 | pswpOld->y = parentHeight-pswp->y-pswp->cy;
|
---|
568 | pswpOld->cx = pswp->cx;
|
---|
569 | pswpOld->cy = pswp->cy;
|
---|
570 |
|
---|
571 | dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
|
---|
572 | x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
|
---|
573 |
|
---|
574 | pwpos->flags = (UINT)flags;
|
---|
575 | pwpos->cy = cy;
|
---|
576 | pwpos->cx = cx;
|
---|
577 | pwpos->x = x;
|
---|
578 | pwpos->y = y;
|
---|
579 | pwpos->hwndInsertAfter = hWinAfter;
|
---|
580 | pwpos->hwnd = hWindow;
|
---|
581 | }
|
---|
582 | //******************************************************************************
|
---|
583 | //******************************************************************************
|
---|
584 | void OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld,
|
---|
585 | int parentHeight, HWND hFrame)
|
---|
586 | {
|
---|
587 | BOOL fCvt = FALSE;
|
---|
588 |
|
---|
589 | HWND hWnd = pwpos->hwnd;
|
---|
590 | HWND hWndInsertAfter = pwpos->hwndInsertAfter;
|
---|
591 | long x = pwpos->x;
|
---|
592 | long y = pwpos->y;
|
---|
593 | long cx = pwpos->cx;
|
---|
594 | long cy = pwpos->cy;
|
---|
595 | UINT fuFlags = pwpos->flags;
|
---|
596 |
|
---|
597 | HWND hWinAfter;
|
---|
598 | ULONG flags = 0;
|
---|
599 | HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
|
---|
600 |
|
---|
601 | if (hWndInsertAfter == HWND_TOPMOST_W)
|
---|
602 | // hWinAfter = HWND_TOPMOST;
|
---|
603 | hWinAfter = HWND_TOP;
|
---|
604 | else if (hWndInsertAfter == HWND_NOTOPMOST_W)
|
---|
605 | // hWinAfter = HWND_NOTOPMOST;
|
---|
606 | hWinAfter = HWND_TOP;
|
---|
607 | else if (hWndInsertAfter == HWND_TOP_W)
|
---|
608 | hWinAfter = HWND_TOP;
|
---|
609 | else if (hWndInsertAfter == HWND_BOTTOM_W)
|
---|
610 | hWinAfter = HWND_BOTTOM;
|
---|
611 | else
|
---|
612 | hWinAfter = (HWND) hWndInsertAfter;
|
---|
613 |
|
---|
614 | if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
|
---|
615 | if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
|
---|
616 | if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
|
---|
617 | if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
|
---|
618 | if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
|
---|
619 | if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
|
---|
620 | if ( fuFlags & SWP_HIDEWINDOW_W) flags |= SWP_HIDE;
|
---|
621 | if ( fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
|
---|
622 |
|
---|
623 | if(flags & (SWP_MOVE | SWP_SIZE))
|
---|
624 | {
|
---|
625 | if((flags & SWP_MOVE) == 0)
|
---|
626 | {
|
---|
627 | x = pswpOld->x;
|
---|
628 | y = pswpOld->y;
|
---|
629 |
|
---|
630 | y = parentHeight - y - pswpOld->cy;
|
---|
631 | }
|
---|
632 |
|
---|
633 | if(flags & SWP_SIZE)
|
---|
634 | {
|
---|
635 | if (cy != pswpOld->cy)
|
---|
636 | flags |= SWP_MOVE;
|
---|
637 | }
|
---|
638 | else
|
---|
639 | {
|
---|
640 | cx = pswpOld->cx;
|
---|
641 | cy = pswpOld->cy;
|
---|
642 | }
|
---|
643 | y = parentHeight - y - cy;
|
---|
644 |
|
---|
645 | if ((pswpOld->x == x) && (pswpOld->y == y))
|
---|
646 | flags &= ~SWP_MOVE;
|
---|
647 |
|
---|
648 | if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
|
---|
649 | flags &= ~SWP_SIZE;
|
---|
650 | }
|
---|
651 |
|
---|
652 | pswp->fl = flags;
|
---|
653 | pswp->cy = cy;
|
---|
654 | pswp->cx = cx;
|
---|
655 | pswp->x = x;
|
---|
656 | pswp->y = y;
|
---|
657 | pswp->hwndInsertBehind = hWinAfter;
|
---|
658 | pswp->hwnd = hWindow;
|
---|
659 | pswp->ulReserved1 = 0;
|
---|
660 | pswp->ulReserved2 = 0;
|
---|
661 | }
|
---|
662 | //******************************************************************************
|
---|
663 | //******************************************************************************
|
---|
664 | void OSLibWinSetClientPos(HWND hwnd, int x, int y, int cx, int cy, int parentHeight)
|
---|
665 | {
|
---|
666 | SWP swp;
|
---|
667 | BOOL rc;
|
---|
668 |
|
---|
669 | swp.hwnd = hwnd;
|
---|
670 | swp.hwndInsertBehind = 0;
|
---|
671 | swp.x = x;
|
---|
672 | swp.y = parentHeight - y - cy;
|
---|
673 | swp.cx = cx;
|
---|
674 | swp.cy = cy;
|
---|
675 | swp.fl = SWP_MOVE | SWP_SIZE;
|
---|
676 |
|
---|
677 | dprintf(("OSLibWinSetClientPos (%d,%d) (%d,%d) -> (%d,%d) (%d,%d)", x, y, x+cx, y+cy, swp.x, swp.y, swp.x+swp.cx, swp.y+swp.cy));
|
---|
678 |
|
---|
679 | rc = WinSetMultWindowPos(GetThreadHAB(), &swp, 1);
|
---|
680 | if(rc == FALSE) {
|
---|
681 | dprintf(("OSLibWinSetClientPos: WinSetMultWindowPos %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
|
---|
682 | }
|
---|
683 | }
|
---|
684 | //******************************************************************************
|
---|
685 | //******************************************************************************
|
---|
686 | BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
|
---|
687 | {
|
---|
688 | BOOL rc;
|
---|
689 |
|
---|
690 | WinMapWindowPoints(hwndFrame, HWND_DESKTOP, (PPOINTL)pRect, 2);
|
---|
691 |
|
---|
692 | rc = WinCalcFrameRect(hwndFrame, (PRECTL)pRect, fClient);
|
---|
693 | WinMapWindowPoints(HWND_DESKTOP, hwndFrame, (PPOINTL)pRect, 2);
|
---|
694 |
|
---|
695 | return rc;
|
---|
696 | }
|
---|
697 | //******************************************************************************
|
---|
698 | //******************************************************************************
|
---|
699 | BOOL OSLibGetMinMaxInfo(HWND hwndFrame, MINMAXINFO *pMinMax)
|
---|
700 | {
|
---|
701 | TRACKINFO tinfo;
|
---|
702 |
|
---|
703 | memset(&tinfo, 0, sizeof(TRACKINFO));
|
---|
704 | WinSendMsg(hwndFrame, WM_QUERYTRACKINFO, (MPARAM)0,(MPARAM)&tinfo);
|
---|
705 |
|
---|
706 | pMinMax->ptMinTrackSize.x = tinfo.ptlMinTrackSize.x;
|
---|
707 | pMinMax->ptMinTrackSize.y = tinfo.ptlMinTrackSize.y;
|
---|
708 | pMinMax->ptMaxTrackSize.x = tinfo.ptlMaxTrackSize.x;
|
---|
709 | pMinMax->ptMaxTrackSize.y = tinfo.ptlMaxTrackSize.y;
|
---|
710 | return TRUE;
|
---|
711 | }
|
---|
712 | //******************************************************************************
|
---|
713 | //******************************************************************************
|
---|
714 | HWND OSLibWinBeginEnumWindows(HWND hwnd)
|
---|
715 | {
|
---|
716 | if(hwnd == OSLIB_HWND_DESKTOP) hwnd = HWND_DESKTOP;
|
---|
717 | else
|
---|
718 | if(hwnd == OSLIB_HWND_OBJECT) hwnd = HWND_OBJECT;
|
---|
719 |
|
---|
720 | return WinBeginEnumWindows(hwnd);
|
---|
721 | }
|
---|
722 | //******************************************************************************
|
---|
723 | //******************************************************************************
|
---|
724 | HWND OSLibWinGetNextWindow(HWND hwndEnum)
|
---|
725 | {
|
---|
726 | return WinGetNextWindow(hwndEnum);
|
---|
727 | }
|
---|
728 | //******************************************************************************
|
---|
729 | //******************************************************************************
|
---|
730 | HWND OSLibWinQueryClientWindow(HWND hwndFrame)
|
---|
731 | {
|
---|
732 | HWND hwndClient = 0;
|
---|
733 |
|
---|
734 | if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME)
|
---|
735 | hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
|
---|
736 |
|
---|
737 | return hwndClient;
|
---|
738 | }
|
---|
739 | //******************************************************************************
|
---|
740 | //******************************************************************************
|
---|
741 | BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
|
---|
742 | {
|
---|
743 | return WinEndEnumWindows(hwndEnum);
|
---|
744 | }
|
---|
745 | //******************************************************************************
|
---|
746 | //******************************************************************************
|
---|
747 | BOOL OSLibWinQueryWindowProcess(HWND hwnd, ULONG *pid, ULONG *tid)
|
---|
748 | {
|
---|
749 | return WinQueryWindowProcess(hwnd, pid, tid);
|
---|
750 | }
|
---|
751 | //******************************************************************************
|
---|
752 | //******************************************************************************
|
---|
753 | BOOL OSLibWinMapWindowPoints (HWND hwndFrom, HWND hwndTo, OSLIBPOINT *pptl, ULONG num)
|
---|
754 | {
|
---|
755 | return WinMapWindowPoints (hwndFrom, hwndTo, (PPOINTL)pptl, num);
|
---|
756 | }
|
---|
757 | //******************************************************************************
|
---|
758 | //******************************************************************************
|
---|
759 | HWND OSLibWinQueryObjectWindow(VOID)
|
---|
760 | {
|
---|
761 | return WinQueryObjectWindow(HWND_DESKTOP);
|
---|
762 | }
|
---|
763 | //******************************************************************************
|
---|
764 | //******************************************************************************
|
---|
765 | HWND OSLibWinObjectWindowFromID(HWND hwndOwner, ULONG ID)
|
---|
766 | {
|
---|
767 | HWND hwndNext, hwndFound=0;
|
---|
768 | HENUM henum;
|
---|
769 |
|
---|
770 | henum = WinBeginEnumWindows(HWND_OBJECT);
|
---|
771 | while ((hwndNext = WinGetNextWindow(henum)) != 0)
|
---|
772 | {
|
---|
773 | if(WinQueryWindow(hwndNext, QW_OWNER) == hwndOwner &&
|
---|
774 | WinQueryWindowUShort(hwndNext, QWS_ID) == ID)
|
---|
775 | {
|
---|
776 | hwndFound = hwndNext;
|
---|
777 | break;
|
---|
778 | }
|
---|
779 | }
|
---|
780 | WinEndEnumWindows(henum);
|
---|
781 | return hwndFound;
|
---|
782 | }
|
---|
783 | //******************************************************************************
|
---|
784 | //******************************************************************************
|
---|
785 | BOOL OSLibSetWindowID(HWND hwnd, ULONG value)
|
---|
786 | {
|
---|
787 | dprintf(("OSLibSetWindowID hwnd:%x ID:%x", hwnd, value));
|
---|
788 | return WinSetWindowULong(hwnd, QWS_ID, value);
|
---|
789 | }
|
---|
790 | //******************************************************************************
|
---|
791 | //******************************************************************************
|
---|
792 | PVOID OSLibWinSubclassWindow(HWND hwnd,PVOID newWndProc)
|
---|
793 | {
|
---|
794 | return WinSubclassWindow(hwnd,(PFNWP)newWndProc);
|
---|
795 | }
|
---|
796 | //******************************************************************************
|
---|
797 | //******************************************************************************
|
---|
798 | BOOL OSLibSetWindowRestoreRect(HWND hwnd, PRECT pRect)
|
---|
799 | {
|
---|
800 | ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
|
---|
801 |
|
---|
802 | WinSetWindowUShort(hwnd, QWS_XRESTORE, (USHORT)pRect->left );
|
---|
803 | WinSetWindowUShort(hwnd, QWS_YRESTORE, (USHORT)(yHeight - pRect->top -
|
---|
804 | (pRect->bottom - pRect->top)));
|
---|
805 | WinSetWindowUShort(hwnd, QWS_CXRESTORE, (USHORT)(pRect->right - pRect->left));
|
---|
806 | WinSetWindowUShort(hwnd, QWS_CYRESTORE, (USHORT)(pRect->bottom - pRect->top));
|
---|
807 | return TRUE;
|
---|
808 | }
|
---|
809 | //******************************************************************************
|
---|
810 | //******************************************************************************
|
---|
811 | BOOL OSLibSetWindowMinPos(HWND hwnd, ULONG x, ULONG y)
|
---|
812 | {
|
---|
813 | ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
|
---|
814 |
|
---|
815 | WinSetWindowUShort(hwnd, QWS_XMINIMIZE, (USHORT)x );
|
---|
816 | WinSetWindowUShort(hwnd, QWS_YMINIMIZE, (USHORT)(yHeight - y -
|
---|
817 | ( 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER)) -
|
---|
818 | WinQuerySysValue( HWND_DESKTOP, SV_CYICON)));
|
---|
819 | return TRUE;
|
---|
820 | }
|
---|
821 | //******************************************************************************
|
---|
822 | //******************************************************************************
|
---|
823 | BOOL OSLibWinGetKeyboardStateTable(unsigned char *PMKeyState)
|
---|
824 | {
|
---|
825 | return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)PMKeyState, FALSE );
|
---|
826 | }
|
---|
827 | //******************************************************************************
|
---|
828 | //******************************************************************************
|
---|
829 | BOOL OSLibWinSetKeyboardStateTable(unsigned char *PMKeyState)
|
---|
830 | {
|
---|
831 | return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)PMKeyState, TRUE );
|
---|
832 | }
|
---|
833 | //******************************************************************************
|
---|
834 | //******************************************************************************
|
---|
835 | USHORT APIENTRY WinTranslateChar2( USHORT /* Codepage (currently ignored) */
|
---|
836 | , PUSHORT /* Ptr to char to translate */
|
---|
837 | , PULONG /* Ptr to deadkey save info */
|
---|
838 | , USHORT /* Translation option (TC_xxx) */
|
---|
839 | , PUSHORT /* Ptr to shift state (TCF_xxx) */
|
---|
840 | );
|
---|
841 | //******************************************************************************
|
---|
842 | //******************************************************************************
|
---|
843 | USHORT OSLibWinTranslateChar(USHORT usScanCode, ULONG type, USHORT shiftstate)
|
---|
844 | {
|
---|
845 | WinTranslateChar2(0, &usScanCode, NULL, type, &shiftstate);
|
---|
846 | return usScanCode;
|
---|
847 | }
|
---|
848 | //******************************************************************************
|
---|
849 | //******************************************************************************
|
---|
850 | BOOL OSLibWinEnableWindowUpdate(HWND hwndFrame, HWND hwndClient ,BOOL fEnable)
|
---|
851 | {
|
---|
852 | WinEnableWindowUpdate(hwndFrame, fEnable);
|
---|
853 | return WinEnableWindowUpdate(hwndClient, fEnable);
|
---|
854 | }
|
---|
855 | //******************************************************************************
|
---|
856 | //******************************************************************************
|
---|
857 | ULONG OSLibWinGetLastError()
|
---|
858 | {
|
---|
859 | return WinGetLastError(GetThreadHAB()) & 0xFFFF;
|
---|
860 | }
|
---|
861 | //******************************************************************************
|
---|
862 | //******************************************************************************
|
---|
863 | void OSLibWinShowTaskList(HWND hwndFrame)
|
---|
864 | {
|
---|
865 | //CB: don't know if this works on all machines
|
---|
866 | WinSetActiveWindow(HWND_DESKTOP,0x8000000E);
|
---|
867 | }
|
---|
868 | //******************************************************************************
|
---|
869 | //******************************************************************************
|
---|
870 | void OSLibSetWindowStyle(HWND hwndFrame, HWND hwndClient, ULONG dwStyle, ULONG dwExStyle)
|
---|
871 | {
|
---|
872 | ULONG dwWinStyle;
|
---|
873 | ULONG dwOldWinStyle;
|
---|
874 |
|
---|
875 | //client window:
|
---|
876 | dwWinStyle = WinQueryWindowULong(hwndClient, QWL_STYLE);
|
---|
877 | dwOldWinStyle = dwWinStyle;
|
---|
878 |
|
---|
879 | if(dwStyle & WS_CLIPCHILDREN_W) {
|
---|
880 | dwWinStyle |= WS_CLIPCHILDREN;
|
---|
881 | }
|
---|
882 | else dwWinStyle &= ~WS_CLIPCHILDREN;
|
---|
883 |
|
---|
884 | if(dwWinStyle != dwOldWinStyle) {
|
---|
885 | WinSetWindowULong(hwndClient, QWL_STYLE, dwWinStyle);
|
---|
886 | }
|
---|
887 |
|
---|
888 | //Frame window
|
---|
889 | dwWinStyle = WinQueryWindowULong(hwndFrame, QWL_STYLE);
|
---|
890 | dwOldWinStyle = dwWinStyle;
|
---|
891 | if(dwStyle & WS_DISABLED_W) {
|
---|
892 | dwWinStyle |= WS_DISABLED;
|
---|
893 | }
|
---|
894 | else dwWinStyle &= ~WS_DISABLED;
|
---|
895 |
|
---|
896 | if(dwStyle & WS_CLIPSIBLINGS_W) {
|
---|
897 | dwWinStyle |= WS_CLIPSIBLINGS;
|
---|
898 | }
|
---|
899 | else dwWinStyle &= ~WS_CLIPSIBLINGS;
|
---|
900 |
|
---|
901 | if(dwStyle & WS_MINIMIZE_W) {
|
---|
902 | dwWinStyle |= WS_MINIMIZED;
|
---|
903 | }
|
---|
904 | else dwWinStyle &= ~WS_MINIMIZED;
|
---|
905 |
|
---|
906 | if(dwStyle & WS_MAXIMIZE_W) {
|
---|
907 | dwWinStyle |= WS_MAXIMIZED;
|
---|
908 | }
|
---|
909 | else dwWinStyle &= ~WS_MAXIMIZED;
|
---|
910 |
|
---|
911 | if(dwWinStyle != dwOldWinStyle) {
|
---|
912 | WinSetWindowULong(hwndFrame, QWL_STYLE, dwWinStyle);
|
---|
913 | }
|
---|
914 | if(fOS2Look) {
|
---|
915 | ULONG OSFrameStyle = 0;
|
---|
916 | if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W) {
|
---|
917 | if(WinWindowFromID(hwndFrame, FID_TITLEBAR) == 0) {
|
---|
918 | OSFrameStyle = FCF_TITLEBAR;
|
---|
919 | }
|
---|
920 | if((dwStyle & WS_SYSMENU_W) && !(dwExStyle & WS_EX_TOOLWINDOW_W))
|
---|
921 | {
|
---|
922 | if(WinWindowFromID(hwndFrame, FID_SYSMENU) == 0) {
|
---|
923 | OSFrameStyle |= FCF_SYSMENU;
|
---|
924 | }
|
---|
925 | }
|
---|
926 | if((dwStyle & WS_MINIMIZEBOX_W) || (dwStyle & WS_MAXIMIZEBOX_W)) {
|
---|
927 | if(WinWindowFromID(hwndFrame, FID_MINMAX) == 0) {
|
---|
928 | OSFrameStyle |= FCF_MINMAX;
|
---|
929 | }
|
---|
930 | }
|
---|
931 | else
|
---|
932 | if(dwStyle & WS_SYSMENU_W) {
|
---|
933 | if(WinWindowFromID(hwndFrame, FID_MINMAX) == 0) {
|
---|
934 | OSFrameStyle |= FCF_CLOSEBUTTON;
|
---|
935 | }
|
---|
936 | }
|
---|
937 | }
|
---|
938 | if(OSFrameStyle) {
|
---|
939 | FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
|
---|
940 |
|
---|
941 | FCData.flCreateFlags = OSFrameStyle;
|
---|
942 | WinCreateFrameControls(hwndFrame, &FCData, NULL);
|
---|
943 | }
|
---|
944 | }
|
---|
945 | }
|
---|
946 | //******************************************************************************
|
---|
947 | //******************************************************************************
|
---|
948 | DWORD OSLibQueryWindowStyle(HWND hwnd)
|
---|
949 | {
|
---|
950 | return WinQueryWindowULong(hwnd, QWL_STYLE);
|
---|
951 | }
|
---|
952 | //******************************************************************************
|
---|
953 | //******************************************************************************
|
---|
954 | void OSLibWinSetVisibleRegionNotify(HWND hwnd, BOOL fNotify)
|
---|
955 | {
|
---|
956 | WinSetVisibleRegionNotify(hwnd, fNotify);
|
---|
957 | }
|
---|
958 | //******************************************************************************
|
---|
959 | //******************************************************************************
|
---|
960 | HWND OSLibWinQueryCapture()
|
---|
961 | {
|
---|
962 | return WinQueryCapture(HWND_DESKTOP);
|
---|
963 | }
|
---|
964 | //******************************************************************************
|
---|
965 | //******************************************************************************
|
---|
966 | BOOL OSLibWinSetCapture(HWND hwnd)
|
---|
967 | {
|
---|
968 | return WinSetCapture(HWND_DESKTOP, hwnd);
|
---|
969 | }
|
---|
970 | //******************************************************************************
|
---|
971 | //******************************************************************************
|
---|
972 | BOOL OSLibWinRemoveFromTasklist(HANDLE hTaskList)
|
---|
973 | {
|
---|
974 | return (WinRemoveSwitchEntry(hTaskList)) ? FALSE : TRUE;
|
---|
975 | }
|
---|
976 | //******************************************************************************
|
---|
977 | //******************************************************************************
|
---|
978 | HANDLE OSLibWinAddToTaskList(HWND hwndFrame, char *title, BOOL fVisible)
|
---|
979 | {
|
---|
980 | SWCNTRL swctrl;
|
---|
981 | ULONG tid;
|
---|
982 |
|
---|
983 | swctrl.hwnd = hwndFrame;
|
---|
984 | swctrl.hwndIcon = 0;
|
---|
985 | swctrl.hprog = 0;
|
---|
986 | WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
|
---|
987 | swctrl.idSession = 0;
|
---|
988 | swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
|
---|
989 | swctrl.fbJump = SWL_JUMPABLE;
|
---|
990 | swctrl.bProgType = PROG_PM;
|
---|
991 | if(title) {
|
---|
992 | strncpy(swctrl.szSwtitle, title, MAXNAMEL+4);
|
---|
993 | swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
|
---|
994 | }
|
---|
995 | else {
|
---|
996 | swctrl.szSwtitle[0] = 0;
|
---|
997 | swctrl.uchVisibility = SWL_INVISIBLE;
|
---|
998 | }
|
---|
999 | return WinAddSwitchEntry(&swctrl);
|
---|
1000 | }
|
---|
1001 | //******************************************************************************
|
---|
1002 | //******************************************************************************
|
---|
1003 | BOOL OSLibWinChangeTaskList(HANDLE hTaskList, HWND hwndFrame, char *title, BOOL fVisible)
|
---|
1004 | {
|
---|
1005 | SWCNTRL swctrl;
|
---|
1006 | ULONG tid;
|
---|
1007 |
|
---|
1008 | swctrl.hwnd = hwndFrame;
|
---|
1009 | swctrl.hwndIcon = 0;
|
---|
1010 | swctrl.hprog = 0;
|
---|
1011 | WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
|
---|
1012 | swctrl.idSession = 0;
|
---|
1013 | swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
|
---|
1014 | swctrl.fbJump = SWL_JUMPABLE;
|
---|
1015 | swctrl.bProgType = PROG_PM;
|
---|
1016 | if(title) {
|
---|
1017 | strncpy(swctrl.szSwtitle, title, MAXNAMEL+4);
|
---|
1018 | swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
|
---|
1019 | }
|
---|
1020 | else {
|
---|
1021 | swctrl.szSwtitle[0] = 0;
|
---|
1022 | swctrl.uchVisibility = SWL_INVISIBLE;
|
---|
1023 | }
|
---|
1024 | return (WinChangeSwitchEntry(hTaskList, &swctrl)) ? FALSE : TRUE;
|
---|
1025 | }
|
---|
1026 | //******************************************************************************
|
---|
1027 | //******************************************************************************
|
---|
1028 | BOOL OSLibWinLockWindowUpdate(HWND hwnd)
|
---|
1029 | {
|
---|
1030 | return WinLockWindowUpdate(HWND_DESKTOP, (HWND)hwnd);
|
---|
1031 | }
|
---|
1032 | //******************************************************************************
|
---|
1033 | //******************************************************************************
|
---|
1034 | ULONG OSLibGetScreenHeight()
|
---|
1035 | {
|
---|
1036 | return ScreenHeight;
|
---|
1037 | }
|
---|
1038 | //******************************************************************************
|
---|
1039 | //******************************************************************************
|
---|
1040 | ULONG OSLibGetScreenWidth()
|
---|
1041 | {
|
---|
1042 | return ScreenWidth;
|
---|
1043 | }
|
---|
1044 | //******************************************************************************
|
---|
1045 | //Returns the maximum position for a window
|
---|
1046 | //Should only be used from toplevel windows
|
---|
1047 | //******************************************************************************
|
---|
1048 | BOOL OSLibWinGetMaxPosition(HWND hwndOS2, RECT *rect)
|
---|
1049 | {
|
---|
1050 | SWP swp;
|
---|
1051 |
|
---|
1052 | if(!WinGetMaxPosition(hwndOS2, &swp)) {
|
---|
1053 | dprintf(("WARNING: WinGetMaxPosition %x returned FALSE", hwndOS2));
|
---|
1054 | return FALSE;
|
---|
1055 | }
|
---|
1056 | rect->left = swp.x;
|
---|
1057 | rect->right = swp.x + swp.cx;
|
---|
1058 | rect->top = ScreenHeight - (swp.y + swp.cy);
|
---|
1059 | rect->bottom = ScreenHeight - swp.y;
|
---|
1060 | return TRUE;
|
---|
1061 | }
|
---|
1062 | //******************************************************************************
|
---|
1063 | //******************************************************************************
|
---|
1064 | BOOL OSLibWinShowPointer(BOOL fShow)
|
---|
1065 | {
|
---|
1066 | return WinShowPointer(HWND_DESKTOP, fShow);
|
---|
1067 | }
|
---|
1068 | //******************************************************************************
|
---|
1069 | //******************************************************************************
|
---|