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

Last change on this file since 1105 was 1105, checked in by sandervl, 26 years ago

EB's window style fixes

File size: 28.6 KB
Line 
1/* $Id: oslibwin.cpp,v 1.11 1999-10-02 04:09:12 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#include <os2.h>
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//******************************************************************************
30//******************************************************************************
31BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw)
32{
33 if(hwndParent == OSLIB_HWND_DESKTOP)
34 {
35 hwndParent = HWND_DESKTOP;
36 }
37
38 return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
39}
40//******************************************************************************
41//******************************************************************************
42HWND OSLibWinCreateWindow(HWND hwndParent, ULONG dwWinStyle, ULONG dwFrameStyle,
43 char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame)
44{
45 HWND hwndClient;
46
47 dprintf(("WinCreateWindow %x %x %x %s", hwndParent, dwWinStyle, dwFrameStyle, pszName));
48
49 if(pszName && *pszName == 0) {
50 pszName = NULL;
51 }
52 if(hwndParent == OSLIB_HWND_DESKTOP) {
53 hwndParent = HWND_DESKTOP;
54 }
55 if(Owner == OSLIB_HWND_DESKTOP) {
56 Owner = HWND_DESKTOP;
57 }
58
59 if(dwFrameStyle || hwndParent == HWND_DESKTOP) {
60 ULONG dwClientStyle;
61
62 dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
63// if(pszName)
64// dwFrameStyle |= FCF_TITLEBAR;
65
66 dwFrameStyle |= FCF_TASKLIST | FCF_NOMOVEWITHOWNER | FCF_NOBYTEALIGN;
67 dwWinStyle &= ~WS_CLIPCHILDREN;
68
69 *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
70 &dwFrameStyle, WIN32_STDCLASS,
71 "", dwClientStyle, 0, 0, &hwndClient);
72 if(*hwndFrame) {
73 if(pszName) {
74 WinSetWindowText(*hwndFrame, pszName);
75 }
76 return hwndClient;
77 }
78 dprintf(("OSLibWinCreateWindow: WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
79 return 0;
80 }
81 hwndClient = WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, 0, 0, 0, 0,
82 Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,
83 NULL);
84 *hwndFrame = hwndClient;
85 return hwndClient;
86}
87//******************************************************************************
88//******************************************************************************
89BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle)
90{
91 *OSWinStyle = 0;
92 *OSFrameStyle = 0;
93
94 /* Window styles */
95 if(dwStyle & WS_MINIMIZE_W)
96 *OSWinStyle |= WS_MINIMIZED;
97//Done explicitely in CreateWindowExA
98#if 1
99 if(dwStyle & WS_VISIBLE_W)
100 *OSWinStyle |= WS_VISIBLE;
101#endif
102 if(dwStyle & WS_DISABLED_W)
103 *OSWinStyle |= WS_DISABLED;
104 if(dwStyle & WS_CLIPSIBLINGS_W)
105 *OSWinStyle |= WS_CLIPSIBLINGS;
106 if(dwStyle & WS_CLIPCHILDREN_W)
107 *OSWinStyle |= WS_CLIPCHILDREN;
108 if(dwStyle & WS_MAXIMIZE_W)
109 *OSWinStyle |= WS_MAXIMIZED;
110 if(dwStyle & WS_GROUP_W)
111 *OSWinStyle |= WS_GROUP;
112 if(dwStyle & WS_TABSTOP_W)
113 *OSWinStyle |= WS_TABSTOP;
114
115 if (dwStyle & WS_CHILD_W)
116 {
117 if (dwExStyle & WS_EX_CLIENTEDGE_W ||
118 dwExStyle & WS_EX_STATICEDGE_W ||
119 dwExStyle & WS_EX_WINDOWEDGE_W)
120 *OSFrameStyle |= FCF_DLGBORDER;
121
122 if(dwStyle & WS_VSCROLL_W)
123 *OSFrameStyle |= FCF_VERTSCROLL;
124 if(dwStyle & WS_HSCROLL_W)
125 *OSFrameStyle |= FCF_HORZSCROLL;
126 } else
127 {
128 if(dwStyle & WS_CAPTION_W)
129 *OSFrameStyle |= FCF_TITLEBAR;
130 if(dwStyle & WS_DLGFRAME_W)
131 *OSFrameStyle |= FCF_DLGBORDER;
132 else
133 if(dwStyle & WS_BORDER_W)
134 *OSFrameStyle |= FCF_BORDER;
135
136 if(dwStyle & WS_VSCROLL_W)
137 *OSFrameStyle |= FCF_VERTSCROLL;
138 if(dwStyle & WS_HSCROLL_W)
139 *OSFrameStyle |= FCF_HORZSCROLL;
140
141 if(dwStyle & WS_SYSMENU_W)
142 *OSFrameStyle |= FCF_SYSMENU;
143 if(dwStyle & WS_THICKFRAME_W)
144 *OSFrameStyle |= FCF_SIZEBORDER; //??
145 if(dwStyle & WS_MINIMIZEBOX_W)
146 *OSFrameStyle |= FCF_MINBUTTON;
147 if(dwStyle & WS_MAXIMIZEBOX_W)
148 *OSFrameStyle |= FCF_MAXBUTTON;
149
150 if(dwExStyle & WS_EX_DLGMODALFRAME_W)
151 *OSFrameStyle |= FCF_DLGBORDER;
152 }
153
154 return TRUE;
155}
156//******************************************************************************
157//******************************************************************************
158BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
159{
160 return WinSetWindowULong(hwnd, offset, value);
161}
162//******************************************************************************
163//******************************************************************************
164ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
165{
166 return WinQueryWindowULong(hwnd, offset);
167}
168//******************************************************************************
169//******************************************************************************
170BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
171{
172 return WinPostMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
173}
174//******************************************************************************
175//******************************************************************************
176ULONG OSLibSendMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
177{
178 return (ULONG)WinSendMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
179}
180//******************************************************************************
181//******************************************************************************
182//******************************************************************************
183//******************************************************************************
184BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle)
185{
186 return WinAlarm(hwndDeskTop,flStyle);
187}
188//******************************************************************************
189//******************************************************************************
190APIRET OSLibDosBeep(ULONG freg,ULONG dur)
191{
192 return DosBeep(freg,dur);
193}
194//******************************************************************************
195//******************************************************************************
196HWND OSLibWinQueryFocus(HWND hwndDeskTop)
197{
198 return WinQueryFocus(hwndDeskTop);
199}
200//******************************************************************************
201//******************************************************************************
202HWND OSLibWinWindowFromID(HWND hwndParent,ULONG id)
203{
204 return WinWindowFromID(hwndParent,id);
205}
206//******************************************************************************
207//******************************************************************************
208BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus, BOOL activate)
209{
210 return WinFocusChange (hwndDeskTop, hwndNewFocus, activate ? FC_NOLOSEACTIVE : 0);
211}
212//******************************************************************************
213//******************************************************************************
214BOOL OSLibWinIsChild (HWND hwnd, HWND hwndOf)
215{
216 return WinIsChild (hwnd, hwndOf);
217}
218//******************************************************************************
219//******************************************************************************
220ULONG OSLibGetWindowHeight(HWND hwnd)
221{
222 RECTL rect;
223
224 return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
225}
226//******************************************************************************
227//******************************************************************************
228LONG OSLibWinQuerySysValue(HWND hwndDeskTop,LONG iSysValue)
229{
230 return WinQuerySysValue(hwndDeskTop,iSysValue);
231}
232//******************************************************************************
233//******************************************************************************
234ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer)
235{
236 return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
237}
238//******************************************************************************
239//******************************************************************************
240BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText)
241{
242 return WinSetDlgItemText(hwndDlg,idItem,pszText);
243}
244//******************************************************************************
245//******************************************************************************
246BOOL OSLibWinQueryPointerPos(HWND hwndDeskTop,PPOINT pptlPoint)
247{
248 return WinQueryPointerPos(hwndDeskTop,(PPOINTL)pptlPoint);
249}
250//******************************************************************************
251//******************************************************************************
252HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
253{
254 return WinQueryWindow(hwnd, lCode);
255}
256//******************************************************************************
257//******************************************************************************
258BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx,
259 LONG cy, ULONG fl)
260{
261 HWND hwndParent = hwndInsertBehind;
262 BOOL rc;
263
264 if(fl & SWP_MOVE) {
265 switch(hwndParent)
266 {
267 case HWNDOS_TOP:
268 case HWNDOS_BOTTOM:
269 hwndParent = HWND_DESKTOP;
270 break;
271 }
272 y = MapOS2ToWin32Y(hwndParent, cy, y);
273 }
274 rc = WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
275 dprintf(("WinSetWindowPos %x %x %d %d %d %d %x returned %d (%x)", hwnd, hwndInsertBehind, x, y, cx, cy, fl, rc, WinGetLastError(GetThreadHAB())));
276 return rc;
277}
278//******************************************************************************
279//******************************************************************************
280BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num)
281{
282 return WinSetMultWindowPos(GetThreadHAB(), pswp, num);
283}
284//******************************************************************************
285//******************************************************************************
286BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
287{
288 BOOL rc;
289
290 if(fl & SWP_SHOW) {
291 rc = WinShowWindow(hwnd, TRUE);
292 }
293 if(rc == 0)
294 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
295 rc = WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, fl);
296 if(rc == 0)
297 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
298 return rc;
299}
300//******************************************************************************
301//******************************************************************************
302BOOL OSLibWinDestroyWindow(HWND hwnd)
303{
304 return WinDestroyWindow(hwnd);
305}
306//******************************************************************************
307//******************************************************************************
308BOOL OSLibWinQueryWindowRect(HWND hwnd, PRECT pRect, int RelativeTo)
309{
310 BOOL rc;
311 RECTLOS2 rectl;
312
313 rc = WinQueryWindowRect(hwnd, (PRECTL)&rectl);
314 if(rc) {
315 if(RelativeTo == RELATIVE_TO_SCREEN) {
316 MapOS2ToWin32Rectl(OSLIB_HWND_DESKTOP, hwnd, &rectl, pRect);
317 }
318 else MapOS2ToWin32Rectl(&rectl, pRect);
319 }
320 else memset(pRect, 0, sizeof(RECT));
321 return rc;
322}
323//******************************************************************************
324//******************************************************************************
325BOOL OSLibWinIsIconic(HWND hwnd)
326{
327 SWP swp;
328 BOOL rc;
329
330 rc = WinQueryWindowPos(hwnd, &swp);
331 if(rc == FALSE) {
332 dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
333 return FALSE;
334 }
335
336 if(swp.fl & SWP_MINIMIZE)
337 return TRUE;
338 else return FALSE;
339}
340//******************************************************************************
341//******************************************************************************
342BOOL OSLibWinSetActiveWindow(HWND hwnd)
343{
344 return WinSetActiveWindow(HWND_DESKTOP, hwnd);
345}
346//******************************************************************************
347//******************************************************************************
348BOOL OSLibWinSetFocus(HWND hwnd)
349{
350 return WinSetFocus(HWND_DESKTOP, hwnd);
351}
352//******************************************************************************
353//******************************************************************************
354BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
355{
356 return WinEnableWindow(hwnd, fEnable);
357}
358//******************************************************************************
359//******************************************************************************
360BOOL OSLibWinIsWindowEnabled(HWND hwnd)
361{
362 return WinIsWindowEnabled(hwnd);
363}
364//******************************************************************************
365//******************************************************************************
366BOOL OSLibWinIsWindowVisible(HWND hwnd)
367{
368 return WinIsWindowVisible(hwnd);
369}
370//******************************************************************************
371//******************************************************************************
372BOOL OSLibWinQueryActiveWindow()
373{
374 return WinQueryActiveWindow(HWND_DESKTOP);
375}
376//******************************************************************************
377//******************************************************************************
378LONG OSLibWinQueryWindowTextLength(HWND hwnd)
379{
380 return WinQueryWindowTextLength(hwnd);
381}
382//******************************************************************************
383//******************************************************************************
384LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz)
385{
386 return WinQueryWindowText(hwnd, length, lpsz);
387}
388//******************************************************************************
389//******************************************************************************
390BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz)
391{
392 return WinSetWindowText(hwnd, lpsz);
393}
394//******************************************************************************
395//******************************************************************************
396BOOL OSLibWinFlashWindow(HWND hwnd, BOOL fFlash)
397{
398 return WinFlashWindow(hwnd, fFlash);
399}
400//******************************************************************************
401//******************************************************************************
402HWND OSLibWinWindowFromPoint(HWND hwnd, PVOID ppoint)
403{
404 return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE);
405}
406//******************************************************************************
407//******************************************************************************
408BOOL OSLibWinMinimizeWindow(HWND hwnd)
409{
410 return WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_MINIMIZE);
411}
412//******************************************************************************
413//******************************************************************************
414BOOL OSLibWinGetBorderSize(HWND hwnd, OSLIBPOINT *pointl)
415{
416 pointl->x = 0;
417 pointl->y = 0;
418 return (BOOL) WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP( &pointl), 0);
419}
420//******************************************************************************
421//******************************************************************************
422BOOL OSLibWinSetIcon(HWND hwnd, HANDLE hIcon)
423{
424 return (BOOL) WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIcon, 0);
425}
426//******************************************************************************
427//******************************************************************************
428BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp)
429{
430 return WinQueryWindowPos(hwnd, pswp);
431}
432//******************************************************************************
433//******************************************************************************
434void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
435{
436 HWND hWindow = pswp->hwnd;
437 HWND hWndInsertAfter = pswp->hwndInsertBehind;
438 long x = pswp->x;
439 long y = pswp->y;
440 long cx = pswp->cx;
441 long cy = pswp->cy;
442 UINT fuFlags = (UINT)pswp->fl;
443 ULONG parentHeight;
444
445 HWND hWinAfter;
446 ULONG flags = 0;
447
448 HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
449
450 if (hWndInsertAfter == HWND_TOP)
451 hWinAfter = HWND_TOP_W;
452 else if (hWndInsertAfter == HWND_BOTTOM)
453 hWinAfter = HWND_BOTTOM_W;
454 else
455 hWinAfter = (HWND) hWndInsertAfter;
456
457 //***********************************
458 // convert PM flags to Windows flags
459 //***********************************
460 if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
461 if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
462 if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
463 if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
464 if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
465 if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
466 if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
467
468 if (fuFlags & (SWP_MOVE | SWP_SIZE))
469 {
470 if (hParent == NULLHANDLE)
471 {
472 ULONG Offset;
473 POINTL pt = {0, 0};
474
475 Offset = OSLibGetWindowHeight(hFrame) - cy;
476 parentHeight = ScreenHeight;
477
478 cx += 2 * x;
479 cy += Offset;
480 WinMapWindowPoints (hFrame, HWND_DESKTOP, &pt, 1);
481 x = pt.x;
482 y = pt.y;
483
484 pswpOld->cx += 2 * pswpOld->x;
485 pswpOld->cy += Offset;
486 pswpOld->x = pt.x;
487 pswpOld->y = pt.y;
488 }
489 else
490 {
491 parentHeight = OSLibGetWindowHeight(hParent);
492 }
493
494 if (fuFlags & SWP_SIZE)
495 {
496 if (cy != pswpOld->cy)
497 {
498 flags &= ~SWP_NOMOVE_W;
499 }
500 }
501 else
502 {
503 cx = pswpOld->cx;
504 cy = pswpOld->cy;
505 }
506
507 if ((fuFlags & SWP_MOVE) == 0)
508 {
509 x = pswpOld->x;
510 y = pswpOld->y;
511 }
512
513 y = parentHeight - y - cy;
514 LONG oldY = parentHeight - pswpOld->y - pswpOld->cy;
515
516 if ((pswpOld->x == x) && (oldY == y))
517 flags |= SWP_NOMOVE_W;
518
519 if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
520 flags |= SWP_NOSIZE_W;
521 }
522
523 if (hParent == NULLHANDLE)
524 {
525 pswpOld->x = x + pswp->x;
526 pswpOld->y = y + cy - pswp->y - pswp->cy;
527 }
528 else {
529 pswpOld->x = pswp->x;
530 pswpOld->y = parentHeight - pswp->y - cy;
531 }
532 pswpOld->cx = pswp->cx;
533 pswpOld->cy = pswp->cy;
534
535dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
536 x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
537
538 pwpos->flags = (UINT)flags;
539 pwpos->cy = (int)cy;
540 pwpos->cx = (int)cx;
541 pwpos->x = (int)x;
542 pwpos->y = (int)y;
543 pwpos->hwndInsertAfter = hWinAfter;
544 pwpos->hwnd = hWindow;
545}
546//******************************************************************************
547//******************************************************************************
548void OSLibMapWINDOWPOStoSWP(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
549{
550 HWND hWnd = pwpos->hwnd;
551 HWND hWndInsertAfter = pwpos->hwndInsertAfter;
552 long x = pwpos->x;
553 long y = pwpos->y;
554 long cx = pwpos->cx;
555 long cy = pwpos->cy;
556 UINT fuFlags = pwpos->flags;
557 ULONG parentHeight;
558
559 HWND hWinAfter;
560 ULONG flags = 0;
561 HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
562
563 if (hWndInsertAfter == HWND_TOPMOST_W)
564// hWinAfter = HWND_TOPMOST;
565 hWinAfter = HWND_TOP;
566 else if (hWndInsertAfter == HWND_NOTOPMOST_W)
567// hWinAfter = HWND_NOTOPMOST;
568 hWinAfter = HWND_TOP;
569 else if (hWndInsertAfter == HWND_TOP_W)
570 hWinAfter = HWND_TOP;
571 else if (hWndInsertAfter == HWND_BOTTOM_W)
572 hWinAfter = HWND_BOTTOM;
573 else
574 hWinAfter = (HWND) hWndInsertAfter;
575
576 if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
577 if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
578 if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
579 if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
580 if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
581 if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
582 if ( fuFlags & SWP_HIDEWINDOW_W) flags |= SWP_HIDE;
583
584 if (flags & (SWP_MOVE | SWP_SIZE))
585 {
586 if (hParent == NULLHANDLE)
587 parentHeight = ScreenHeight;
588 else
589 parentHeight = OSLibGetWindowHeight(hParent);
590
591 if ((flags & SWP_MOVE) == 0)
592 {
593 x = pswpOld->x;
594 y = pswpOld->y;
595
596 if (!((y == 0) && (pswpOld->cy == 0)))
597 {
598 y = parentHeight - y - pswpOld->cy;
599 }
600 }
601
602 if (flags & SWP_SIZE)
603 {
604 if (cy != pswpOld->cy)
605 flags |= SWP_MOVE;
606 }
607 else
608 {
609 cx = pswpOld->cx;
610 cy = pswpOld->cy;
611 }
612
613 y = parentHeight - y - cy;
614
615 if ((pswpOld->x == x) && (pswpOld->y == y))
616 flags &= ~SWP_MOVE;
617
618 if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
619 flags &= ~SWP_SIZE;
620 }
621
622 pswp->fl = flags;
623 pswp->cy = cy;
624 pswp->cx = cx;
625 pswp->x = x;
626 pswp->y = y;
627 pswp->hwndInsertBehind = hWinAfter;
628 pswp->hwnd = hWindow;
629 pswp->ulReserved1 = 0;
630 pswp->ulReserved2 = 0;
631}
632//******************************************************************************
633//******************************************************************************
634HWND OSLibWinBeginEnumWindows(HWND hwnd)
635{
636 if(hwnd == OSLIB_HWND_DESKTOP) hwnd = HWND_DESKTOP;
637 else
638 if(hwnd == OSLIB_HWND_OBJECT) hwnd = HWND_OBJECT;
639
640 return WinBeginEnumWindows(hwnd);
641}
642//******************************************************************************
643//******************************************************************************
644HWND OSLibWinGetNextWindow(HWND hwndEnum)
645{
646 return WinGetNextWindow(hwndEnum);
647}
648//******************************************************************************
649//******************************************************************************
650HWND OSLibWinQueryClientWindow(HWND hwndFrame)
651{
652 HWND hwndClient = 0;
653
654 if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME)
655 hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
656
657 return hwndClient;
658}
659//******************************************************************************
660//******************************************************************************
661BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
662{
663 return WinEndEnumWindows(hwndEnum);
664}
665//******************************************************************************
666//******************************************************************************
667BOOL OSLibWinQueryWindowProcess(HWND hwnd, ULONG *pid, ULONG *tid)
668{
669 return WinQueryWindowProcess(hwnd, pid, tid);
670}
671//******************************************************************************
672//******************************************************************************
673BOOL OSLibWinMapWindowPoints (HWND hwndFrom, HWND hwndTo, OSLIBPOINT *pptl, ULONG num)
674{
675 return WinMapWindowPoints (hwndFrom, hwndTo, (PPOINTL)pptl, num);
676}
677//******************************************************************************
678//******************************************************************************
679BOOL OSLibWinEnableScrollBar(HWND hwndParent, int scrollBar, BOOL fEnable)
680{
681 HWND hwndScroll;
682
683 if(scrollBar == OSLIB_VSCROLL) {
684 hwndScroll = WinWindowFromID(hwndParent, FID_VERTSCROLL);
685 }
686 else hwndScroll = WinWindowFromID(hwndParent, FID_HORZSCROLL);
687
688 if(hwndScroll == NULL)
689 return FALSE;
690
691 return WinEnableWindow(hwndScroll, fEnable);
692}
693//******************************************************************************
694//******************************************************************************
695BOOL OSLibWinShowScrollBar(HWND hwndParent, int scrollBar, BOOL fShow)
696{
697 HWND hwndScroll;
698
699 if(scrollBar == OSLIB_VSCROLL) {
700 hwndScroll = WinWindowFromID(hwndParent, FID_VERTSCROLL);
701 }
702 else hwndScroll = WinWindowFromID(hwndParent, FID_HORZSCROLL);
703
704 if(hwndScroll == NULL)
705 return FALSE;
706
707 if(fShow != WinIsWindowVisible(hwndScroll)) {
708 WinShowWindow(hwndScroll, fShow);
709 }
710 return TRUE;
711}
712//******************************************************************************
713//******************************************************************************
714ULONG OSLibWinGetScrollPos(HWND hwndParent, int scrollBar)
715{
716 HWND hwndScroll;
717
718 if(scrollBar == OSLIB_VSCROLL) {
719 hwndScroll = WinWindowFromID(hwndParent, FID_VERTSCROLL);
720 }
721 else hwndScroll = WinWindowFromID(hwndParent, FID_HORZSCROLL);
722
723 if(hwndScroll == NULL)
724 return 0;
725
726 return (ULONG)WinSendMsg(hwndScroll, SBM_QUERYPOS, 0, 0);
727}
728//******************************************************************************
729//******************************************************************************
730ULONG OSLibWinSetScrollPos(HWND hwndParent, int scrollBar, int pos, int fRedraw)
731{
732 HWND hwndScroll;
733 ULONG oldPos;
734
735 if(scrollBar == OSLIB_VSCROLL) {
736 hwndScroll = WinWindowFromID(hwndParent, FID_VERTSCROLL);
737 }
738 else hwndScroll = WinWindowFromID(hwndParent, FID_HORZSCROLL);
739
740 if(hwndScroll == NULL)
741 return 0;
742
743 oldPos = (ULONG)WinSendMsg(hwndScroll, SBM_QUERYPOS, 0, 0);
744
745 if(WinSendMsg(hwndScroll, SBM_SETPOS, MPFROMSHORT(pos), MPFROMLONG(fRedraw)) == FALSE)
746 return 0;
747
748 return oldPos;
749}
750//******************************************************************************
751//******************************************************************************
752BOOL OSLibWinSetScrollRange(HWND hwndParent, int scrollBar, int minpos,
753 int maxpos, int fRedraw)
754{
755 HWND hwndScroll;
756
757 if(scrollBar == OSLIB_VSCROLL) {
758 hwndScroll = WinWindowFromID(hwndParent, FID_VERTSCROLL);
759 }
760 else hwndScroll = WinWindowFromID(hwndParent, FID_HORZSCROLL);
761
762 if(hwndScroll == NULL)
763 return 0;
764
765 return (BOOL)WinSendMsg( hwndScroll, SBM_SETSCROLLBAR,
766 MPFROMLONG(WinSendMsg(hwndScroll, SBM_QUERYPOS, 0, 0)),
767 MPFROM2SHORT( minpos ,maxpos ) );
768}
769//******************************************************************************
770//******************************************************************************
771BOOL OSLibWinSetScrollPageSize(HWND hwndParent, int scrollBar, int pagesize,
772 int totalsize, int fRedraw)
773{
774 HWND hwndScroll;
775
776 if(scrollBar == OSLIB_VSCROLL) {
777 hwndScroll = WinWindowFromID(hwndParent, FID_VERTSCROLL);
778 }
779 else hwndScroll = WinWindowFromID(hwndParent, FID_HORZSCROLL);
780
781 if(hwndScroll == NULL)
782 return 0;
783
784 return (BOOL)WinSendMsg( hwndScroll, SBM_SETTHUMBSIZE,
785 MPFROM2SHORT(pagesize, totalsize),
786 0);
787}
788//******************************************************************************
789//******************************************************************************
790void OSLibTranslateScrollCmdAndMsg(ULONG *msg, ULONG *scrollcmd)
791{
792 switch(*scrollcmd)
793 {
794 case SB_LINEUP:
795 *scrollcmd = SB_LINEUP_W;
796 break;
797 case SB_LINEDOWN:
798 *scrollcmd = SB_LINEDOWN_W;
799 break;
800 case SB_PAGEUP:
801 *scrollcmd = SB_PAGEUP_W;
802 break;
803 case SB_PAGEDOWN:
804 *scrollcmd = SB_PAGEDOWN_W;
805 break;
806 case SB_SLIDERTRACK:
807 *scrollcmd = SB_THUMBTRACK_W;
808 break;
809 case SB_SLIDERPOSITION:
810 *scrollcmd = SB_THUMBPOSITION_W;
811 break;
812 case SB_ENDSCROLL:
813 *scrollcmd = SB_ENDSCROLL_W;
814 break;
815 }
816 *msg = (*msg == WM_HSCROLL) ? WM_HSCROLL_W : WM_VSCROLL_W;
817 return;
818}
819//******************************************************************************
820//******************************************************************************
821void OSLibSetWindowStyle(HWND hwnd, ULONG dwStyle)
822{
823 ULONG OSWinStyle, OSFrameStyle;
824
825 OSLibWinConvertStyle(dwStyle, 0, &OSWinStyle, &OSFrameStyle);
826
827 WinSetWindowULong(hwnd, QWL_STYLE,
828 (WinQueryWindowULong(hwnd, QWL_STYLE) & ~0xffff0000) |
829 OSWinStyle);
830}
831//******************************************************************************
832//******************************************************************************
Note: See TracBrowser for help on using the repository browser.