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

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

Merged Rewind menu control

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