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

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

min/max button recreation doesn't work (hang during destruction probably)

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