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

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

more logging

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