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

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

extra logging + support for postponed ddraw resize

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