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

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

PF: Create invisible vertical scroller for all top-level windows so the IBM wheel driver sends us WM_VSCROLL messages

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