source: trunk/src/user32/oslibwin.cpp@ 9563

Last change on this file since 9563 was 9563, checked in by sandervl, 23 years ago

Fix for painting a completely ownerdrawn menu (owner window was wrong); don't do anything in DoNCPaint if window is invisible

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