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

Last change on this file since 3830 was 3803, checked in by sandervl, 25 years ago

strncpy call changes

File size: 30.1 KB
Line 
1/* $Id: oslibwin.cpp,v 1.82 2000-07-06 21:17:57 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 <string.h>
19
20#include <misc.h>
21#include "win32type.h"
22#include <winconst.h>
23#include "oslibwin.h"
24#include "oslibutil.h"
25#include "oslibmsg.h"
26#include "oslibgdi.h"
27#include "pmwindow.h"
28
29#define DBG_LOCALLOG DBG_oslibwin
30#include "dbglocal.h"
31
32//******************************************************************************
33//******************************************************************************
34BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw)
35{
36 if(hwndParent == OSLIB_HWND_DESKTOP)
37 {
38 hwndParent = HWND_DESKTOP;
39 }
40 else
41 if(hwndParent == OSLIB_HWND_OBJECT) {
42 hwndParent = HWND_OBJECT;
43 }
44 return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
45}
46//******************************************************************************
47//******************************************************************************
48BOOL OSLibWinSetOwner(HWND hwnd, HWND hwndOwner)
49{
50 return WinSetOwner(hwnd, hwndOwner);
51}
52//******************************************************************************
53//******************************************************************************
54HWND OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle,
55 char *pszName, HWND Owner, ULONG fHWND_BOTTOM,
56 ULONG id, BOOL fTaskList,BOOL fShellPosition,
57 int classStyle)
58{
59 HWND hwndClient;
60 ULONG dwFrameStyle = 0;
61
62 if(pszName && *pszName == 0) {
63 pszName = NULL;
64 }
65 if(hwndParent == OSLIB_HWND_DESKTOP) {
66 hwndParent = HWND_DESKTOP;
67 }
68 if(Owner == OSLIB_HWND_DESKTOP) {
69 Owner = HWND_DESKTOP;
70 }
71 BOOL TopLevel = hwndParent == HWND_DESKTOP;
72
73 if(classStyle & CS_SAVEBITS_W) dwWinStyle |= WS_SAVEBITS;
74 if(classStyle & CS_PARENTDC_W) dwWinStyle |= WS_PARENTCLIP;
75
76 dwWinStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
77
78 if(fTaskList)
79 {
80 dwFrameStyle |= FCF_NOMOVEWITHOWNER;
81 }
82 if (fShellPosition) dwFrameStyle |= FCF_SHELLPOSITION;
83
84 FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
85 FCData.flCreateFlags = dwFrameStyle;
86
87 dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x winstyle %x", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle, dwWinStyle));
88
89#if 0
90 return WinCreateWindow (hwndParent,
91// TopLevel ? WIN32_STDFRAMECLASS : WIN32_STDCLASS,
92 WIN32_STDFRAMECLASS,
93 pszName, dwWinStyle, 0, 0, 0, 0,
94 Owner, HWND_TOP,
95 id, &FCData, NULL);
96#else
97 return WinCreateWindow (hwndParent,
98 WIN32_STDFRAMECLASS,
99 pszName, dwWinStyle, 0, 0, 0, 0,
100 Owner, HWND_TOP,
101 id, NULL, NULL);
102#endif
103}
104//******************************************************************************
105//******************************************************************************
106BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle)
107{
108 *OSWinStyle = 0;
109
110 /* Window styles */
111 if(dwStyle & WS_MINIMIZE_W)
112 *OSWinStyle |= WS_MINIMIZED;
113//Done explicitely in CreateWindowExA
114#if 0
115 if(dwStyle & WS_VISIBLE_W)
116 *OSWinStyle |= WS_VISIBLE;
117#endif
118 if(dwStyle & WS_DISABLED_W)
119 *OSWinStyle |= WS_DISABLED;
120 if(dwStyle & WS_CLIPSIBLINGS_W)
121 *OSWinStyle |= WS_CLIPSIBLINGS;
122 if(dwStyle & WS_CLIPCHILDREN_W)
123 *OSWinStyle |= WS_CLIPCHILDREN;
124 if(dwStyle & WS_MAXIMIZE_W)
125 *OSWinStyle |= WS_MAXIMIZED;
126 if(dwStyle & WS_GROUP_W)
127 *OSWinStyle |= WS_GROUP;
128 if(dwStyle & WS_TABSTOP_W)
129 *OSWinStyle |= WS_TABSTOP;
130
131 return TRUE;
132}
133//******************************************************************************
134//******************************************************************************
135BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
136{
137 if(offset == OSLIB_QWL_USER)
138 offset = QWL_USER;
139
140 return WinSetWindowULong(hwnd, offset, value);
141}
142//******************************************************************************
143//******************************************************************************
144ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
145{
146 if(offset == OSLIB_QWL_USER)
147 offset = QWL_USER;
148
149 return WinQueryWindowULong(hwnd, offset);
150}
151//******************************************************************************
152//******************************************************************************
153BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle)
154{
155 return WinAlarm(hwndDeskTop,flStyle);
156}
157//******************************************************************************
158//******************************************************************************
159APIRET OSLibDosBeep(ULONG freg,ULONG dur)
160{
161 return DosBeep(freg,dur);
162}
163//******************************************************************************
164//******************************************************************************
165HWND OSLibWinQueryFocus(HWND hwndDeskTop)
166{
167 return WinQueryFocus(hwndDeskTop);
168}
169//******************************************************************************
170//******************************************************************************
171HWND OSLibWinWindowFromID(HWND hwndParent,ULONG id)
172{
173 return WinWindowFromID(hwndParent,id);
174}
175//******************************************************************************
176//******************************************************************************
177BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus, BOOL activate)
178{
179 return WinFocusChange (hwndDeskTop, hwndNewFocus, activate ? FC_NOLOSEACTIVE : 0);
180}
181//******************************************************************************
182//******************************************************************************
183BOOL OSLibWinIsChild (HWND hwnd, HWND hwndOf)
184{
185 return WinIsChild (hwnd, hwndOf);
186}
187//******************************************************************************
188//******************************************************************************
189ULONG OSLibGetWindowHeight(HWND hwnd)
190{
191 RECTL rect;
192
193 return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
194}
195//******************************************************************************
196//******************************************************************************
197LONG OSLibWinQuerySysValue(LONG iSysValue)
198{
199 return WinQuerySysValue(HWND_DESKTOP,iSysValue);
200}
201//******************************************************************************
202//******************************************************************************
203ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer)
204{
205 return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
206}
207//******************************************************************************
208//******************************************************************************
209BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText)
210{
211 return WinSetDlgItemText(hwndDlg,idItem,pszText);
212}
213//******************************************************************************
214//******************************************************************************
215BOOL OSLibWinQueryPointerPos(PPOINT pptlPoint)
216{
217 return WinQueryPointerPos(HWND_DESKTOP,(PPOINTL)pptlPoint);
218}
219//******************************************************************************
220//******************************************************************************
221HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
222{
223 return WinQueryWindow(hwnd, lCode);
224}
225//******************************************************************************
226//******************************************************************************
227BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num)
228{
229 return WinSetMultWindowPos(GetThreadHAB(), pswp, num);
230}
231//******************************************************************************
232//******************************************************************************
233BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
234{
235 BOOL rc = 1;
236
237 if(fl & SWP_SHOW) {
238 rc = WinShowWindow(hwnd, TRUE);
239 }
240 if(rc == 0)
241 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
242 rc = WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, fl);
243 if(rc == 0)
244 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
245 return rc;
246}
247//******************************************************************************
248//******************************************************************************
249BOOL OSLibWinDestroyWindow(HWND hwnd)
250{
251 return WinDestroyWindow(hwnd);
252}
253//******************************************************************************
254//******************************************************************************
255#if 0
256BOOL OSLibWinQueryWindowRect(Win32BaseWindow *window, PRECT pRect, int RelativeTo)
257{
258 BOOL rc;
259 RECTLOS2 rectl;
260
261 rc = WinQueryWindowRect(window->getOS2WindowHandle(), (PRECTL)&rectl);
262 if(rc) {
263 if(RelativeTo == RELATIVE_TO_SCREEN) {
264 mapOS2ToWin32RectFrame(window,windowDesktop,&rectl,pRect);
265 }
266 else mapOS2ToWin32RectFrame(window,&rectl,pRect);
267 }
268 else memset(pRect, 0, sizeof(RECT));
269 return rc;
270}
271#endif
272//******************************************************************************
273//******************************************************************************
274BOOL OSLibWinIsIconic(HWND hwnd)
275{
276 SWP swp;
277 BOOL rc;
278
279 rc = WinQueryWindowPos(hwnd, &swp);
280 if(rc == FALSE) {
281 dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
282 return FALSE;
283 }
284
285 if(swp.fl & SWP_MINIMIZE)
286 return TRUE;
287 else return FALSE;
288}
289//******************************************************************************
290//******************************************************************************
291BOOL OSLibWinSetActiveWindow(HWND hwnd)
292{
293 BOOL rc;
294
295 rc = WinSetActiveWindow(HWND_DESKTOP, hwnd);
296 if(rc == FALSE) {
297 dprintf(("WinSetActiveWindow %x failure: %x", hwnd, OSLibWinGetLastError()));
298 }
299 return rc;
300}
301//******************************************************************************
302//******************************************************************************
303BOOL OSLibWinSetFocus(HWND hwnd)
304{
305 return WinSetFocus(HWND_DESKTOP, hwnd);
306}
307//******************************************************************************
308//******************************************************************************
309BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
310{
311 BOOL rc;
312 HWND hwndClient;
313
314 rc = WinEnableWindow(hwnd, fEnable);
315 hwndClient = WinWindowFromID(hwnd, FID_CLIENT);
316 if(hwndClient) {
317 WinEnableWindow(hwndClient, fEnable);
318 }
319 return rc;
320}
321//******************************************************************************
322//******************************************************************************
323BOOL OSLibWinIsWindowEnabled(HWND hwnd)
324{
325 return WinIsWindowEnabled(hwnd);
326}
327//******************************************************************************
328//******************************************************************************
329BOOL OSLibWinIsWindowVisible(HWND hwnd)
330{
331 return WinIsWindowVisible(hwnd);
332}
333//******************************************************************************
334//******************************************************************************
335HWND OSLibWinQueryActiveWindow()
336{
337 return WinQueryActiveWindow(HWND_DESKTOP);
338}
339//******************************************************************************
340//******************************************************************************
341LONG OSLibWinQueryWindowTextLength(HWND hwnd)
342{
343 return WinQueryWindowTextLength(hwnd);
344}
345//******************************************************************************
346//******************************************************************************
347LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz)
348{
349 return WinQueryWindowText(hwnd, length, lpsz);
350}
351//******************************************************************************
352//******************************************************************************
353BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz)
354{
355 return WinSetWindowText(hwnd, lpsz);
356}
357//******************************************************************************
358//******************************************************************************
359BOOL OSLibWinFlashWindow(HWND hwnd, BOOL fFlash)
360{
361 return WinFlashWindow(hwnd, fFlash);
362}
363//******************************************************************************
364//******************************************************************************
365HWND OSLibWinWindowFromPoint(HWND hwnd, PVOID ppoint)
366{
367 return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE);
368}
369//******************************************************************************
370//******************************************************************************
371BOOL OSLibWinMinimizeWindow(HWND hwnd)
372{
373 return WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_MINIMIZE);
374}
375//******************************************************************************
376//******************************************************************************
377BOOL OSLibWinGetBorderSize(HWND hwnd, OSLIBPOINT *pointl)
378{
379 pointl->x = 0;
380 pointl->y = 0;
381 return (BOOL) WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP( &pointl), 0);
382}
383//******************************************************************************
384//******************************************************************************
385BOOL OSLibWinSetIcon(HWND hwnd, HANDLE hIcon)
386{
387 return (BOOL) WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIcon, 0);
388}
389//******************************************************************************
390//******************************************************************************
391BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp)
392{
393 return WinQueryWindowPos(hwnd, pswp);
394}
395//******************************************************************************
396//******************************************************************************
397void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld,
398 int parentHeight, int clientOrgX, int clientOrgY,
399 HWND hwnd)
400{
401 HWND hWindow = pswp->hwnd;
402 HWND hWndInsertAfter = pswp->hwndInsertBehind;
403 long x = pswp->x - clientOrgX;
404 long y = pswp->y + clientOrgY;
405 long cx = pswp->cx;
406 long cy = pswp->cy;
407 UINT fuFlags = (UINT)pswp->fl;
408
409 HWND hWinAfter;
410 ULONG flags = 0;
411
412 HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
413
414 if (hWndInsertAfter == HWND_TOP)
415 hWinAfter = HWND_TOP_W;
416 else if (hWndInsertAfter == HWND_BOTTOM)
417 hWinAfter = HWND_BOTTOM_W;
418 else
419 hWinAfter = (HWND) hWndInsertAfter;
420
421 //***********************************
422 // convert PM flags to Windows flags
423 //***********************************
424 if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
425 if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
426 if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
427 if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
428 if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
429 if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
430 if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
431 if ( fuFlags & SWP_NOADJUST) flags |= SWP_NOSENDCHANGING_W;
432
433 if(fuFlags & (SWP_MOVE | SWP_SIZE))
434 {
435 y = parentHeight - y - pswp->cy;
436
437 if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
438 flags |= SWP_NOMOVE_W;
439
440 if ((pswp->cx == pswpOld->cx) && (pswp->cy == pswpOld->cy))
441 flags |= SWP_NOSIZE_W;
442
443 if (fuFlags & SWP_SIZE)
444 {
445 if (pswp->cy != pswpOld->cy)
446 {
447 flags &= ~SWP_NOMOVE_W;
448 }
449 }
450 }
451
452 pswpOld->x = pswp->x;
453 pswpOld->y = parentHeight-pswp->y-pswp->cy;
454 pswpOld->cx = pswp->cx;
455 pswpOld->cy = pswp->cy;
456
457 dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
458 x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
459
460 pwpos->flags = (UINT)flags;
461 pwpos->cy = cy;
462 pwpos->cx = cx;
463 pwpos->x = x;
464 pwpos->y = y;
465 pwpos->hwndInsertAfter = hWinAfter;
466 pwpos->hwnd = hWindow;
467}
468//******************************************************************************
469//******************************************************************************
470void OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld,
471 int parentHeight, int clientOrgX, int clientOrgY, HWND hFrame)
472{
473 BOOL fCvt = FALSE;
474
475 HWND hWnd = pwpos->hwnd;
476 HWND hWndInsertAfter = pwpos->hwndInsertAfter;
477 long x = pwpos->x + clientOrgX;
478 long y = pwpos->y + clientOrgY;
479 long cx = pwpos->cx;
480 long cy = pwpos->cy;
481 UINT fuFlags = pwpos->flags;
482
483 HWND hWinAfter;
484 ULONG flags = 0;
485 HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
486
487 if (hWndInsertAfter == HWND_TOPMOST_W)
488// hWinAfter = HWND_TOPMOST;
489 hWinAfter = HWND_TOP;
490 else if (hWndInsertAfter == HWND_NOTOPMOST_W)
491// hWinAfter = HWND_NOTOPMOST;
492 hWinAfter = HWND_TOP;
493 else if (hWndInsertAfter == HWND_TOP_W)
494 hWinAfter = HWND_TOP;
495 else if (hWndInsertAfter == HWND_BOTTOM_W)
496 hWinAfter = HWND_BOTTOM;
497 else
498 hWinAfter = (HWND) hWndInsertAfter;
499
500 if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
501 if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
502 if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
503 if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
504 if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
505 if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
506 if ( fuFlags & SWP_HIDEWINDOW_W) flags |= SWP_HIDE;
507 if ( fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
508
509 if(flags & (SWP_MOVE | SWP_SIZE))
510 {
511 if((flags & SWP_MOVE) == 0)
512 {
513 x = pswpOld->x;
514 y = pswpOld->y;
515
516 y = parentHeight - y - pswpOld->cy;
517 }
518
519 if(flags & SWP_SIZE)
520 {
521 if (cy != pswpOld->cy)
522 flags |= SWP_MOVE;
523 }
524 else
525 {
526 cx = pswpOld->cx;
527 cy = pswpOld->cy;
528 }
529 y = parentHeight - y - cy;
530
531 if ((pswpOld->x == x) && (pswpOld->y == y))
532 flags &= ~SWP_MOVE;
533
534 if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
535 flags &= ~SWP_SIZE;
536 }
537
538 pswp->fl = flags;
539 pswp->cy = cy;
540 pswp->cx = cx;
541 pswp->x = x;
542 pswp->y = y;
543 pswp->hwndInsertBehind = hWinAfter;
544 pswp->hwnd = hWindow;
545 pswp->ulReserved1 = 0;
546 pswp->ulReserved2 = 0;
547}
548//******************************************************************************
549//Position in screen coordinates
550//******************************************************************************
551BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
552{
553 BOOL rc;
554
555 WinMapWindowPoints(hwndFrame, HWND_DESKTOP, (PPOINTL)pRect, 2);
556
557 rc = WinCalcFrameRect(hwndFrame, (PRECTL)pRect, fClient);
558 WinMapWindowPoints(HWND_DESKTOP, hwndFrame, (PPOINTL)pRect, 2);
559
560 return rc;
561}
562//******************************************************************************
563//******************************************************************************
564BOOL OSLibGetMinMaxInfo(HWND hwndFrame, MINMAXINFO *pMinMax)
565{
566 TRACKINFO tinfo;
567
568 memset(&tinfo, 0, sizeof(TRACKINFO));
569 WinSendMsg(hwndFrame, WM_QUERYTRACKINFO, (MPARAM)0,(MPARAM)&tinfo);
570
571 pMinMax->ptMinTrackSize.x = tinfo.ptlMinTrackSize.x;
572 pMinMax->ptMinTrackSize.y = tinfo.ptlMinTrackSize.y;
573 pMinMax->ptMaxTrackSize.x = tinfo.ptlMaxTrackSize.x;
574 pMinMax->ptMaxTrackSize.y = tinfo.ptlMaxTrackSize.y;
575 return TRUE;
576}
577//******************************************************************************
578//******************************************************************************
579HWND OSLibWinBeginEnumWindows(HWND hwnd)
580{
581 if(hwnd == OSLIB_HWND_DESKTOP) hwnd = HWND_DESKTOP;
582 else
583 if(hwnd == OSLIB_HWND_OBJECT) hwnd = HWND_OBJECT;
584
585 return WinBeginEnumWindows(hwnd);
586}
587//******************************************************************************
588//******************************************************************************
589HWND OSLibWinGetNextWindow(HWND hwndEnum)
590{
591 return WinGetNextWindow(hwndEnum);
592}
593//******************************************************************************
594//******************************************************************************
595HWND OSLibWinQueryClientWindow(HWND hwndFrame)
596{
597 HWND hwndClient = 0;
598
599 if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME)
600 hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
601
602 return hwndClient;
603}
604//******************************************************************************
605//******************************************************************************
606BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
607{
608 return WinEndEnumWindows(hwndEnum);
609}
610//******************************************************************************
611//******************************************************************************
612BOOL OSLibWinQueryWindowProcess(HWND hwnd, ULONG *pid, ULONG *tid)
613{
614 return WinQueryWindowProcess(hwnd, pid, tid);
615}
616//******************************************************************************
617//******************************************************************************
618BOOL OSLibWinMapWindowPoints (HWND hwndFrom, HWND hwndTo, OSLIBPOINT *pptl, ULONG num)
619{
620 return WinMapWindowPoints (hwndFrom, hwndTo, (PPOINTL)pptl, num);
621}
622//******************************************************************************
623//******************************************************************************
624HWND OSLibWinQueryObjectWindow(VOID)
625{
626 return WinQueryObjectWindow(HWND_DESKTOP);
627}
628//******************************************************************************
629//******************************************************************************
630HWND OSLibWinObjectWindowFromID(HWND hwndOwner, ULONG ID)
631{
632 HWND hwndNext, hwndFound=0;
633 HENUM henum;
634
635 henum = WinBeginEnumWindows(HWND_OBJECT);
636 while ((hwndNext = WinGetNextWindow(henum)) != 0)
637 {
638 if(WinQueryWindow(hwndNext, QW_OWNER) == hwndOwner &&
639 WinQueryWindowUShort(hwndNext, QWS_ID) == ID)
640 {
641 hwndFound = hwndNext;
642 break;
643 }
644 }
645 WinEndEnumWindows(henum);
646 return hwndFound;
647}
648//******************************************************************************
649//******************************************************************************
650BOOL OSLibSetWindowID(HWND hwnd, ULONG value)
651{
652 dprintf(("OSLibSetWindowID hwnd:%x ID:%x", hwnd, value));
653 return WinSetWindowULong(hwnd, QWS_ID, value);
654}
655//******************************************************************************
656//******************************************************************************
657PVOID OSLibWinSubclassWindow(HWND hwnd,PVOID newWndProc)
658{
659 return WinSubclassWindow(hwnd,(PFNWP)newWndProc);
660}
661//******************************************************************************
662//******************************************************************************
663BOOL OSLibSetWindowRestoreRect(HWND hwnd, PRECT pRect)
664{
665 ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
666
667 WinSetWindowUShort(hwnd, QWS_XRESTORE, (USHORT)pRect->left );
668 WinSetWindowUShort(hwnd, QWS_YRESTORE, (USHORT)(yHeight - pRect->top -
669 (pRect->bottom - pRect->top)));
670 WinSetWindowUShort(hwnd, QWS_CXRESTORE, (USHORT)(pRect->right - pRect->left));
671 WinSetWindowUShort(hwnd, QWS_CYRESTORE, (USHORT)(pRect->bottom - pRect->top));
672 return TRUE;
673}
674//******************************************************************************
675//******************************************************************************
676BOOL OSLibSetWindowMinPos(HWND hwnd, ULONG x, ULONG y)
677{
678 ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
679
680 WinSetWindowUShort(hwnd, QWS_XMINIMIZE, (USHORT)x );
681 WinSetWindowUShort(hwnd, QWS_YMINIMIZE, (USHORT)(yHeight - y -
682 ( 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER)) -
683 WinQuerySysValue( HWND_DESKTOP, SV_CYICON)));
684 return TRUE;
685}
686//******************************************************************************
687//******************************************************************************
688BOOL OSLibWinGetKeyboardStateTable(unsigned char *PMKeyState)
689{
690 return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)&PMKeyState, FALSE );
691}
692//******************************************************************************
693//******************************************************************************
694BOOL OSLibWinSetKeyboardStateTable(unsigned char *PMKeyState)
695{
696 return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)&PMKeyState, TRUE );
697}
698//******************************************************************************
699//******************************************************************************
700BOOL OSLibWinEnableWindowUpdate(HWND hwnd,BOOL fEnable)
701{
702 return WinEnableWindowUpdate(hwnd,fEnable);
703}
704//******************************************************************************
705//******************************************************************************
706ULONG OSLibWinGetLastError()
707{
708 return WinGetLastError(GetThreadHAB()) & 0xFFFF;
709}
710//******************************************************************************
711//******************************************************************************
712void OSLibWinShowTaskList(HWND hwndFrame)
713{
714 //CB: don't know if this works on all machines
715 WinSetActiveWindow(HWND_DESKTOP,0x8000000E);
716}
717//******************************************************************************
718//******************************************************************************
719void OSLibSetWindowStyle(HWND hwnd, ULONG dwStyle, ULONG dwExStyle, BOOL saveBits)
720{
721 ULONG dwWinStyle;
722
723 OSLibWinConvertStyle(dwStyle, dwExStyle, &dwWinStyle);
724
725 dwWinStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP | WS_CLIPCHILDREN);
726 if(saveBits) dwWinStyle |= WS_SAVEBITS;
727 if(dwStyle & WS_VISIBLE_W)
728 dwWinStyle |= WS_VISIBLE;
729
730 WinSetWindowULong(hwnd, QWL_STYLE,
731 (WinQueryWindowULong(hwnd, QWL_STYLE) & ~0xffff0000) |
732 dwWinStyle);
733}
734//******************************************************************************
735//******************************************************************************
736DWORD OSLibQueryWindowStyle(HWND hwnd)
737{
738 return WinQueryWindowULong(hwnd, QWL_STYLE);
739}
740//******************************************************************************
741//******************************************************************************
742void OSLibWinSetVisibleRegionNotify(HWND hwnd, BOOL fNotify)
743{
744 WinSetVisibleRegionNotify(hwnd, fNotify);
745}
746//******************************************************************************
747//******************************************************************************
748HWND OSLibWinQueryCapture()
749{
750 return WinQueryCapture(HWND_DESKTOP);
751}
752//******************************************************************************
753//******************************************************************************
754BOOL OSLibWinSetCapture(HWND hwnd)
755{
756 return WinSetCapture(HWND_DESKTOP, hwnd);
757}
758//******************************************************************************
759//******************************************************************************
760BOOL OSLibWinRemoveFromTasklist(HANDLE hTaskList)
761{
762 return (WinRemoveSwitchEntry(hTaskList)) ? FALSE : TRUE;
763}
764//******************************************************************************
765//******************************************************************************
766HANDLE OSLibWinAddToTaskList(HWND hwndFrame, char *title, BOOL fVisible)
767{
768 SWCNTRL swctrl;
769 ULONG tid;
770
771 swctrl.hwnd = hwndFrame;
772 swctrl.hwndIcon = 0;
773 swctrl.hprog = 0;
774 WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
775 swctrl.idSession = 0;
776 swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
777 swctrl.fbJump = SWL_JUMPABLE;
778 swctrl.bProgType = PROG_PM;
779 if(title) {
780 strncpy(swctrl.szSwtitle, title, MAXNAMEL+4);
781 swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
782 }
783 else {
784 swctrl.szSwtitle[0] = 0;
785 swctrl.uchVisibility = SWL_INVISIBLE;
786 }
787 return WinAddSwitchEntry(&swctrl);
788}
789//******************************************************************************
790//******************************************************************************
791BOOL OSLibWinChangeTaskList(HANDLE hTaskList, HWND hwndFrame, char *title, BOOL fVisible)
792{
793 SWCNTRL swctrl;
794 ULONG tid;
795
796 swctrl.hwnd = hwndFrame;
797 swctrl.hwndIcon = 0;
798 swctrl.hprog = 0;
799 WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
800 swctrl.idSession = 0;
801 swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
802 swctrl.fbJump = SWL_JUMPABLE;
803 swctrl.bProgType = PROG_PM;
804 if(title) {
805 strncpy(swctrl.szSwtitle, title, MAXNAMEL+4);
806 swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
807 }
808 else {
809 swctrl.szSwtitle[0] = 0;
810 swctrl.uchVisibility = SWL_INVISIBLE;
811 }
812 return (WinChangeSwitchEntry(hTaskList, &swctrl)) ? FALSE : TRUE;
813}
814//******************************************************************************
815//******************************************************************************
816ULONG OSLibGetScreenHeight()
817{
818 return ScreenHeight;
819}
820//******************************************************************************
821//******************************************************************************
822ULONG OSLibGetScreenWidth()
823{
824 return ScreenWidth;
825}
826//******************************************************************************
827//******************************************************************************
Note: See TracBrowser for help on using the repository browser.