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

Last change on this file since 2666 was 2666, checked in by cbratschi, 26 years ago

several fixes -> changelog

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