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

Last change on this file since 963 was 963, checked in by dengert, 26 years ago

window focus management fixed

File size: 26.5 KB
Line 
1/* $Id: oslibwin.cpp,v 1.2 1999-09-17 18:49:53 dengert 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, BOOL activate)
186{
187 return WinFocusChange (hwndDeskTop, hwndNewFocus, activate ? FC_NOLOSEACTIVE : 0);
188}
189//******************************************************************************
190//******************************************************************************
191BOOL OSLibWinIsChild (HWND hwnd, HWND hwndOf)
192{
193 return WinIsChild (hwnd, hwndOf);
194}
195//******************************************************************************
196//******************************************************************************
197ULONG OSLibGetWindowHeight(HWND hwnd)
198{
199 RECTL rect;
200
201 return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
202}
203//******************************************************************************
204//******************************************************************************
205LONG OSLibWinQuerySysValue(HWND hwndDeskTop,LONG iSysValue)
206{
207 return WinQuerySysValue(hwndDeskTop,iSysValue);
208}
209//******************************************************************************
210//******************************************************************************
211ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer)
212{
213 return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
214}
215//******************************************************************************
216//******************************************************************************
217BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText)
218{
219 return WinSetDlgItemText(hwndDlg,idItem,pszText);
220}
221//******************************************************************************
222//******************************************************************************
223BOOL OSLibWinQueryPointerPos(HWND hwndDeskTop,PPOINT pptlPoint)
224{
225 return WinQueryPointerPos(hwndDeskTop,(PPOINTL)pptlPoint);
226}
227//******************************************************************************
228//******************************************************************************
229HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
230{
231 return WinQueryWindow(hwnd, lCode);
232}
233//******************************************************************************
234//******************************************************************************
235BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx,
236 LONG cy, ULONG fl)
237{
238 HWND hwndParent = hwndInsertBehind;
239 BOOL rc;
240
241 if(fl & SWP_MOVE) {
242 switch(hwndParent)
243 {
244 case HWNDOS_TOP:
245 case HWNDOS_BOTTOM:
246 hwndParent = HWND_DESKTOP;
247 break;
248 }
249 y = MapOS2ToWin32Y(hwndParent, cy, y);
250 }
251 rc = WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
252 dprintf(("WinSetWindowPos %x %x %d %d %d %d %x returned %d (%x)", hwnd, hwndInsertBehind, x, y, cx, cy, fl, rc, WinGetLastError(GetThreadHAB())));
253 return rc;
254}
255//******************************************************************************
256//******************************************************************************
257BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num)
258{
259 return WinSetMultWindowPos(GetThreadHAB(), pswp, num);
260}
261//******************************************************************************
262//******************************************************************************
263BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
264{
265 BOOL rc;
266
267 if(fl & SWP_SHOW) {
268 rc = WinShowWindow(hwnd, TRUE);
269 }
270 if(rc == 0)
271 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
272 rc = WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, fl);
273 if(rc == 0)
274 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
275 return rc;
276}
277//******************************************************************************
278//******************************************************************************
279BOOL OSLibWinDestroyWindow(HWND hwnd)
280{
281 return WinDestroyWindow(hwnd);
282}
283//******************************************************************************
284//******************************************************************************
285BOOL OSLibWinQueryWindowRect(HWND hwnd, PRECT pRect, int RelativeTo)
286{
287 BOOL rc;
288 RECTLOS2 rectl;
289
290 rc = WinQueryWindowRect(hwnd, (PRECTL)&rectl);
291 if(rc) {
292 if(RelativeTo == RELATIVE_TO_SCREEN) {
293 MapOS2ToWin32Rectl(OSLIB_HWND_DESKTOP, hwnd, &rectl, pRect);
294 }
295 else MapOS2ToWin32Rectl(&rectl, pRect);
296 }
297 else memset(pRect, 0, sizeof(RECT));
298 return rc;
299}
300//******************************************************************************
301//******************************************************************************
302BOOL OSLibWinIsIconic(HWND hwnd)
303{
304 SWP swp;
305 BOOL rc;
306
307 rc = WinQueryWindowPos(hwnd, &swp);
308 if(rc == FALSE) {
309 dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
310 return FALSE;
311 }
312
313 if(swp.fl & SWP_MINIMIZE)
314 return TRUE;
315 else return FALSE;
316}
317//******************************************************************************
318//******************************************************************************
319BOOL OSLibWinSetActiveWindow(HWND hwnd)
320{
321 return WinSetActiveWindow(HWND_DESKTOP, hwnd);
322}
323//******************************************************************************
324//******************************************************************************
325BOOL OSLibWinSetFocus(HWND hwnd)
326{
327 return WinSetFocus(HWND_DESKTOP, hwnd);
328}
329//******************************************************************************
330//******************************************************************************
331BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
332{
333 return WinEnableWindow(hwnd, fEnable);
334}
335//******************************************************************************
336//******************************************************************************
337BOOL OSLibWinIsWindowEnabled(HWND hwnd)
338{
339 return WinIsWindowEnabled(hwnd);
340}
341//******************************************************************************
342//******************************************************************************
343BOOL OSLibWinIsWindowVisible(HWND hwnd)
344{
345 return WinIsWindowVisible(hwnd);
346}
347//******************************************************************************
348//******************************************************************************
349BOOL OSLibWinQueryActiveWindow()
350{
351 return WinQueryActiveWindow(HWND_DESKTOP);
352}
353//******************************************************************************
354//******************************************************************************
355LONG OSLibWinQueryWindowTextLength(HWND hwnd)
356{
357 return WinQueryWindowTextLength(hwnd);
358}
359//******************************************************************************
360//******************************************************************************
361LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz)
362{
363 return WinQueryWindowText(hwnd, length, lpsz);
364}
365//******************************************************************************
366//******************************************************************************
367BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz)
368{
369 return WinSetWindowText(hwnd, lpsz);
370}
371//******************************************************************************
372//******************************************************************************
373BOOL OSLibWinFlashWindow(HWND hwnd, BOOL fFlash)
374{
375 return WinFlashWindow(hwnd, fFlash);
376}
377//******************************************************************************
378//******************************************************************************
379HWND OSLibWinWindowFromPoint(HWND hwnd, PVOID ppoint)
380{
381 return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE);
382}
383//******************************************************************************
384//******************************************************************************
385BOOL OSLibWinMinimizeWindow(HWND hwnd)
386{
387 return WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_MINIMIZE);
388}
389//******************************************************************************
390//******************************************************************************
391BOOL OSLibWinGetBorderSize(HWND hwnd, OSLIBPOINT *pointl)
392{
393 pointl->x = 0;
394 pointl->y = 0;
395 return (BOOL) WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP( &pointl), 0);
396}
397//******************************************************************************
398//******************************************************************************
399BOOL OSLibWinSetIcon(HWND hwnd, HANDLE hIcon)
400{
401 return (BOOL) WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIcon, 0);
402}
403//******************************************************************************
404//******************************************************************************
405BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp)
406{
407 return WinQueryWindowPos(hwnd, pswp);
408}
409//******************************************************************************
410//******************************************************************************
411void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
412{
413 HWND hWindow = pswp->hwnd;
414 HWND hWndInsertAfter = pswp->hwndInsertBehind;
415 long x = pswp->x;
416 long y = pswp->y;
417 long cx = pswp->cx;
418 long cy = pswp->cy;
419 UINT fuFlags = (UINT)pswp->fl;
420 ULONG parentHeight;
421
422 HWND hWinAfter;
423 ULONG flags = 0;
424
425 //***************************************************
426 // Map constant HWNDs (e.g. HWND_DESKTOP, HWND_TOP)
427 //***************************************************
428 HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
429
430 if ( hWndInsertAfter == HWND_TOP )
431 hWinAfter = HWND_TOP_W;
432 else if ( hWndInsertAfter == HWND_BOTTOM )
433 hWinAfter = HWND_BOTTOM_W;
434 else
435 hWinAfter = (HWND) hWndInsertAfter;
436
437 //***********************************
438 // convert PM flags to Windows flags
439 //***********************************
440 if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
441 if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
442 if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
443 if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
444 if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
445 if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
446 if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
447
448 //**************************************************************************
449 // When moving or sizing we'll have to do some calculations for Y inversion.
450 //
451 // If moving - invert Y coord.
452 //
453 // If sizing - if the height is changing, have to move the window to
454 // maintain correct windows position. If we just size then the
455 // TR corner will extend. The Windows behaviour should be to
456 // extend the BR corner.
457 //
458 // If this is a child window then we'll have to move within the client
459 // area of the parent.
460 //
461 // If this is an overlapped or popup window we'll have to move around
462 // within the desktop.
463 //**************************************************************************
464 if ( fuFlags & (SWP_MOVE | SWP_SIZE) )
465 {
466 if (hParent == NULLHANDLE)
467 {
468 ULONG Offset;
469 POINTL pt = {0, 0};
470
471 Offset = OSLibGetWindowHeight(hFrame) - cy;
472 parentHeight = ScreenHeight;
473
474 cx += 2 * x;
475 cy += Offset;
476 WinMapWindowPoints (hFrame, HWND_DESKTOP, &pt, 1);
477 x = pt.x;
478 y = pt.y;
479
480 pswpOld->cx += 2 * pswpOld->x;
481 pswpOld->cy += Offset;
482 pswpOld->x = pt.x;
483 pswpOld->y = pt.y;
484 }
485 else
486 {
487 parentHeight = OSLibGetWindowHeight(hParent);
488 }
489
490 if (fuFlags & SWP_SIZE)
491 {
492 // If height is changing we MUST move to maintain top-left alignment
493 if (cy != pswpOld->cy)
494 {
495 flags &= ~SWP_NOMOVE_W;
496 }
497 }
498 else
499 {
500 cx = pswpOld->cx;
501 cy = pswpOld->cy;
502 }
503
504 //**********************************************************
505 // We'll need both a y and cy for the Y inversion code.
506 // If either wasn't passed in, calculate the current value.
507 //**********************************************************
508 if ((fuFlags & SWP_MOVE) == 0)
509 {
510 x = pswpOld->x;
511 y = pswpOld->y;
512 }
513
514 //********************************************************
515 // Y inversion here... old Y is top left corner of window
516 // relative to top left of parent.
517 //********************************************************
518 y = parentHeight - y - cy;
519 LONG oldY = parentHeight - pswpOld->y - pswpOld->cy;
520
521 // Set the SWP_NOMOVE_W flag if the window has not moved in windows
522 // coordinates.
523 if ( ( pswpOld->x == x ) && ( oldY == y ) )
524 flags |= SWP_NOMOVE_W;
525
526 // Set the SWP_NOSIZE_W flag if the window is not really being sized.
527 if ( ( pswpOld->cx == cx ) && ( pswpOld->cy == cy ) )
528 flags |= SWP_NOSIZE_W;
529 }
530
531 if (hParent == NULLHANDLE)
532 {
533 pswpOld->x = x + pswp->x;
534 pswpOld->y = y + cy - pswp->y - pswp->cy;
535 }
536 else {
537 pswpOld->x = pswp->x;
538 pswpOld->y = parentHeight - pswp->y - cy;
539 }
540 pswpOld->cx = pswp->cx;
541 pswpOld->cy = pswp->cy;
542
543dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
544 x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
545
546 // Fill in the WINDOWPOS structure with the now calculated PM values.
547 pwpos->flags = (UINT)flags;
548 pwpos->cy = (int)cy;
549 pwpos->cx = (int)cx;
550 pwpos->x = (int)x;
551 pwpos->y = (int)y;
552 pwpos->hwndInsertAfter = hWinAfter;
553 pwpos->hwnd = hWindow;
554}
555//******************************************************************************
556//******************************************************************************
557void OSLibMapWINDOWPOStoSWP(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
558{
559 HWND hWnd = pwpos->hwnd;
560 HWND hWndInsertAfter = pwpos->hwndInsertAfter;
561 long x = pwpos->x;
562 long y = pwpos->y;
563 long cx = pwpos->cx;
564 long cy = pwpos->cy;
565 UINT fuFlags = pwpos->flags;
566 ULONG parentHeight;
567
568 HWND hWinAfter;
569 ULONG flags = 0;
570
571 //***************************************************
572 // Map constant HWNDs (e.g. HWND_DESKTOP, HWND_TOP)
573 //***************************************************
574 HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
575
576 if ( hWndInsertAfter == HWND_TOPMOST_W )
577// hWinAfter = HWND_TOPMOST;
578 hWinAfter = HWND_TOP;
579 else if ( hWndInsertAfter == HWND_NOTOPMOST_W )
580// hWinAfter = HWND_NOTOPMOST;
581 hWinAfter = HWND_TOP;
582 else if ( hWndInsertAfter == HWND_TOP_W )
583 hWinAfter = HWND_TOP;
584 else if ( hWndInsertAfter == HWND_BOTTOM_W )
585 hWinAfter = HWND_BOTTOM;
586 else
587 hWinAfter = (HWND) hWndInsertAfter;
588
589 //***********************************
590 // convert Windows flags to PM flags
591 //***********************************
592 if ( ! ( fuFlags & SWP_NOSIZE_W ) ) flags |= SWP_SIZE;
593 if ( ! ( fuFlags & SWP_NOMOVE_W ) ) flags |= SWP_MOVE;
594 if ( ! ( fuFlags & SWP_NOZORDER_W ) ) flags |= SWP_ZORDER;
595 if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
596 if ( ! ( fuFlags & SWP_NOACTIVATE_W ) ) flags |= SWP_ACTIVATE;
597 if ( fuFlags & SWP_SHOWWINDOW_W ) flags |= SWP_SHOW;
598 if ( fuFlags & SWP_HIDEWINDOW_W ) flags |= SWP_HIDE;
599 /* no PM equivalent for SWP_FRAMECHANGED_W, SWP_NOCOPYBITS_W and SWP_NOOWNERZORDER_W */
600
601 //**************************************************************************
602 // When moving or sizing we'll have to do some calculations for Y inversion.
603 //
604 // If moving - invert Y coord.
605 //
606 // If sizing - if the height is changing, have to move the window to
607 // maintain correct windows position. If we just size then the
608 // TR corner will extend. The Windows behaviour should be to
609 // extend the BR corner.
610 //
611 // If this is a child window then we'll have to move within the client
612 // area of the parent.
613 //
614 // If this is an overlapped or popup window we'll have to move around
615 // within the desktop.
616 //**************************************************************************
617 if ( flags & (SWP_MOVE | SWP_SIZE) )
618 {
619 if (hParent == NULLHANDLE)
620 parentHeight = ScreenHeight;
621 else
622 parentHeight = OSLibGetWindowHeight(hParent);
623
624 //**********************************************************
625 // We'll need both a y and cy for the Y inversion code.
626 // If either wasn't passed in, calculate the current value.
627 //**********************************************************
628 if ((flags & SWP_MOVE) == 0)
629 {
630 x = pswpOld->x;
631 y = pswpOld->y;
632
633 // If the window is at (x,0) with a height of zero then this calculation
634 // won't quite work. Instead of calculating the Windows y coord, we set
635 // it at (x,0).
636 if (!(y == 0 && pswpOld->cy == 0))
637 {
638 // convert Y coordinate back to Windows's for later conversion with new size
639 y = parentHeight - y - pswpOld->cy;
640 }
641 }
642
643 if (flags & SWP_SIZE)
644 {
645 // If height is changing we MUST move to maintain top-left alignment
646 if (cy != pswpOld->cy)
647 flags |= SWP_MOVE;
648 }
649 else
650 {
651 cx = pswpOld->cx;
652 cy = pswpOld->cy;
653 }
654
655 //********************************************************
656 // Y inversion here... old Y is top left corner of window
657 // relative to top left of parent.
658 //********************************************************
659 y = parentHeight - y - cy;
660
661 // Clear the SWP_MOVE flag if the window is not really being moved.
662 if ( ( pswpOld->x == x ) && ( pswpOld->y == y ) )
663 flags &= ~SWP_MOVE;
664
665 // Clear the SWP_SIZE flag if the window is not really being sized.
666 if ( ( pswpOld->cx == cx ) && ( pswpOld->cy == cy ) )
667 flags &= ~SWP_SIZE;
668 }
669
670 // Fill in the SWP structure with the now calculated PM values.
671 pswp->fl = flags;
672 pswp->cy = cy;
673 pswp->cx = cx;
674 pswp->x = x;
675 pswp->y = y;
676 pswp->hwndInsertBehind = hWinAfter;
677 pswp->hwnd = hWindow;
678 pswp->ulReserved1 = 0;
679 pswp->ulReserved2 = 0;
680}
681//******************************************************************************
682//******************************************************************************
683HWND OSLibWinBeginEnumWindows(HWND hwnd)
684{
685 if(hwnd == OSLIB_HWND_DESKTOP) hwnd = HWND_DESKTOP;
686 else
687 if(hwnd == OSLIB_HWND_OBJECT) hwnd = HWND_OBJECT;
688
689 return WinBeginEnumWindows(hwnd);
690}
691//******************************************************************************
692//******************************************************************************
693HWND OSLibWinGetNextWindow(HWND hwndEnum)
694{
695 return WinGetNextWindow(hwndEnum);
696}
697//******************************************************************************
698//******************************************************************************
699HWND OSLibWinQueryClientWindow(HWND hwndFrame)
700{
701 HWND hwndClient = 0;
702
703 if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME)
704 hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
705
706 return hwndClient;
707}
708//******************************************************************************
709//******************************************************************************
710BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
711{
712 return WinEndEnumWindows(hwndEnum);
713}
714//******************************************************************************
715//******************************************************************************
716BOOL OSLibWinQueryWindowProcess(HWND hwnd, ULONG *pid, ULONG *tid)
717{
718 return WinQueryWindowProcess(hwnd, pid, tid);
719}
720//******************************************************************************
721//******************************************************************************
Note: See TracBrowser for help on using the repository browser.