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

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

Fix for DCX_INTERSECTRGN in GetDCEx

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