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

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

ToAscii, GetKeyState, GetAsyncKeyState & GetKeyboardState fixes

File size: 47.1 KB
Line 
1/* $Id: oslibwin.cpp,v 1.139 2003-02-16 15:31:10 sandervl Exp $ */
2/*
3 * Window API wrappers for OS/2
4 *
5 *
6 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 * Copyright 1999 Daniela Engert (dani@ngrt.de)
8 *
9 *
10 * Project Odin Software License can be found in LICENSE.TXT
11 *
12 */
13#define INCL_WIN
14#define INCL_PM
15#define INCL_WINSWITCHLIST
16#include <os2wrap.h>
17#include <stdlib.h>
18#include <stdio.h>
19#include <string.h>
20
21#include <misc.h>
22#include <win32type.h>
23#include <winconst.h>
24#include <winuser32.h>
25#include <wprocess.h>
26#include "oslibwin.h"
27#include "oslibutil.h"
28#include "oslibmsg.h"
29#include "oslibgdi.h"
30#include "pmwindow.h"
31#include "initterm.h"
32
33#define DBG_LOCALLOG DBG_oslibwin
34#include "dbglocal.h"
35
36//Undocumented PM WS_TOPMOST style; similar to WS_EX_TOPMOST in Windows
37#define WS_TOPMOST 0x00200000L
38
39//******************************************************************************
40//******************************************************************************
41BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw)
42{
43 if(hwndParent == OSLIB_HWND_DESKTOP)
44 {
45 hwndParent = HWND_DESKTOP;
46 }
47 else
48 if(hwndParent == OSLIB_HWND_OBJECT) {
49 hwndParent = HWND_OBJECT;
50 }
51 return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
52}
53//******************************************************************************
54//******************************************************************************
55BOOL OSLibWinSetOwner(HWND hwnd, HWND hwndOwner)
56{
57 return WinSetOwner(hwnd, hwndOwner);
58}
59//******************************************************************************
60//******************************************************************************
61HWND OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle, ULONG dwOSFrameStyle,
62 char *pszName, HWND Owner, ULONG fHWND_BOTTOM,
63 ULONG id, BOOL fTaskList,BOOL fShellPosition,
64 int classStyle, HWND *hwndFrame)
65{
66 HWND hwndClient;
67 ULONG dwFrameStyle = 0;
68
69 if(pszName && *pszName == 0) {
70 pszName = NULL;
71 }
72 if(hwndParent == OSLIB_HWND_DESKTOP) {
73 hwndParent = HWND_DESKTOP;
74 }
75 if(Owner == OSLIB_HWND_DESKTOP) {
76 Owner = HWND_DESKTOP;
77 }
78
79 if(classStyle & CS_SAVEBITS_W) dwWinStyle |= WS_SAVEBITS;
80 if(classStyle & CS_PARENTDC_W) dwWinStyle |= WS_PARENTCLIP;
81
82 dwWinStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
83
84 if(fTaskList)
85 {
86 dwFrameStyle |= FCF_NOMOVEWITHOWNER;
87 }
88 if (fShellPosition) dwFrameStyle |= FCF_SHELLPOSITION;
89
90 FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
91 FCData.flCreateFlags = dwFrameStyle;
92
93 dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x winstyle %x bottom %d", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle, dwWinStyle, fHWND_BOTTOM));
94
95 //Must not use WS_CLIPCHILDREN style with frame window. Transparency won't work otherwise.
96 //Eg: dialog parent, groupbox; invalidate part of groupbox -> painting algorithm stops when it finds
97 // a window with WS_CLIPCHILDREN -> result: dialog window won't update groupbox background as groupbox only draws the border
98 *hwndFrame = WinCreateWindow(hwndParent,
99 WIN32_STDFRAMECLASS,
100 pszName, (dwWinStyle & ~WS_CLIPCHILDREN), 0, 0, 0, 0,
101 Owner, (fHWND_BOTTOM) ? HWND_BOTTOM : HWND_TOP,
102 id, (PVOID)&FCData, NULL);
103 if(fOS2Look && *hwndFrame) {
104 FCData.flCreateFlags = dwOSFrameStyle;
105 WinCreateFrameControls(*hwndFrame, &FCData, NULL);
106 }
107 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//******************************************************************************
317BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus, BOOL activate)
318{
319 return WinFocusChange (hwndDeskTop, hwndNewFocus, activate ? 0 : FC_NOSETACTIVE);
320}
321//******************************************************************************
322//******************************************************************************
323BOOL OSLibWinIsChild (HWND hwnd, HWND hwndOf)
324{
325 return WinIsChild (hwnd, hwndOf);
326}
327//******************************************************************************
328//******************************************************************************
329ULONG OSLibGetWindowHeight(HWND hwnd)
330{
331 RECTL rect;
332
333 return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
334}
335//******************************************************************************
336//******************************************************************************
337LONG OSLibWinQuerySysValue(LONG iSysValue)
338{
339 return WinQuerySysValue(HWND_DESKTOP,iSysValue);
340}
341//******************************************************************************
342//******************************************************************************
343BOOL OSLibWinSetSysValue(LONG iSysValue, ULONG val)
344{
345 return WinSetSysValue(HWND_DESKTOP, iSysValue, val);
346}
347//******************************************************************************
348//******************************************************************************
349ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer)
350{
351 return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
352}
353//******************************************************************************
354//******************************************************************************
355BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText)
356{
357 return WinSetDlgItemText(hwndDlg,idItem,pszText);
358}
359//******************************************************************************
360//******************************************************************************
361BOOL OSLibWinQueryPointerPos(PPOINT pptlPoint)
362{
363 return WinQueryPointerPos(HWND_DESKTOP,(PPOINTL)pptlPoint);
364}
365//******************************************************************************
366//******************************************************************************
367BOOL OSLibWinSetPointerPos(int x, int y)
368{
369 return WinSetPointerPos(HWND_DESKTOP, x, y);
370}
371//******************************************************************************
372//******************************************************************************
373HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
374{
375 return WinQueryWindow(hwnd, lCode);
376}
377//******************************************************************************
378//******************************************************************************
379BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num)
380{
381 return WinSetMultWindowPos(GetThreadHAB(), pswp, num);
382}
383//******************************************************************************
384//******************************************************************************
385BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
386{
387 BOOL rc = 1;
388
389 if(fl & SWP_SHOW) {
390 rc = WinShowWindow(hwnd, TRUE);
391 }
392 if(rc == 0)
393 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
394 rc = WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, fl);
395 if(rc == 0)
396 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
397 return rc;
398}
399//******************************************************************************
400//******************************************************************************
401BOOL OSLibWinDestroyWindow(HWND hwnd)
402{
403 return WinDestroyWindow(hwnd);
404}
405//******************************************************************************
406//******************************************************************************
407BOOL OSLibWinQueryWindowClientRect(HWND hwndOS2, PRECT pRect)
408{
409 BOOL rc;
410 RECTLOS2 rectl;
411
412 rc = WinQueryWindowRect(hwndOS2, (PRECTL)&rectl);
413 if(rc) {
414 pRect->left = 0;
415 pRect->right = rectl.xRight - rectl.xLeft;
416 pRect->top = 0;
417 pRect->bottom = rectl.yTop - rectl.yBottom;
418 }
419 else memset(pRect, 0, sizeof(RECT));
420 return rc;
421}
422//******************************************************************************
423//******************************************************************************
424BOOL OSLibQueryWindowRectAbsolute (HWND hwndOS2, PRECT pRect)
425{
426 BOOL rc;
427 RECTLOS2 rectl;
428
429 rc = WinQueryWindowRect (hwndOS2, (RECTL *)&rectl);
430 if (rc)
431 {
432 rc = WinMapWindowPoints (hwndOS2, HWND_DESKTOP, (POINTL *)&rectl, 2);
433 if (rc)
434 {
435 pRect->left = rectl.xLeft;
436 pRect->right = rectl.xRight;
437 pRect->top = mapScreenY (rectl.yTop);
438 pRect->bottom = mapScreenY (rectl.yBottom);
439 }
440 }
441 if (!rc)
442 {
443 memset(pRect, 0, sizeof(*pRect));
444 }
445 return rc;
446}
447//******************************************************************************
448//******************************************************************************
449#if 0
450BOOL OSLibWinQueryWindowRect(Win32BaseWindow *window, PRECT pRect, int RelativeTo)
451{
452 BOOL rc;
453 RECTLOS2 rectl;
454
455 rc = WinQueryWindowRect(window->getOS2WindowHandle(), (PRECTL)&rectl);
456 if(rc) {
457 if(RelativeTo == RELATIVE_TO_SCREEN) {
458 mapOS2ToWin32RectFrame(window,windowDesktop,&rectl,pRect);
459 }
460 else mapOS2ToWin32RectFrame(window,&rectl,pRect);
461 }
462 else memset(pRect, 0, sizeof(RECT));
463 return rc;
464}
465#endif
466//******************************************************************************
467//******************************************************************************
468BOOL OSLibWinIsIconic(HWND hwnd)
469{
470 SWP swp;
471 BOOL rc;
472
473 rc = WinQueryWindowPos(hwnd, &swp);
474 if(rc == FALSE) {
475 dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
476 return FALSE;
477 }
478
479 if(swp.fl & SWP_MINIMIZE)
480 return TRUE;
481 else return FALSE;
482}
483//******************************************************************************
484//******************************************************************************
485BOOL OSLibWinSetActiveWindow(HWND hwnd)
486{
487 BOOL rc;
488
489 rc = WinSetActiveWindow(HWND_DESKTOP, hwnd);
490 if(rc == FALSE) {
491 dprintf(("WinSetActiveWindow %x failure: %x", hwnd, OSLibWinGetLastError()));
492 }
493 return rc;
494}
495//******************************************************************************
496//******************************************************************************
497BOOL OSLibWinSetFocus(HWND hwnd)
498{
499 return WinSetFocus(HWND_DESKTOP, hwnd);
500}
501//******************************************************************************
502//******************************************************************************
503BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
504{
505 BOOL rc;
506 HWND hwndClient;
507
508 rc = WinEnableWindow(hwnd, fEnable);
509 hwndClient = WinWindowFromID(hwnd, FID_CLIENT);
510 if(hwndClient) {
511 WinEnableWindow(hwndClient, fEnable);
512 }
513 return rc;
514}
515//******************************************************************************
516//******************************************************************************
517BOOL OSLibWinIsWindowEnabled(HWND hwnd)
518{
519 return WinIsWindowEnabled(hwnd);
520}
521//******************************************************************************
522//******************************************************************************
523BOOL OSLibWinIsWindowVisible(HWND hwnd)
524{
525 return WinIsWindowVisible(hwnd);
526}
527//******************************************************************************
528//******************************************************************************
529HWND OSLibWinQueryActiveWindow()
530{
531 return WinQueryActiveWindow(HWND_DESKTOP);
532}
533//******************************************************************************
534//******************************************************************************
535LONG OSLibWinQueryWindowTextLength(HWND hwnd)
536{
537 return WinQueryWindowTextLength(hwnd);
538}
539//******************************************************************************
540//******************************************************************************
541LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz)
542{
543 return WinQueryWindowText(hwnd, length, lpsz);
544}
545//******************************************************************************
546//******************************************************************************
547BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz)
548{
549 return WinSetWindowText(hwnd, lpsz);
550}
551//******************************************************************************
552//******************************************************************************
553BOOL OSLibWinSetTitleBarText(HWND hwnd, LPSTR lpsz)
554{
555 return WinSetWindowText(WinWindowFromID(hwnd, FID_TITLEBAR), lpsz);
556}
557//******************************************************************************
558//******************************************************************************
559BOOL OSLibWinFlashWindow(HWND hwnd, BOOL fFlash)
560{
561 return WinFlashWindow(hwnd, fFlash);
562}
563//******************************************************************************
564//******************************************************************************
565HWND OSLibWinWindowFromPoint(HWND hwnd, PVOID ppoint)
566{
567 return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE);
568}
569//******************************************************************************
570//******************************************************************************
571BOOL OSLibWinMinimizeWindow(HWND hwnd)
572{
573 /* @@PF The reason for this weird minimize algorithm is that we are not fully
574 using PM for minimization. I.e. we respect all PM messages yet we do mess
575 so much with some messages that minimization is based partly on vodoo.
576 That is if you try minimize and deactivate in one call it will fail.
577 Here we deactivate yourselves and give focus to next window that is
578 on desktop, this func also works with MDI */
579
580 BOOL rc;
581 HWND hwndNext;
582
583 rc = WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_MINIMIZE);
584
585 if (rc) {
586 rc = WinSetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_DEACTIVATE | SWP_ZORDER);
587 if (rc)
588 {
589 HENUM henum;
590 henum = WinBeginEnumWindows(HWND_DESKTOP);
591 while ((hwndNext = WinGetNextWindow(henum)) != NULLHANDLE)
592 {
593 if (WinIsWindowVisible(hwndNext) && WinIsWindowShowing(hwndNext)) break;
594 }
595 WinEndEnumWindows (henum);
596 rc = WinSetWindowPos(hwndNext, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER);
597 }
598 }
599
600 return (rc);
601}
602//******************************************************************************
603//******************************************************************************
604BOOL OSLibWinGetBorderSize(HWND hwnd, OSLIBPOINT *pointl)
605{
606 pointl->x = 0;
607 pointl->y = 0;
608 return (BOOL) WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP( &pointl), 0);
609}
610//******************************************************************************
611//******************************************************************************
612BOOL OSLibWinSetIcon(HWND hwnd, HANDLE hIcon)
613{
614 ULONG hIconOS2 = GetOS2Icon(hIcon);
615 if(hIconOS2)
616 return (BOOL) WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIconOS2, 0);
617 return FALSE;
618}
619//******************************************************************************
620//******************************************************************************
621BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp)
622{
623 return WinQueryWindowPos(hwnd, pswp);
624}
625//******************************************************************************
626//******************************************************************************
627void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld,
628 int parentHeight, HWND hwnd)
629{
630 HWND hWindow = pswp->hwnd;
631 HWND hWndInsertAfter = pswp->hwndInsertBehind;
632 long x = pswp->x;
633 long y = pswp->y;
634 long cx = pswp->cx;
635 long cy = pswp->cy;
636 UINT fuFlags = (UINT)pswp->fl;
637
638 HWND hWinAfter;
639 ULONG flags = 0;
640
641 HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
642
643 if (hWndInsertAfter == HWND_TOP)
644 hWinAfter = HWND_TOP_W;
645 else if (hWndInsertAfter == HWND_BOTTOM)
646 hWinAfter = HWND_BOTTOM_W;
647 else
648 hWinAfter = (HWND) hWndInsertAfter;
649
650 //***********************************
651 // convert PM flags to Windows flags
652 //***********************************
653 if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
654 if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
655 if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
656 if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
657 if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
658 if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
659 if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
660 if ( fuFlags & SWP_NOADJUST) flags |= SWP_NOSENDCHANGING_W;
661
662 if(fuFlags & (SWP_MOVE | SWP_SIZE))
663 {
664 y = parentHeight - y - pswp->cy;
665
666 if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
667 flags |= SWP_NOMOVE_W;
668
669 if ((pswp->cx == pswpOld->cx) && (pswp->cy == pswpOld->cy))
670 flags |= SWP_NOSIZE_W;
671
672 if (fuFlags & SWP_SIZE)
673 {
674 if (pswp->cy != pswpOld->cy)
675 {
676 flags &= ~SWP_NOMOVE_W;
677 }
678 }
679 }
680
681 pswpOld->x = pswp->x;
682 pswpOld->y = parentHeight-pswp->y-pswp->cy;
683 pswpOld->cx = pswp->cx;
684 pswpOld->cy = pswp->cy;
685
686 dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
687 x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
688
689 pwpos->flags = (UINT)flags;
690 pwpos->cy = cy;
691 pwpos->cx = cx;
692 pwpos->x = x;
693 pwpos->y = y;
694 pwpos->hwndInsertAfter = hWinAfter;
695 pwpos->hwnd = hWindow;
696
697 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));
698}
699//******************************************************************************
700//******************************************************************************
701void OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld,
702 int parentHeight, HWND hFrame)
703{
704 BOOL fCvt = FALSE;
705
706 HWND hWnd = pwpos->hwnd;
707 HWND hWndInsertAfter = pwpos->hwndInsertAfter;
708 long x = pwpos->x;
709 long y = pwpos->y;
710 long cx = pwpos->cx;
711 long cy = pwpos->cy;
712 UINT fuFlags = pwpos->flags;
713
714 HWND hWinAfter;
715 ULONG flags = 0;
716 HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
717
718 if (hWndInsertAfter == HWND_TOPMOST_W)
719// hWinAfter = HWND_TOPMOST;
720 hWinAfter = HWND_TOP;
721 else if (hWndInsertAfter == HWND_NOTOPMOST_W)
722// hWinAfter = HWND_NOTOPMOST;
723 hWinAfter = HWND_TOP;
724 else if (hWndInsertAfter == HWND_TOP_W)
725 hWinAfter = HWND_TOP;
726 else if (hWndInsertAfter == HWND_BOTTOM_W)
727 hWinAfter = HWND_BOTTOM;
728 else
729 hWinAfter = (HWND) hWndInsertAfter;
730
731 if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
732 if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
733 if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
734 if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
735 if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
736 if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
737 //SvL: Must also deactivate the window when hiding it or else focus won't
738 // change. (NOTE: make sure this doesn't cause regressions (01-02-2003)
739 if ( fuFlags & SWP_HIDEWINDOW_W) {
740 flags |= SWP_HIDE|SWP_DEACTIVATE;
741 }
742
743 if ( fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
744
745 if(flags & (SWP_MOVE | SWP_SIZE))
746 {
747 if((flags & SWP_MOVE) == 0)
748 {
749 x = pswpOld->x;
750 y = pswpOld->y;
751
752 y = parentHeight - y - pswpOld->cy;
753 }
754
755 if(flags & SWP_SIZE)
756 {
757 if (cy != pswpOld->cy)
758 flags |= SWP_MOVE;
759 }
760 else
761 {
762 cx = pswpOld->cx;
763 cy = pswpOld->cy;
764 }
765 y = parentHeight - y - cy;
766
767 if ((pswpOld->x == x) && (pswpOld->y == y))
768 flags &= ~SWP_MOVE;
769
770 if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
771 flags &= ~SWP_SIZE;
772 }
773
774 pswp->fl = flags;
775 pswp->cy = cy;
776 pswp->cx = cx;
777 pswp->x = x;
778 pswp->y = y;
779 pswp->hwndInsertBehind = hWinAfter;
780 pswp->hwnd = hWindow;
781 pswp->ulReserved1 = 0;
782 pswp->ulReserved2 = 0;
783
784 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));
785}
786//******************************************************************************
787//******************************************************************************
788void OSLibWinSetClientPos(HWND hwnd, int x, int y, int cx, int cy, int parentHeight)
789{
790 SWP swp;
791 BOOL rc;
792
793 swp.hwnd = hwnd;
794 swp.hwndInsertBehind = 0;
795 swp.x = x;
796 swp.y = parentHeight - y - cy;
797 swp.cx = cx;
798 swp.cy = cy;
799 swp.fl = SWP_MOVE | SWP_SIZE;
800
801 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));
802
803 rc = WinSetMultWindowPos(GetThreadHAB(), &swp, 1);
804 if(rc == FALSE) {
805 dprintf(("OSLibWinSetClientPos: WinSetMultWindowPos %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
806 }
807}
808//******************************************************************************
809//******************************************************************************
810BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
811{
812 BOOL rc;
813
814 WinMapWindowPoints(hwndFrame, HWND_DESKTOP, (PPOINTL)pRect, 2);
815
816 rc = WinCalcFrameRect(hwndFrame, (PRECTL)pRect, fClient);
817 WinMapWindowPoints(HWND_DESKTOP, hwndFrame, (PPOINTL)pRect, 2);
818
819 return rc;
820}
821//******************************************************************************
822//******************************************************************************
823BOOL OSLibGetMinMaxInfo(HWND hwndFrame, MINMAXINFO *pMinMax)
824{
825 TRACKINFO tinfo;
826
827 memset(&tinfo, 0, sizeof(TRACKINFO));
828 WinSendMsg(hwndFrame, WM_QUERYTRACKINFO, (MPARAM)0,(MPARAM)&tinfo);
829
830 pMinMax->ptMinTrackSize.x = tinfo.ptlMinTrackSize.x;
831 pMinMax->ptMinTrackSize.y = tinfo.ptlMinTrackSize.y;
832 pMinMax->ptMaxTrackSize.x = tinfo.ptlMaxTrackSize.x;
833 pMinMax->ptMaxTrackSize.y = tinfo.ptlMaxTrackSize.y;
834 return TRUE;
835}
836//******************************************************************************
837//******************************************************************************
838HWND OSLibWinBeginEnumWindows(HWND hwnd)
839{
840 if(hwnd == OSLIB_HWND_DESKTOP) hwnd = HWND_DESKTOP;
841 else
842 if(hwnd == OSLIB_HWND_OBJECT) hwnd = HWND_OBJECT;
843
844 return WinBeginEnumWindows(hwnd);
845}
846//******************************************************************************
847//******************************************************************************
848HWND OSLibWinGetNextWindow(HWND hwndEnum)
849{
850 return WinGetNextWindow(hwndEnum);
851}
852//******************************************************************************
853//******************************************************************************
854HWND OSLibWinQueryClientWindow(HWND hwndFrame)
855{
856 HWND hwndClient = 0;
857
858 if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME)
859 hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
860
861 return hwndClient;
862}
863//******************************************************************************
864//******************************************************************************
865BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
866{
867 return WinEndEnumWindows(hwndEnum);
868}
869//******************************************************************************
870//******************************************************************************
871BOOL OSLibWinQueryWindowProcess(HWND hwnd, ULONG *pid, ULONG *tid)
872{
873 BOOL ret;
874
875 ret = WinQueryWindowProcess(hwnd, pid, tid);
876 *tid = MAKE_THREADID(*pid, *tid);
877 return ret;
878}
879//******************************************************************************
880//******************************************************************************
881BOOL OSLibWinMapWindowPoints (HWND hwndFrom, HWND hwndTo, OSLIBPOINT *pptl, ULONG num)
882{
883 return WinMapWindowPoints (hwndFrom, hwndTo, (PPOINTL)pptl, num);
884}
885//******************************************************************************
886//******************************************************************************
887HWND OSLibWinQueryObjectWindow(VOID)
888{
889 return WinQueryObjectWindow(HWND_DESKTOP);
890}
891//******************************************************************************
892//******************************************************************************
893HWND OSLibWinObjectWindowFromID(HWND hwndOwner, ULONG ID)
894{
895 HWND hwndNext, hwndFound=0;
896 HENUM henum;
897
898 henum = WinBeginEnumWindows(HWND_OBJECT);
899 while ((hwndNext = WinGetNextWindow(henum)) != 0)
900 {
901 if(WinQueryWindow(hwndNext, QW_OWNER) == hwndOwner &&
902 WinQueryWindowUShort(hwndNext, QWS_ID) == ID)
903 {
904 hwndFound = hwndNext;
905 break;
906 }
907 }
908 WinEndEnumWindows(henum);
909 return hwndFound;
910}
911//******************************************************************************
912//******************************************************************************
913BOOL OSLibSetWindowID(HWND hwnd, ULONG value)
914{
915 dprintf(("OSLibSetWindowID hwnd:%x ID:%x", hwnd, value));
916 return WinSetWindowULong(hwnd, QWS_ID, value);
917}
918//******************************************************************************
919//******************************************************************************
920PVOID OSLibWinSubclassWindow(HWND hwnd,PVOID newWndProc)
921{
922 return WinSubclassWindow(hwnd,(PFNWP)newWndProc);
923}
924//******************************************************************************
925//******************************************************************************
926BOOL OSLibSetWindowRestoreRect(HWND hwnd, PRECT pRect)
927{
928 ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
929
930 WinSetWindowUShort(hwnd, QWS_XRESTORE, (USHORT)pRect->left );
931 WinSetWindowUShort(hwnd, QWS_YRESTORE, (USHORT)(yHeight - pRect->top -
932 (pRect->bottom - pRect->top)));
933 WinSetWindowUShort(hwnd, QWS_CXRESTORE, (USHORT)(pRect->right - pRect->left));
934 WinSetWindowUShort(hwnd, QWS_CYRESTORE, (USHORT)(pRect->bottom - pRect->top));
935 return TRUE;
936}
937//******************************************************************************
938//******************************************************************************
939BOOL OSLibSetWindowMinPos(HWND hwnd, ULONG x, ULONG y)
940{
941 ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
942
943 WinSetWindowUShort(hwnd, QWS_XMINIMIZE, (USHORT)x );
944 WinSetWindowUShort(hwnd, QWS_YMINIMIZE, (USHORT)(yHeight - y -
945 ( 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER)) -
946 WinQuerySysValue( HWND_DESKTOP, SV_CYICON)));
947 return TRUE;
948}
949//******************************************************************************
950//******************************************************************************
951BOOL OSLibWinEnableWindowUpdate(HWND hwndFrame, HWND hwndClient ,BOOL fEnable)
952{
953 WinEnableWindowUpdate(hwndFrame, fEnable);
954 return WinEnableWindowUpdate(hwndClient, fEnable);
955}
956//******************************************************************************
957//******************************************************************************
958ULONG OSLibWinGetLastError()
959{
960 return WinGetLastError(GetThreadHAB()) & 0xFFFF;
961}
962//******************************************************************************
963//******************************************************************************
964void OSLibWinShowTaskList(HWND hwndFrame)
965{
966 SWBLOCK swblk;
967 // the first entry returned is always the window list itself
968 if (WinQuerySwitchList(0, &swblk, sizeof(SWBLOCK)) > 0)
969 WinSetActiveWindow(HWND_DESKTOP, swblk.aswentry[0].swctl.hwnd);
970// WinShowWindow(swblk.aswentry[0].swctl.hwnd, TRUE);
971}
972//******************************************************************************
973//******************************************************************************
974void OSLibSetWindowStyle(HWND hwndFrame, HWND hwndClient, ULONG dwStyle,
975 ULONG dwExStyle)
976{
977 ULONG dwWinStyle;
978 ULONG dwOldWinStyle;
979
980 //client window:
981 dwWinStyle = WinQueryWindowULong(hwndClient, QWL_STYLE);
982 dwOldWinStyle = dwWinStyle;
983
984 if(dwStyle & WS_CLIPCHILDREN_W) {
985 dwWinStyle |= WS_CLIPCHILDREN;
986 }
987 else dwWinStyle &= ~WS_CLIPCHILDREN;
988
989 if(dwWinStyle != dwOldWinStyle) {
990 WinSetWindowULong(hwndClient, QWL_STYLE, dwWinStyle);
991 }
992
993 //Frame window
994 dwWinStyle = WinQueryWindowULong(hwndFrame, QWL_STYLE);
995 dwOldWinStyle = dwWinStyle;
996 if(dwStyle & WS_DISABLED_W) {
997 dwWinStyle |= WS_DISABLED;
998 }
999 else dwWinStyle &= ~WS_DISABLED;
1000
1001 if(dwExStyle & WS_EX_TOPMOST_W) {
1002 dwWinStyle |= WS_TOPMOST;
1003 }
1004 else dwWinStyle &= ~WS_TOPMOST;
1005
1006 if(dwStyle & WS_CLIPSIBLINGS_W) {
1007 dwWinStyle |= WS_CLIPSIBLINGS;
1008 }
1009 else dwWinStyle &= ~WS_CLIPSIBLINGS;
1010
1011 if(dwStyle & WS_MINIMIZE_W) {
1012 dwWinStyle |= WS_MINIMIZED;
1013 }
1014 else dwWinStyle &= ~WS_MINIMIZED;
1015
1016 if(dwStyle & WS_MAXIMIZE_W) {
1017 dwWinStyle |= WS_MAXIMIZED;
1018 }
1019 else dwWinStyle &= ~WS_MAXIMIZED;
1020
1021 if(dwWinStyle != dwOldWinStyle) {
1022 WinSetWindowULong(hwndFrame, QWL_STYLE, dwWinStyle);
1023 }
1024 if(fOS2Look) {
1025 ULONG OSFrameStyle = 0;
1026 if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W)
1027 {
1028 if(WinWindowFromID(hwndFrame, FID_TITLEBAR) == 0) {
1029 OSFrameStyle = FCF_TITLEBAR;
1030 }
1031
1032 if((dwStyle & WS_SYSMENU_W) && !(dwExStyle & WS_EX_TOOLWINDOW_W))
1033 {
1034 if(WinWindowFromID(hwndFrame, FID_SYSMENU) == 0) {
1035 OSFrameStyle |= FCF_SYSMENU;
1036 }
1037 }
1038
1039 if((dwStyle & WS_MINIMIZEBOX_W) || (dwStyle & WS_MAXIMIZEBOX_W))
1040 {
1041 HWND hwndMinMax = WinWindowFromID(hwndFrame, FID_MINMAX);
1042 if(dwStyle & WS_MINIMIZEBOX_W) {
1043 if(hwndMinMax == 0) {
1044 OSFrameStyle |= FCF_MINBUTTON;
1045 }
1046 else {
1047 if(WinIsMenuItemValid(hwndMinMax, SC_MINIMIZE) == FALSE) {
1048 //recreate mimize button
1049//TODO: this method doesn't work (hang during destruction probably)
1050// OSFrameStyle |= FCF_MINBUTTON;
1051 }
1052 }
1053 }
1054 else
1055 if(hwndMinMax) {
1056 WinSendMsg(hwndMinMax, MM_REMOVEITEM, MPFROM2SHORT(SC_MINIMIZE, TRUE), NULL);
1057 }
1058
1059 if(dwStyle & WS_MAXIMIZEBOX_W) {
1060 if(hwndMinMax == 0) {
1061 OSFrameStyle |= FCF_MAXBUTTON;
1062 }
1063 else {
1064 if(WinIsMenuItemValid(hwndMinMax, SC_MAXIMIZE) == FALSE) {
1065 //recreate maximize button
1066//TODO: this method doesn't work (hang during destruction probably)
1067// OSFrameStyle |= FCF_MAXBUTTON;
1068 }
1069 }
1070 }
1071 else
1072 if(hwndMinMax) {
1073 WinSendMsg(hwndMinMax, MM_REMOVEITEM, MPFROM2SHORT(SC_MAXIMIZE, TRUE), NULL);
1074 }
1075 }
1076 else
1077 if(dwStyle & WS_SYSMENU_W) {
1078 if(WinWindowFromID(hwndFrame, FID_MINMAX) == 0) {
1079 OSFrameStyle |= FCF_CLOSEBUTTON;
1080 }
1081 }
1082 }
1083 // no caption, delete all controls if they exist
1084 else
1085 {
1086 if (WinWindowFromID(hwndFrame, FID_TITLEBAR))
1087 WinDestroyWindow(WinWindowFromID(hwndFrame, FID_TITLEBAR));
1088 if (WinWindowFromID(hwndFrame, FID_SYSMENU))
1089 WinDestroyWindow(WinWindowFromID(hwndFrame, FID_SYSMENU));
1090 if (WinWindowFromID(hwndFrame, FID_MINMAX))
1091 WinDestroyWindow(WinWindowFromID(hwndFrame, FID_MINMAX));
1092 }
1093
1094 if(OSFrameStyle) {
1095 FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
1096 char buffer[255];
1097 FCData.flCreateFlags = OSFrameStyle;
1098
1099 GetWindowTextA(OS2ToWin32Handle(hwndClient), buffer, sizeof(buffer));
1100 WinCreateFrameControls(hwndFrame, &FCData, buffer );
1101
1102 if (WinQueryActiveWindow(HWND_DESKTOP) == hwndFrame)
1103 WinSendMsg(WinWindowFromID(hwndFrame, FID_TITLEBAR), TBM_SETHILITE, (MPARAM)1, 0);
1104
1105 }
1106 } // os2look
1107}
1108//******************************************************************************
1109//******************************************************************************
1110BOOL OSLibChangeCloseButtonState(HWND hwndFrame, BOOL State)
1111{
1112 dprintf(("OSLibChangeCloseButtonState %x %d", hwndFrame, State));
1113 return WinEnableMenuItem(WinWindowFromID(hwndFrame, FID_SYSMENU), SC_CLOSE, State);
1114}
1115//******************************************************************************
1116//******************************************************************************
1117DWORD OSLibQueryWindowStyle(HWND hwnd)
1118{
1119 return WinQueryWindowULong(hwnd, QWL_STYLE);
1120}
1121//******************************************************************************
1122//******************************************************************************
1123void OSLibWinSetVisibleRegionNotify(HWND hwnd, BOOL fNotify)
1124{
1125 WinSetVisibleRegionNotify(hwnd, fNotify);
1126}
1127//******************************************************************************
1128//******************************************************************************
1129HWND OSLibWinQueryCapture()
1130{
1131 return WinQueryCapture(HWND_DESKTOP);
1132}
1133//******************************************************************************
1134//******************************************************************************
1135BOOL OSLibWinSetCapture(HWND hwnd)
1136{
1137 return WinSetCapture(HWND_DESKTOP, hwnd);
1138}
1139//******************************************************************************
1140//******************************************************************************
1141BOOL OSLibWinRemoveFromTasklist(HANDLE hTaskList)
1142{
1143 dprintf(("OSLibWinRemoveFromTasklist %x", hTaskList));
1144 return (WinRemoveSwitchEntry(hTaskList)) ? FALSE : TRUE;
1145}
1146//******************************************************************************
1147//******************************************************************************
1148HANDLE OSLibWinAddToTaskList(HWND hwndFrame, char *title, BOOL fVisible)
1149{
1150 SWCNTRL swctrl;
1151 ULONG tid;
1152
1153 swctrl.hwnd = hwndFrame;
1154 swctrl.hwndIcon = 0;
1155 swctrl.hprog = 0;
1156 WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
1157 swctrl.idSession = 0;
1158 swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
1159 swctrl.fbJump = SWL_JUMPABLE;
1160 swctrl.bProgType = PROG_PM;
1161 if(title) {
1162 CharToOemBuffA( title, swctrl.szSwtitle, min(strlen(title)+1,MAXNAMEL+4) );
1163 swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
1164 }
1165 else {
1166 swctrl.szSwtitle[0] = 0;
1167 swctrl.uchVisibility = SWL_INVISIBLE;
1168 }
1169 HANDLE hTaskList = WinAddSwitchEntry(&swctrl);
1170 dprintf(("OSLibWinAddToTaskList %s %x", swctrl.szSwtitle, hTaskList));
1171 return hTaskList;
1172}
1173//******************************************************************************
1174//******************************************************************************
1175BOOL OSLibWinChangeTaskList(HANDLE hTaskList, HWND hwndFrame, char *title, BOOL fVisible)
1176{
1177 SWCNTRL swctrl;
1178 ULONG tid;
1179
1180 swctrl.hwnd = hwndFrame;
1181 swctrl.hwndIcon = 0;
1182 swctrl.hprog = 0;
1183 WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
1184 swctrl.idSession = 0;
1185 swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
1186 swctrl.fbJump = SWL_JUMPABLE;
1187 swctrl.bProgType = PROG_PM;
1188 dprintf(("OSLibWinChangeTaskList %x %s swctrl %x size %d", hTaskList, title, &swctrl, sizeof(swctrl)));
1189 if(title) {
1190 CharToOemBuffA( title, swctrl.szSwtitle, min(strlen(title)+1,MAXNAMEL+4) );
1191 swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
1192 }
1193 else {
1194 swctrl.szSwtitle[0] = 0;
1195 swctrl.uchVisibility = SWL_INVISIBLE;
1196 }
1197 dprintf(("hwnd %x", swctrl.hwnd));
1198 dprintf(("hwndIcon %x", swctrl.hwndIcon));
1199 dprintf(("hprog %x", swctrl.hprog));
1200 dprintf(("idProcess %x", swctrl.idProcess));
1201 dprintf(("idSession %x", swctrl.idSession));
1202 dprintf(("uchVisibility %x", swctrl.uchVisibility));
1203 dprintf(("fbJump %x", swctrl.fbJump));
1204 dprintf(("bProgType %x", swctrl.bProgType));
1205 dprintf(("szSwtitle %s", swctrl.szSwtitle));
1206
1207 return (WinChangeSwitchEntry(hTaskList, &swctrl)) ? FALSE : TRUE;
1208}
1209//******************************************************************************
1210//******************************************************************************
1211BOOL OSLibWinLockWindowUpdate(HWND hwnd)
1212{
1213 return WinLockWindowUpdate(HWND_DESKTOP, (HWND)hwnd);
1214}
1215//******************************************************************************
1216//******************************************************************************
1217ULONG OSLibGetScreenHeight()
1218{
1219 return ScreenHeight;
1220}
1221//******************************************************************************
1222//******************************************************************************
1223ULONG OSLibGetScreenWidth()
1224{
1225 return ScreenWidth;
1226}
1227//******************************************************************************
1228//Returns the maximum position for a window
1229//Should only be used from toplevel windows
1230//******************************************************************************
1231BOOL OSLibWinGetMaxPosition(HWND hwndOS2, RECT *rect)
1232{
1233 SWP swp;
1234
1235 if(!WinGetMaxPosition(hwndOS2, &swp)) {
1236 dprintf(("WARNING: WinGetMaxPosition %x returned FALSE", hwndOS2));
1237 return FALSE;
1238 }
1239 rect->left = swp.x;
1240 rect->right = swp.x + swp.cx;
1241 rect->top = ScreenHeight - (swp.y + swp.cy);
1242 rect->bottom = ScreenHeight - swp.y;
1243 return TRUE;
1244}
1245//******************************************************************************
1246//******************************************************************************
1247BOOL OSLibWinShowPointer(BOOL fShow)
1248{
1249 return WinShowPointer(HWND_DESKTOP, fShow);
1250}
1251//******************************************************************************
1252//******************************************************************************
1253ULONG OSLibWinQuerySysColor(int index)
1254{
1255 return CONVERT_RGB(WinQuerySysColor(HWND_DESKTOP, index, 0));
1256}
1257//******************************************************************************
1258//PF This was added for IBM Wheel Mouse driver - it searches for scrollbars and
1259//only if they exist sends WM_VSCROLL messages to the window
1260//******************************************************************************
1261HWND OSLibWinCreateInvisibleScroller(HWND parentHWND, int direction)
1262{
1263 return WinCreateWindow(parentHWND, WC_SCROLLBAR, NULL, direction,
1264 0, 0, 0, 0, parentHWND, HWND_BOTTOM, 1, NULL, NULL);
1265}
1266//******************************************************************************
1267//******************************************************************************
Note: See TracBrowser for help on using the repository browser.