source: trunk/src/user32/new/oslibwin.cpp@ 724

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

Use shared memory for class & window objects

File size: 25.9 KB
Line 
1/* $Id: oslibwin.cpp,v 1.26 1999-08-28 14:09:29 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) {
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 *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
68 &dwFrameStyle, WIN32_STDCLASS,
69 "", dwClientStyle, 0, 0, &hwndClient);
70 if(*hwndFrame) {
71 if(pszName) {
72 WinSetWindowText(*hwndFrame, pszName);
73 }
74 return hwndClient;
75 }
76 dprintf(("OSLibWinCreateWindow: WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
77 return 0;
78 }
79 hwndClient = WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, 0, 0, 0, 0,
80 Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,
81 NULL);
82 *hwndFrame = hwndClient;
83 return hwndClient;
84}
85//******************************************************************************
86//******************************************************************************
87BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle)
88{
89 *OSWinStyle = 0;
90 *OSFrameStyle = 0;
91
92 /* Window styles */
93 if(dwStyle & WS_MINIMIZE_W)
94 *OSWinStyle |= WS_MINIMIZED;
95//Done explicitely in CreateWindowExA
96#if 0
97 if(dwStyle & WS_VISIBLE_W)
98 *OSWinStyle |= WS_VISIBLE;
99#endif
100 if(dwStyle & WS_DISABLED_W)
101 *OSWinStyle |= WS_DISABLED;
102 if(dwStyle & WS_CLIPSIBLINGS_W)
103 *OSWinStyle |= WS_CLIPSIBLINGS;
104 if(dwStyle & WS_CLIPCHILDREN_W)
105 *OSWinStyle |= WS_CLIPCHILDREN;
106 if(dwStyle & WS_MAXIMIZE_W)
107 *OSWinStyle |= WS_MAXIMIZED;
108 if(dwStyle & WS_GROUP_W)
109 *OSWinStyle |= WS_GROUP;
110 if(dwStyle & WS_TABSTOP_W)
111 *OSWinStyle |= WS_TABSTOP;
112
113 if(dwStyle & WS_CAPTION_W)
114 *OSFrameStyle |= FCF_TITLEBAR;
115 if(dwStyle & WS_DLGFRAME_W)
116 *OSFrameStyle |= FCF_DLGBORDER;
117 else
118 if(dwStyle & WS_BORDER_W)
119 *OSFrameStyle |= FCF_BORDER;
120
121 if(dwStyle & WS_VSCROLL_W)
122 *OSFrameStyle |= FCF_VERTSCROLL;
123 if(dwStyle & WS_HSCROLL_W)
124 *OSFrameStyle |= FCF_HORZSCROLL;
125 if(dwStyle & WS_SYSMENU_W)
126 *OSFrameStyle |= FCF_SYSMENU;
127 if(dwStyle & WS_THICKFRAME_W)
128 *OSFrameStyle |= FCF_SIZEBORDER; //??
129 if(dwStyle & WS_MINIMIZEBOX_W)
130 *OSFrameStyle |= FCF_MINBUTTON;
131 if(dwStyle & WS_MAXIMIZEBOX_W)
132 *OSFrameStyle |= FCF_MAXBUTTON;
133
134 if(dwExStyle & WS_EX_DLGMODALFRAME_W)
135 *OSFrameStyle |= FCF_DLGBORDER;
136
137 return TRUE;
138}
139//******************************************************************************
140//******************************************************************************
141BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
142{
143 return WinSetWindowULong(hwnd, offset, value);
144}
145//******************************************************************************
146//******************************************************************************
147ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
148{
149 return WinQueryWindowULong(hwnd, offset);
150}
151//******************************************************************************
152//******************************************************************************
153BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
154{
155 return WinPostMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
156}
157//******************************************************************************
158//******************************************************************************
159//******************************************************************************
160//******************************************************************************
161BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle)
162{
163 return WinAlarm(hwndDeskTop,flStyle);
164}
165//******************************************************************************
166//******************************************************************************
167APIRET OSLibDosBeep(ULONG freg,ULONG dur)
168{
169 return DosBeep(freg,dur);
170}
171//******************************************************************************
172//******************************************************************************
173HWND OSLibWinQueryFocus(HWND hwndDeskTop)
174{
175 return WinQueryFocus(hwndDeskTop);
176}
177//******************************************************************************
178//******************************************************************************
179HWND OSLibWinWindowFromID(HWND hwndParent,ULONG id)
180{
181 return WinWindowFromID(hwndParent,id);
182}
183//******************************************************************************
184//******************************************************************************
185BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus)
186{
187 return WinSetFocus(hwndDeskTop,hwndNewFocus);
188}
189//******************************************************************************
190//******************************************************************************
191ULONG OSLibGetWindowHeight(HWND hwnd)
192{
193 RECTL rect;
194
195 return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
196}
197//******************************************************************************
198//******************************************************************************
199LONG OSLibWinQuerySysValue(HWND hwndDeskTop,LONG iSysValue)
200{
201 return WinQuerySysValue(hwndDeskTop,iSysValue);
202}
203//******************************************************************************
204//******************************************************************************
205ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer)
206{
207 return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
208}
209//******************************************************************************
210//******************************************************************************
211BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText)
212{
213 return WinSetDlgItemText(hwndDlg,idItem,pszText);
214}
215//******************************************************************************
216//******************************************************************************
217BOOL OSLibWinQueryPointerPos(HWND hwndDeskTop,PPOINT pptlPoint)
218{
219 return WinQueryPointerPos(hwndDeskTop,(PPOINTL)pptlPoint);
220}
221//******************************************************************************
222//******************************************************************************
223HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
224{
225 return WinQueryWindow(hwnd, lCode);
226}
227//******************************************************************************
228//******************************************************************************
229BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx,
230 LONG cy, ULONG fl)
231{
232 HWND hwndParent = hwndInsertBehind;
233 BOOL rc;
234
235 if(fl & SWP_MOVE) {
236 switch(hwndParent)
237 {
238 case HWNDOS_TOP:
239 case HWNDOS_BOTTOM:
240 hwndParent = HWND_DESKTOP;
241 break;
242 }
243 y = MapOS2ToWin32Y(hwndParent, cy, y);
244 }
245 rc = WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
246 dprintf(("WinSetWindowPos %x %x %d %d %d %d %x returned %d (%x)", hwnd, hwndInsertBehind, x, y, cx, cy, fl, rc, WinGetLastError(GetThreadHAB())));
247 return rc;
248}
249//******************************************************************************
250//******************************************************************************
251BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num)
252{
253 return WinSetMultWindowPos(GetThreadHAB(), pswp, num);
254}
255//******************************************************************************
256//******************************************************************************
257BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
258{
259 BOOL rc;
260
261 if(fl & SWP_SHOW) {
262 rc = WinShowWindow(hwnd, TRUE);
263 }
264 if(rc == 0)
265 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
266 rc = WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, fl);
267 if(rc == 0)
268 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
269 return rc;
270}
271//******************************************************************************
272//******************************************************************************
273BOOL OSLibWinDestroyWindow(HWND hwnd)
274{
275 return WinDestroyWindow(hwnd);
276}
277//******************************************************************************
278//******************************************************************************
279BOOL OSLibWinQueryWindowRect(HWND hwnd, PRECT pRect, int RelativeTo)
280{
281 BOOL rc;
282 RECTLOS2 rectl;
283
284 rc = WinQueryWindowRect(hwnd, (PRECTL)&rectl);
285 if(rc) {
286 if(RelativeTo == RELATIVE_TO_SCREEN) {
287 MapOS2ToWin32Rectl(OSLIB_HWND_DESKTOP, hwnd, &rectl, pRect);
288 }
289 else MapOS2ToWin32Rectl(&rectl, pRect);
290 }
291 else memset(pRect, 0, sizeof(RECT));
292 return rc;
293}
294//******************************************************************************
295//******************************************************************************
296BOOL OSLibWinIsIconic(HWND hwnd)
297{
298 SWP swp;
299 BOOL rc;
300
301 rc = WinQueryWindowPos(hwnd, &swp);
302 if(rc == FALSE) {
303 dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
304 return FALSE;
305 }
306
307 if(swp.fl & SWP_MINIMIZE)
308 return TRUE;
309 else return FALSE;
310}
311//******************************************************************************
312//******************************************************************************
313BOOL OSLibWinSetActiveWindow(HWND hwnd)
314{
315 return WinSetActiveWindow(HWND_DESKTOP, hwnd);
316}
317//******************************************************************************
318//******************************************************************************
319BOOL OSLibWinSetFocus(HWND hwnd)
320{
321 return WinSetFocus(HWND_DESKTOP, hwnd);
322}
323//******************************************************************************
324//******************************************************************************
325BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
326{
327 return WinEnableWindow(hwnd, fEnable);
328}
329//******************************************************************************
330//******************************************************************************
331BOOL OSLibWinIsWindowEnabled(HWND hwnd)
332{
333 return WinIsWindowEnabled(hwnd);
334}
335//******************************************************************************
336//******************************************************************************
337BOOL OSLibWinIsWindowVisible(HWND hwnd)
338{
339 return WinIsWindowVisible(hwnd);
340}
341//******************************************************************************
342//******************************************************************************
343BOOL OSLibWinQueryActiveWindow()
344{
345 return WinQueryActiveWindow(HWND_DESKTOP);
346}
347//******************************************************************************
348//******************************************************************************
349LONG OSLibWinQueryWindowTextLength(HWND hwnd)
350{
351 return WinQueryWindowTextLength(hwnd);
352}
353//******************************************************************************
354//******************************************************************************
355LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz)
356{
357 return WinQueryWindowText(hwnd, length, lpsz);
358}
359//******************************************************************************
360//******************************************************************************
361BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz)
362{
363 return WinSetWindowText(hwnd, lpsz);
364}
365//******************************************************************************
366//******************************************************************************
367BOOL OSLibWinFlashWindow(HWND hwnd, BOOL fFlash)
368{
369 return WinFlashWindow(hwnd, fFlash);
370}
371//******************************************************************************
372//******************************************************************************
373HWND OSLibWinWindowFromPoint(HWND hwnd, PVOID ppoint)
374{
375 return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE);
376}
377//******************************************************************************
378//******************************************************************************
379BOOL OSLibWinMinimizeWindow(HWND hwnd)
380{
381 return WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_MINIMIZE);
382}
383//******************************************************************************
384//******************************************************************************
385BOOL OSLibWinGetBorderSize(HWND hwnd, OSLIBPOINT *pointl)
386{
387 pointl->x = 0;
388 pointl->y = 0;
389 return (BOOL) WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP( &pointl), 0);
390}
391//******************************************************************************
392//******************************************************************************
393BOOL OSLibWinSetIcon(HWND hwnd, HANDLE hIcon)
394{
395 return (BOOL) WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIcon, 0);
396}
397//******************************************************************************
398//******************************************************************************
399BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp)
400{
401 return WinQueryWindowPos(hwnd, pswp);
402}
403//******************************************************************************
404//******************************************************************************
405void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
406{
407 HWND hWindow = pswp->hwnd;
408 HWND hWndInsertAfter = pswp->hwndInsertBehind;
409 long x = pswp->x;
410 long y = pswp->y;
411 long cx = pswp->cx;
412 long cy = pswp->cy;
413 UINT fuFlags = (UINT)pswp->fl;
414 ULONG parentHeight;
415
416 HWND hWinAfter;
417 ULONG flags = 0;
418
419 //***************************************************
420 // Map constant HWNDs (e.g. HWND_DESKTOP, HWND_TOP)
421 //***************************************************
422 HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
423
424 if ( hWndInsertAfter == HWND_TOP )
425 hWinAfter = HWND_TOP_W;
426 else if ( hWndInsertAfter == HWND_BOTTOM )
427 hWinAfter = HWND_BOTTOM_W;
428 else
429 hWinAfter = (HWND) hWndInsertAfter;
430
431 //***********************************
432 // convert PM flags to Windows flags
433 //***********************************
434 if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
435 if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
436 if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
437 if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
438 if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
439 if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
440 if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
441
442 //**************************************************************************
443 // When moving or sizing we'll have to do some calculations for Y inversion.
444 //
445 // If moving - invert Y coord.
446 //
447 // If sizing - if the height is changing, have to move the window to
448 // maintain correct windows position. If we just size then the
449 // TR corner will extend. The Windows behaviour should be to
450 // extend the BR corner.
451 //
452 // If this is a child window then we'll have to move within the client
453 // area of the parent.
454 //
455 // If this is an overlapped or popup window we'll have to move around
456 // within the desktop.
457 //**************************************************************************
458 if ( fuFlags & (SWP_MOVE | SWP_SIZE) )
459 {
460 if (hParent == NULLHANDLE)
461 {
462 ULONG Offset;
463 POINTL pt = {0, 0};
464
465 Offset = OSLibGetWindowHeight(hFrame) - cy;
466 parentHeight = ScreenHeight;
467
468 cx += 2 * x;
469 cy += Offset;
470 WinMapWindowPoints (hFrame, HWND_DESKTOP, &pt, 1);
471 x = pt.x;
472 y = pt.y;
473
474 pswpOld->cx += 2 * pswpOld->x;
475 pswpOld->cy += Offset;
476 pswpOld->x = pt.x;
477 pswpOld->y = pt.y;
478 }
479 else
480 {
481 parentHeight = OSLibGetWindowHeight(hParent);
482 }
483
484 if (fuFlags & SWP_SIZE)
485 {
486 // If height is changing we MUST move to maintain top-left alignment
487 if (cy != pswpOld->cy)
488 {
489 flags &= ~SWP_NOMOVE_W;
490 }
491 }
492 else
493 {
494 cx = pswpOld->cx;
495 cy = pswpOld->cy;
496 }
497
498 //**********************************************************
499 // We'll need both a y and cy for the Y inversion code.
500 // If either wasn't passed in, calculate the current value.
501 //**********************************************************
502 if ((fuFlags & SWP_MOVE) == 0)
503 {
504 x = pswpOld->x;
505 y = pswpOld->y;
506 }
507
508 //********************************************************
509 // Y inversion here... old Y is top left corner of window
510 // relative to top left of parent.
511 //********************************************************
512 y = parentHeight - y - cy;
513 LONG oldY = parentHeight - pswpOld->y - pswpOld->cy;
514
515 // Set the SWP_NOMOVE_W flag if the window has not moved in windows
516 // coordinates.
517 if ( ( pswpOld->x == x ) && ( oldY == y ) )
518 flags |= SWP_NOMOVE_W;
519
520 // Set the SWP_NOSIZE_W flag if the window is not really being sized.
521 if ( ( pswpOld->cx == cx ) && ( pswpOld->cy == cy ) )
522 flags |= SWP_NOSIZE_W;
523 }
524
525 if (hParent == NULLHANDLE)
526 {
527 pswpOld->x = x + pswp->x;
528 pswpOld->y = y + cy - pswp->y - pswp->cy;
529 }
530 else {
531 pswpOld->x = pswp->x;
532 pswpOld->y = parentHeight - pswp->y - cy;
533 }
534 pswpOld->cx = pswp->cx;
535 pswpOld->cy = pswp->cy;
536
537dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
538 x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
539
540 // Fill in the WINDOWPOS structure with the now calculated PM values.
541 pwpos->flags = (UINT)flags;
542 pwpos->cy = (int)cy;
543 pwpos->cx = (int)cx;
544 pwpos->x = (int)x;
545 pwpos->y = (int)y;
546 pwpos->hwndInsertAfter = hWinAfter;
547 pwpos->hwnd = hWindow;
548}
549//******************************************************************************
550//******************************************************************************
551void OSLibMapWINDOWPOStoSWP(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
552{
553 HWND hWnd = pwpos->hwnd;
554 HWND hWndInsertAfter = pwpos->hwndInsertAfter;
555 long x = pwpos->x;
556 long y = pwpos->y;
557 long cx = pwpos->cx;
558 long cy = pwpos->cy;
559 UINT fuFlags = pwpos->flags;
560 ULONG parentHeight;
561
562 HWND hWinAfter;
563 ULONG flags = 0;
564
565 //***************************************************
566 // Map constant HWNDs (e.g. HWND_DESKTOP, HWND_TOP)
567 //***************************************************
568 HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
569
570 if ( hWndInsertAfter == HWND_TOPMOST_W )
571// hWinAfter = HWND_TOPMOST;
572 hWinAfter = HWND_TOP;
573 else if ( hWndInsertAfter == HWND_NOTOPMOST_W )
574// hWinAfter = HWND_NOTOPMOST;
575 hWinAfter = HWND_TOP;
576 else if ( hWndInsertAfter == HWND_TOP_W )
577 hWinAfter = HWND_TOP;
578 else if ( hWndInsertAfter == HWND_BOTTOM_W )
579 hWinAfter = HWND_BOTTOM;
580 else
581 hWinAfter = (HWND) hWndInsertAfter;
582
583 //***********************************
584 // convert Windows flags to PM flags
585 //***********************************
586 if ( ! ( fuFlags & SWP_NOSIZE_W ) ) flags |= SWP_SIZE;
587 if ( ! ( fuFlags & SWP_NOMOVE_W ) ) flags |= SWP_MOVE;
588 if ( ! ( fuFlags & SWP_NOZORDER_W ) ) flags |= SWP_ZORDER;
589 if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
590 if ( ! ( fuFlags & SWP_NOACTIVATE_W ) ) flags |= SWP_ACTIVATE;
591 if ( fuFlags & SWP_SHOWWINDOW_W ) flags |= SWP_SHOW;
592 if ( fuFlags & SWP_HIDEWINDOW_W ) flags |= SWP_HIDE;
593 /* no PM equivalent for SWP_FRAMECHANGED_W, SWP_NOCOPYBITS_W and SWP_NOOWNERZORDER_W */
594
595 //**************************************************************************
596 // When moving or sizing we'll have to do some calculations for Y inversion.
597 //
598 // If moving - invert Y coord.
599 //
600 // If sizing - if the height is changing, have to move the window to
601 // maintain correct windows position. If we just size then the
602 // TR corner will extend. The Windows behaviour should be to
603 // extend the BR corner.
604 //
605 // If this is a child window then we'll have to move within the client
606 // area of the parent.
607 //
608 // If this is an overlapped or popup window we'll have to move around
609 // within the desktop.
610 //**************************************************************************
611 if ( flags & (SWP_MOVE | SWP_SIZE) )
612 {
613 if (hParent == NULLHANDLE)
614 parentHeight = ScreenHeight;
615 else
616 parentHeight = OSLibGetWindowHeight(hParent);
617
618 //**********************************************************
619 // We'll need both a y and cy for the Y inversion code.
620 // If either wasn't passed in, calculate the current value.
621 //**********************************************************
622 if ((flags & SWP_MOVE) == 0)
623 {
624 x = pswpOld->x;
625 y = pswpOld->y;
626
627 // If the window is at (x,0) with a height of zero then this calculation
628 // won't quite work. Instead of calculating the Windows y coord, we set
629 // it at (x,0).
630 if (!(y == 0 && pswpOld->cy == 0))
631 {
632 // convert Y coordinate back to Windows's for later conversion with new size
633 y = parentHeight - y - pswpOld->cy;
634 }
635 }
636
637 if (flags & SWP_SIZE)
638 {
639 // If height is changing we MUST move to maintain top-left alignment
640 if (cy != pswpOld->cy)
641 flags |= SWP_MOVE;
642 }
643 else
644 {
645 cx = pswpOld->cx;
646 cy = pswpOld->cy;
647 }
648
649 //********************************************************
650 // Y inversion here... old Y is top left corner of window
651 // relative to top left of parent.
652 //********************************************************
653 y = parentHeight - y - cy;
654
655 // Clear the SWP_MOVE flag if the window is not really being moved.
656 if ( ( pswpOld->x == x ) && ( pswpOld->y == y ) )
657 flags &= ~SWP_MOVE;
658
659 // Clear the SWP_SIZE flag if the window is not really being sized.
660 if ( ( pswpOld->cx == cx ) && ( pswpOld->cy == cy ) )
661 flags &= ~SWP_SIZE;
662 }
663
664 // Fill in the SWP structure with the now calculated PM values.
665 pswp->fl = flags;
666 pswp->cy = cy;
667 pswp->cx = cx;
668 pswp->x = x;
669 pswp->y = y;
670 pswp->hwndInsertBehind = hWinAfter;
671 pswp->hwnd = hWindow;
672 pswp->ulReserved1 = 0;
673 pswp->ulReserved2 = 0;
674}
675//******************************************************************************
676//******************************************************************************
677HWND OSLibWinBeginEnumWindows(HWND hwnd)
678{
679 if(hwnd == OSLIB_HWND_DESKTOP) hwnd = HWND_DESKTOP;
680
681 return WinBeginEnumWindows(hwnd);
682}
683//******************************************************************************
684//******************************************************************************
685HWND OSLibWinGetNextWindow(HWND hwndEnum)
686{
687 return WinGetNextWindow(hwndEnum);
688}
689//******************************************************************************
690//******************************************************************************
691HWND OSLibWinQueryClientWindow(HWND hwndFrame)
692{
693 HWND hwndClient = 0;
694
695 if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME)
696 hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
697
698 return hwndClient;
699}
700//******************************************************************************
701//******************************************************************************
702BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
703{
704 return WinEndEnumWindows(hwndEnum);
705}
706//******************************************************************************
707//******************************************************************************
Note: See TracBrowser for help on using the repository browser.