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

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

Only subclass frame when they have either a 3d border or *only* the WS_BORDER borderstyle

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