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

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

PF: Disable close button & close item in system menu for windows with SC_NOCLOSE class style

File size: 45.8 KB
Line 
1/* $Id: oslibwin.cpp,v 1.129 2002-10-15 09:18:10 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//******************************************************************************
686//******************************************************************************
687void OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld,
688 int parentHeight, HWND hFrame)
689{
690 BOOL fCvt = FALSE;
691
692 HWND hWnd = pwpos->hwnd;
693 HWND hWndInsertAfter = pwpos->hwndInsertAfter;
694 long x = pwpos->x;
695 long y = pwpos->y;
696 long cx = pwpos->cx;
697 long cy = pwpos->cy;
698 UINT fuFlags = pwpos->flags;
699
700 HWND hWinAfter;
701 ULONG flags = 0;
702 HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
703
704 if (hWndInsertAfter == HWND_TOPMOST_W)
705// hWinAfter = HWND_TOPMOST;
706 hWinAfter = HWND_TOP;
707 else if (hWndInsertAfter == HWND_NOTOPMOST_W)
708// hWinAfter = HWND_NOTOPMOST;
709 hWinAfter = HWND_TOP;
710 else if (hWndInsertAfter == HWND_TOP_W)
711 hWinAfter = HWND_TOP;
712 else if (hWndInsertAfter == HWND_BOTTOM_W)
713 hWinAfter = HWND_BOTTOM;
714 else
715 hWinAfter = (HWND) hWndInsertAfter;
716
717 if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
718 if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
719 if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
720 if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
721 if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
722 if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
723 if ( fuFlags & SWP_HIDEWINDOW_W) flags |= SWP_HIDE;
724 if ( fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
725
726 if(flags & (SWP_MOVE | SWP_SIZE))
727 {
728 if((flags & SWP_MOVE) == 0)
729 {
730 x = pswpOld->x;
731 y = pswpOld->y;
732
733 y = parentHeight - y - pswpOld->cy;
734 }
735
736 if(flags & SWP_SIZE)
737 {
738 if (cy != pswpOld->cy)
739 flags |= SWP_MOVE;
740 }
741 else
742 {
743 cx = pswpOld->cx;
744 cy = pswpOld->cy;
745 }
746 y = parentHeight - y - cy;
747
748 if ((pswpOld->x == x) && (pswpOld->y == y))
749 flags &= ~SWP_MOVE;
750
751 if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
752 flags &= ~SWP_SIZE;
753 }
754
755 pswp->fl = flags;
756 pswp->cy = cy;
757 pswp->cx = cx;
758 pswp->x = x;
759 pswp->y = y;
760 pswp->hwndInsertBehind = hWinAfter;
761 pswp->hwnd = hWindow;
762 pswp->ulReserved1 = 0;
763 pswp->ulReserved2 = 0;
764}
765//******************************************************************************
766//******************************************************************************
767void OSLibWinSetClientPos(HWND hwnd, int x, int y, int cx, int cy, int parentHeight)
768{
769 SWP swp;
770 BOOL rc;
771
772 swp.hwnd = hwnd;
773 swp.hwndInsertBehind = 0;
774 swp.x = x;
775 swp.y = parentHeight - y - cy;
776 swp.cx = cx;
777 swp.cy = cy;
778 swp.fl = SWP_MOVE | SWP_SIZE;
779
780 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));
781
782 rc = WinSetMultWindowPos(GetThreadHAB(), &swp, 1);
783 if(rc == FALSE) {
784 dprintf(("OSLibWinSetClientPos: WinSetMultWindowPos %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
785 }
786}
787//******************************************************************************
788//******************************************************************************
789BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
790{
791 BOOL rc;
792
793 WinMapWindowPoints(hwndFrame, HWND_DESKTOP, (PPOINTL)pRect, 2);
794
795 rc = WinCalcFrameRect(hwndFrame, (PRECTL)pRect, fClient);
796 WinMapWindowPoints(HWND_DESKTOP, hwndFrame, (PPOINTL)pRect, 2);
797
798 return rc;
799}
800//******************************************************************************
801//******************************************************************************
802BOOL OSLibGetMinMaxInfo(HWND hwndFrame, MINMAXINFO *pMinMax)
803{
804 TRACKINFO tinfo;
805
806 memset(&tinfo, 0, sizeof(TRACKINFO));
807 WinSendMsg(hwndFrame, WM_QUERYTRACKINFO, (MPARAM)0,(MPARAM)&tinfo);
808
809 pMinMax->ptMinTrackSize.x = tinfo.ptlMinTrackSize.x;
810 pMinMax->ptMinTrackSize.y = tinfo.ptlMinTrackSize.y;
811 pMinMax->ptMaxTrackSize.x = tinfo.ptlMaxTrackSize.x;
812 pMinMax->ptMaxTrackSize.y = tinfo.ptlMaxTrackSize.y;
813 return TRUE;
814}
815//******************************************************************************
816//******************************************************************************
817HWND OSLibWinBeginEnumWindows(HWND hwnd)
818{
819 if(hwnd == OSLIB_HWND_DESKTOP) hwnd = HWND_DESKTOP;
820 else
821 if(hwnd == OSLIB_HWND_OBJECT) hwnd = HWND_OBJECT;
822
823 return WinBeginEnumWindows(hwnd);
824}
825//******************************************************************************
826//******************************************************************************
827HWND OSLibWinGetNextWindow(HWND hwndEnum)
828{
829 return WinGetNextWindow(hwndEnum);
830}
831//******************************************************************************
832//******************************************************************************
833HWND OSLibWinQueryClientWindow(HWND hwndFrame)
834{
835 HWND hwndClient = 0;
836
837 if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME)
838 hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
839
840 return hwndClient;
841}
842//******************************************************************************
843//******************************************************************************
844BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
845{
846 return WinEndEnumWindows(hwndEnum);
847}
848//******************************************************************************
849//******************************************************************************
850BOOL OSLibWinQueryWindowProcess(HWND hwnd, ULONG *pid, ULONG *tid)
851{
852 BOOL ret;
853
854 ret = WinQueryWindowProcess(hwnd, pid, tid);
855 *tid = MAKE_THREADID(*pid, *tid);
856 return ret;
857}
858//******************************************************************************
859//******************************************************************************
860BOOL OSLibWinMapWindowPoints (HWND hwndFrom, HWND hwndTo, OSLIBPOINT *pptl, ULONG num)
861{
862 return WinMapWindowPoints (hwndFrom, hwndTo, (PPOINTL)pptl, num);
863}
864//******************************************************************************
865//******************************************************************************
866HWND OSLibWinQueryObjectWindow(VOID)
867{
868 return WinQueryObjectWindow(HWND_DESKTOP);
869}
870//******************************************************************************
871//******************************************************************************
872HWND OSLibWinObjectWindowFromID(HWND hwndOwner, ULONG ID)
873{
874 HWND hwndNext, hwndFound=0;
875 HENUM henum;
876
877 henum = WinBeginEnumWindows(HWND_OBJECT);
878 while ((hwndNext = WinGetNextWindow(henum)) != 0)
879 {
880 if(WinQueryWindow(hwndNext, QW_OWNER) == hwndOwner &&
881 WinQueryWindowUShort(hwndNext, QWS_ID) == ID)
882 {
883 hwndFound = hwndNext;
884 break;
885 }
886 }
887 WinEndEnumWindows(henum);
888 return hwndFound;
889}
890//******************************************************************************
891//******************************************************************************
892BOOL OSLibSetWindowID(HWND hwnd, ULONG value)
893{
894 dprintf(("OSLibSetWindowID hwnd:%x ID:%x", hwnd, value));
895 return WinSetWindowULong(hwnd, QWS_ID, value);
896}
897//******************************************************************************
898//******************************************************************************
899PVOID OSLibWinSubclassWindow(HWND hwnd,PVOID newWndProc)
900{
901 return WinSubclassWindow(hwnd,(PFNWP)newWndProc);
902}
903//******************************************************************************
904//******************************************************************************
905BOOL OSLibSetWindowRestoreRect(HWND hwnd, PRECT pRect)
906{
907 ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
908
909 WinSetWindowUShort(hwnd, QWS_XRESTORE, (USHORT)pRect->left );
910 WinSetWindowUShort(hwnd, QWS_YRESTORE, (USHORT)(yHeight - pRect->top -
911 (pRect->bottom - pRect->top)));
912 WinSetWindowUShort(hwnd, QWS_CXRESTORE, (USHORT)(pRect->right - pRect->left));
913 WinSetWindowUShort(hwnd, QWS_CYRESTORE, (USHORT)(pRect->bottom - pRect->top));
914 return TRUE;
915}
916//******************************************************************************
917//******************************************************************************
918BOOL OSLibSetWindowMinPos(HWND hwnd, ULONG x, ULONG y)
919{
920 ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
921
922 WinSetWindowUShort(hwnd, QWS_XMINIMIZE, (USHORT)x );
923 WinSetWindowUShort(hwnd, QWS_YMINIMIZE, (USHORT)(yHeight - y -
924 ( 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER)) -
925 WinQuerySysValue( HWND_DESKTOP, SV_CYICON)));
926 return TRUE;
927}
928//******************************************************************************
929//******************************************************************************
930BOOL OSLibWinGetKeyboardStateTable(unsigned char *PMKeyState)
931{
932 return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)PMKeyState, FALSE );
933}
934//******************************************************************************
935//******************************************************************************
936BOOL OSLibWinSetKeyboardStateTable(unsigned char *PMKeyState)
937{
938 return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)PMKeyState, TRUE );
939}
940//******************************************************************************
941//******************************************************************************
942USHORT APIENTRY WinTranslateChar2( USHORT /* Codepage (currently ignored) */
943 , PUSHORT /* Ptr to char to translate */
944 , PULONG /* Ptr to deadkey save info */
945 , USHORT /* Translation option (TC_xxx) */
946 , PUSHORT /* Ptr to shift state (TCF_xxx) */
947 );
948//******************************************************************************
949//******************************************************************************
950USHORT OSLibWinTranslateChar(USHORT usScanCode, ULONG type, USHORT shiftstate)
951{
952 USHORT usResult;
953 USHORT sel = GetFS();
954
955 usResult = WinTranslateChar2(0, &usScanCode, NULL, type, &shiftstate);
956 SetFS(sel);
957 return usScanCode;
958}
959//******************************************************************************
960//******************************************************************************
961BOOL OSLibWinEnableWindowUpdate(HWND hwndFrame, HWND hwndClient ,BOOL fEnable)
962{
963 WinEnableWindowUpdate(hwndFrame, fEnable);
964 return WinEnableWindowUpdate(hwndClient, fEnable);
965}
966//******************************************************************************
967//******************************************************************************
968ULONG OSLibWinGetLastError()
969{
970 return WinGetLastError(GetThreadHAB()) & 0xFFFF;
971}
972//******************************************************************************
973//******************************************************************************
974void OSLibWinShowTaskList(HWND hwndFrame)
975{
976 SWBLOCK swblk;
977 // the first entry returned is always the window list itself
978 if (WinQuerySwitchList(0, &swblk, sizeof(SWBLOCK)) > 0)
979 WinSetActiveWindow(HWND_DESKTOP, swblk.aswentry[0].swctl.hwnd);
980// WinShowWindow(swblk.aswentry[0].swctl.hwnd, TRUE);
981}
982//******************************************************************************
983//******************************************************************************
984void OSLibSetWindowStyle(HWND hwndFrame, HWND hwndClient, ULONG dwStyle, ULONG dwExStyle)
985{
986 ULONG dwWinStyle;
987 ULONG dwOldWinStyle;
988
989 //client window:
990 dwWinStyle = WinQueryWindowULong(hwndClient, QWL_STYLE);
991 dwOldWinStyle = dwWinStyle;
992
993 if(dwStyle & WS_CLIPCHILDREN_W) {
994 dwWinStyle |= WS_CLIPCHILDREN;
995 }
996 else dwWinStyle &= ~WS_CLIPCHILDREN;
997
998 if(dwWinStyle != dwOldWinStyle) {
999 WinSetWindowULong(hwndClient, QWL_STYLE, dwWinStyle);
1000 }
1001
1002 //Frame window
1003 dwWinStyle = WinQueryWindowULong(hwndFrame, QWL_STYLE);
1004 dwOldWinStyle = dwWinStyle;
1005 if(dwStyle & WS_DISABLED_W) {
1006 dwWinStyle |= WS_DISABLED;
1007 }
1008 else dwWinStyle &= ~WS_DISABLED;
1009
1010 if(dwExStyle & WS_EX_TOPMOST_W) {
1011 dwWinStyle |= WS_TOPMOST;
1012 }
1013 else dwWinStyle &= ~WS_TOPMOST;
1014
1015 if(dwStyle & WS_CLIPSIBLINGS_W) {
1016 dwWinStyle |= WS_CLIPSIBLINGS;
1017 }
1018 else dwWinStyle &= ~WS_CLIPSIBLINGS;
1019
1020 if(dwStyle & WS_MINIMIZE_W) {
1021 dwWinStyle |= WS_MINIMIZED;
1022 }
1023 else dwWinStyle &= ~WS_MINIMIZED;
1024
1025 if(dwStyle & WS_MAXIMIZE_W) {
1026 dwWinStyle |= WS_MAXIMIZED;
1027 }
1028 else dwWinStyle &= ~WS_MAXIMIZED;
1029
1030 if(dwWinStyle != dwOldWinStyle) {
1031 WinSetWindowULong(hwndFrame, QWL_STYLE, dwWinStyle);
1032 }
1033 if(fOS2Look) {
1034 ULONG OSFrameStyle = 0;
1035 if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W)
1036 {
1037 if(WinWindowFromID(hwndFrame, FID_TITLEBAR) == 0) {
1038 OSFrameStyle = FCF_TITLEBAR;
1039 }
1040
1041 if((dwStyle & WS_SYSMENU_W) && !(dwExStyle & WS_EX_TOOLWINDOW_W))
1042 {
1043 if(WinWindowFromID(hwndFrame, FID_SYSMENU) == 0) {
1044 OSFrameStyle |= FCF_SYSMENU;
1045 }
1046 }
1047
1048 if((dwStyle & WS_MINIMIZEBOX_W) || (dwStyle & WS_MAXIMIZEBOX_W)) {
1049 if(dwStyle & WS_MINIMIZEBOX_W)
1050 if(WinWindowFromID(hwndFrame, FID_MINMAX) == 0) {
1051 OSFrameStyle |= FCF_MINBUTTON;
1052 }
1053
1054 if(dwStyle & WS_MAXIMIZEBOX_W)
1055 if(WinWindowFromID(hwndFrame, FID_MINMAX) == 0) {
1056 OSFrameStyle |= FCF_MAXBUTTON;
1057 }
1058 }
1059 else
1060 if(dwStyle & WS_SYSMENU_W) {
1061 if(WinWindowFromID(hwndFrame, FID_MINMAX) == 0) {
1062 OSFrameStyle |= FCF_CLOSEBUTTON;
1063 }
1064 }
1065 }
1066 // no caption, delete all controls if they exist
1067 else
1068 {
1069 if (WinWindowFromID(hwndFrame, FID_TITLEBAR))
1070 WinDestroyWindow(WinWindowFromID(hwndFrame, FID_TITLEBAR));
1071 if (WinWindowFromID(hwndFrame, FID_SYSMENU))
1072 WinDestroyWindow(WinWindowFromID(hwndFrame, FID_SYSMENU));
1073 if (WinWindowFromID(hwndFrame, FID_MINMAX))
1074 WinDestroyWindow(WinWindowFromID(hwndFrame, FID_MINMAX));
1075 }
1076
1077 if(OSFrameStyle) {
1078 FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
1079 char buffer[255];
1080 FCData.flCreateFlags = OSFrameStyle;
1081
1082 GetWindowTextA(OS2ToWin32Handle(hwndClient), buffer, sizeof(buffer));
1083 WinCreateFrameControls(hwndFrame, &FCData, buffer );
1084
1085 if (WinQueryActiveWindow(HWND_DESKTOP) == hwndFrame)
1086 WinSendMsg(WinWindowFromID(hwndFrame, FID_TITLEBAR), TBM_SETHILITE, (MPARAM)1, 0);
1087
1088 }
1089 } // os2look
1090}
1091
1092//******************************************************************************
1093//******************************************************************************
1094BOOL OSLibChangeCloseButtonState(HWND hwndFrame, BOOL State)
1095{
1096 return WinEnableMenuItem(WinWindowFromID(hwndFrame, FID_SYSMENU), SC_CLOSE, State);
1097}
1098//******************************************************************************
1099//******************************************************************************
1100DWORD OSLibQueryWindowStyle(HWND hwnd)
1101{
1102 return WinQueryWindowULong(hwnd, QWL_STYLE);
1103}
1104//******************************************************************************
1105//******************************************************************************
1106void OSLibWinSetVisibleRegionNotify(HWND hwnd, BOOL fNotify)
1107{
1108 WinSetVisibleRegionNotify(hwnd, fNotify);
1109}
1110//******************************************************************************
1111//******************************************************************************
1112HWND OSLibWinQueryCapture()
1113{
1114 return WinQueryCapture(HWND_DESKTOP);
1115}
1116//******************************************************************************
1117//******************************************************************************
1118BOOL OSLibWinSetCapture(HWND hwnd)
1119{
1120 return WinSetCapture(HWND_DESKTOP, hwnd);
1121}
1122//******************************************************************************
1123//******************************************************************************
1124BOOL OSLibWinRemoveFromTasklist(HANDLE hTaskList)
1125{
1126 return (WinRemoveSwitchEntry(hTaskList)) ? FALSE : TRUE;
1127}
1128//******************************************************************************
1129//******************************************************************************
1130HANDLE OSLibWinAddToTaskList(HWND hwndFrame, char *title, BOOL fVisible)
1131{
1132 SWCNTRL swctrl;
1133 ULONG tid;
1134
1135 swctrl.hwnd = hwndFrame;
1136 swctrl.hwndIcon = 0;
1137 swctrl.hprog = 0;
1138 WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
1139 swctrl.idSession = 0;
1140 swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
1141 swctrl.fbJump = SWL_JUMPABLE;
1142 swctrl.bProgType = PROG_PM;
1143 if(title) {
1144 CharToOemBuffA( title, swctrl.szSwtitle, min(strlen(title)+1,MAXNAMEL+4) );
1145 swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
1146 }
1147 else {
1148 swctrl.szSwtitle[0] = 0;
1149 swctrl.uchVisibility = SWL_INVISIBLE;
1150 }
1151 return WinAddSwitchEntry(&swctrl);
1152}
1153//******************************************************************************
1154//******************************************************************************
1155BOOL OSLibWinChangeTaskList(HANDLE hTaskList, HWND hwndFrame, char *title, BOOL fVisible)
1156{
1157 SWCNTRL swctrl;
1158 ULONG tid;
1159
1160 swctrl.hwnd = hwndFrame;
1161 swctrl.hwndIcon = 0;
1162 swctrl.hprog = 0;
1163 WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
1164 swctrl.idSession = 0;
1165 swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
1166 swctrl.fbJump = SWL_JUMPABLE;
1167 swctrl.bProgType = PROG_PM;
1168 if(title) {
1169 CharToOemBuffA( title, swctrl.szSwtitle, min(strlen(title)+1,MAXNAMEL+4) );
1170 swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
1171 }
1172 else {
1173 swctrl.szSwtitle[0] = 0;
1174 swctrl.uchVisibility = SWL_INVISIBLE;
1175 }
1176 return (WinChangeSwitchEntry(hTaskList, &swctrl)) ? FALSE : TRUE;
1177}
1178//******************************************************************************
1179//******************************************************************************
1180BOOL OSLibWinLockWindowUpdate(HWND hwnd)
1181{
1182 return WinLockWindowUpdate(HWND_DESKTOP, (HWND)hwnd);
1183}
1184//******************************************************************************
1185//******************************************************************************
1186ULONG OSLibGetScreenHeight()
1187{
1188 return ScreenHeight;
1189}
1190//******************************************************************************
1191//******************************************************************************
1192ULONG OSLibGetScreenWidth()
1193{
1194 return ScreenWidth;
1195}
1196//******************************************************************************
1197//Returns the maximum position for a window
1198//Should only be used from toplevel windows
1199//******************************************************************************
1200BOOL OSLibWinGetMaxPosition(HWND hwndOS2, RECT *rect)
1201{
1202 SWP swp;
1203
1204 if(!WinGetMaxPosition(hwndOS2, &swp)) {
1205 dprintf(("WARNING: WinGetMaxPosition %x returned FALSE", hwndOS2));
1206 return FALSE;
1207 }
1208 rect->left = swp.x;
1209 rect->right = swp.x + swp.cx;
1210 rect->top = ScreenHeight - (swp.y + swp.cy);
1211 rect->bottom = ScreenHeight - swp.y;
1212 return TRUE;
1213}
1214//******************************************************************************
1215//******************************************************************************
1216BOOL OSLibWinShowPointer(BOOL fShow)
1217{
1218 return WinShowPointer(HWND_DESKTOP, fShow);
1219}
1220//******************************************************************************
1221//******************************************************************************
1222ULONG OSLibWinQuerySysColor(int index)
1223{
1224 return CONVERT_RGB(WinQuerySysColor(HWND_DESKTOP, index, 0));
1225}
1226//******************************************************************************
1227//PF This was added for IBM Wheel Mouse driver - it searches for scrollbars and
1228//only if they exist sends WM_VSCROLL messages to the window
1229//******************************************************************************
1230HWND OSLibWinCreateInvisibleScroller(HWND parentHWND, int direction)
1231{
1232 return WinCreateWindow(parentHWND, WC_SCROLLBAR, NULL, direction,
1233 0, 0, 0, 0, parentHWND, HWND_BOTTOM, 1, NULL, NULL);
1234}
1235//******************************************************************************
1236//******************************************************************************
Note: See TracBrowser for help on using the repository browser.