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

Last change on this file since 5385 was 5385, checked in by sandervl, 24 years ago

cursor handling updates

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