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

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

Deactivate window when hiding it to force PM to switch focus.

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