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

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

fix last fix (dialogs)

File size: 42.5 KB
Line 
1/* $Id: oslibwin.cpp,v 1.40 1999-10-30 18:08:19 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#define HAS_3DFRAME(exStyle) \
30 ((exStyle & WS_EX_CLIENTEDGE_W) || (exStyle & WS_EX_STATICEDGE_W) || (exStyle & WS_EX_WINDOWEDGE_W))
31
32//******************************************************************************
33//******************************************************************************
34BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw)
35{
36 if(hwndParent == OSLIB_HWND_DESKTOP)
37 {
38 hwndParent = HWND_DESKTOP;
39 }
40
41 return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
42}
43//******************************************************************************
44//******************************************************************************
45BOOL OSLibWinSetOwner(HWND hwnd, HWND hwndOwner)
46{
47 return WinSetOwner(hwnd, hwndOwner);
48}
49//******************************************************************************
50//******************************************************************************
51HWND OSLibWinCreateWindow(HWND hwndParent, ULONG dwWinStyle, ULONG dwFrameStyle,
52 char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame,
53 ULONG id)
54{
55 HWND hwndClient;
56
57 dprintf(("WinCreateWindow %x %x %x %s", hwndParent, dwWinStyle, dwFrameStyle, 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
69 ULONG dwClientStyle;
70
71#if 0
72// if(dwFrameStyle || hwndParent == HWND_DESKTOP) {
73 dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP | WS_CLIPSIBLINGS);
74
75 dwFrameStyle |= FCF_NOBYTEALIGN;
76 if (hwndParent == HWND_DESKTOP && dwFrameStyle & FCF_TITLEBAR)
77 dwFrameStyle |= FCF_TASKLIST | FCF_NOMOVEWITHOWNER;
78
79 dwWinStyle &= ~(WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
80
81 *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
82 &dwFrameStyle, WIN32_STDCLASS,
83 "", dwClientStyle, 0, id, &hwndClient);
84 if(*hwndFrame) {
85 if(pszName) {
86 WinSetWindowText(*hwndFrame, pszName);
87 }
88 return hwndClient;
89 }
90 dprintf(("OSLibWinCreateWindow: (FRAME) WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
91 return 0;
92#else
93 BOOL TopLevel = hwndParent == HWND_DESKTOP;
94 FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
95
96 dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP | WS_CLIPSIBLINGS);
97
98 dwFrameStyle |= FCF_NOBYTEALIGN;
99 if (hwndParent == HWND_DESKTOP && dwFrameStyle & FCF_TITLEBAR) {
100 dwFrameStyle |= FCF_TASKLIST | FCF_NOMOVEWITHOWNER;
101 }
102
103 dwWinStyle &= ~WS_CLIPCHILDREN;
104 FCData.flCreateFlags = dwFrameStyle;
105
106 *hwndFrame = WinCreateWindow (hwndParent,
107 TopLevel ? WC_FRAME : WIN32_INNERFRAME,
108 pszName, dwWinStyle, 0, 0, 50, 30,
109 hwndParent, HWND_TOP, id, &FCData, NULL);
110 if (*hwndFrame) {
111 hwndClient = WinCreateWindow (*hwndFrame, WIN32_STDCLASS,
112 NULL, dwClientStyle, 0, 0, 0, 0,
113 *hwndFrame, HWND_TOP, FID_CLIENT, NULL, NULL);
114 if (hwndClient != NULLHANDLE)
115 WinSendMsg (*hwndFrame, WM_UPDATEFRAME, 0, 0);
116 return hwndClient;
117 }
118 dprintf(("OSLibWinCreateWindow: (FRAME) WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
119 return 0;
120#endif
121
122#if 0
123 }
124 hwndClient = WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, 0, 0, 0, 0,
125 Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,
126 NULL);
127 *hwndFrame = hwndClient;
128 return hwndClient;
129#endif
130}
131//******************************************************************************
132//******************************************************************************
133BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG *dwExStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle, ULONG *borderWidth, ULONG *borderHeight)
134{
135 *OSWinStyle = 0;
136 *OSFrameStyle = 0;
137 *borderWidth = 0;
138 *borderHeight = 0;
139
140 /* Window styles */
141 if(dwStyle & WS_MINIMIZE_W)
142 *OSWinStyle |= WS_MINIMIZED;
143//Done explicitely in CreateWindowExA
144#if 1
145 if(dwStyle & WS_VISIBLE_W)
146 *OSWinStyle |= WS_VISIBLE;
147#endif
148 if(dwStyle & WS_DISABLED_W)
149 *OSWinStyle |= WS_DISABLED;
150 if(dwStyle & WS_CLIPSIBLINGS_W)
151 *OSWinStyle |= WS_CLIPSIBLINGS;
152 if(dwStyle & WS_CLIPCHILDREN_W)
153 *OSWinStyle |= WS_CLIPCHILDREN;
154 if(dwStyle & WS_MAXIMIZE_W)
155 *OSWinStyle |= WS_MAXIMIZED;
156 if(dwStyle & WS_GROUP_W)
157 *OSWinStyle |= WS_GROUP;
158 if(dwStyle & WS_TABSTOP_W)
159 *OSWinStyle |= WS_TABSTOP;
160
161 if(dwStyle & WS_CHILD_W && !((dwStyle & WS_CAPTION_W) == WS_CAPTION_W))
162 {
163//SvL: Causes crash in VPBuddy if enabled -> find bug
164#if 0
165 if (!HAS_3DFRAME(*dwExStyle) && (dwStyle & (WS_DLGFRAME_W | WS_THICKFRAME_W))) *dwExStyle |= WS_EX_DLGMODALFRAME_W;
166#endif
167
168 if (*dwExStyle & WS_EX_CLIENTEDGE_W)
169 {
170 *OSFrameStyle |= FCF_SIZEBORDER;
171 *borderHeight = *borderWidth = 2;
172 }
173 else
174 if (*dwExStyle & WS_EX_DLGMODALFRAME_W)
175 {
176 *OSFrameStyle |= FCF_SIZEBORDER;
177 *borderHeight = *borderWidth = 3;
178 }
179 else
180 if (*dwExStyle & WS_EX_STATICEDGE_W)
181 {
182 *OSFrameStyle |= FCF_SIZEBORDER;
183 *borderHeight = *borderWidth = 2;
184 }
185 else
186 if(dwStyle & WS_BORDER_W)
187 {
188 *OSFrameStyle |= FCF_BORDER;
189 *borderHeight = *borderWidth = 1;
190 }
191 else if (*dwExStyle & WS_EX_WINDOWEDGE_W); //no border
192
193 if(dwStyle & WS_VSCROLL_W)
194 *OSFrameStyle |= FCF_VERTSCROLL;
195 if(dwStyle & WS_HSCROLL_W)
196 *OSFrameStyle |= FCF_HORZSCROLL;
197 }
198 else
199 {
200 if((dwStyle & WS_CAPTION_W) == WS_DLGFRAME_W)
201 *OSFrameStyle |= FCF_DLGBORDER;
202 else
203 {
204 if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W)
205 *OSFrameStyle |= (FCF_TITLEBAR | FCF_BORDER);
206 else
207 if(dwStyle & WS_BORDER_W)
208 *OSFrameStyle |= FCF_BORDER;
209 }
210
211 if(dwStyle & WS_VSCROLL_W)
212 *OSFrameStyle |= FCF_VERTSCROLL;
213 if(dwStyle & WS_HSCROLL_W)
214 *OSFrameStyle |= FCF_HORZSCROLL;
215
216 if(dwStyle & WS_SYSMENU_W)
217 *OSFrameStyle |= FCF_SYSMENU;
218 if(dwStyle & WS_THICKFRAME_W)
219 *OSFrameStyle |= FCF_SIZEBORDER; //??
220 if(dwStyle & WS_MINIMIZEBOX_W)
221 *OSFrameStyle |= FCF_MINBUTTON;
222 if(dwStyle & WS_MAXIMIZEBOX_W)
223 *OSFrameStyle |= FCF_MAXBUTTON;
224
225 if(*dwExStyle & WS_EX_DLGMODALFRAME_W)
226 *OSFrameStyle |= FCF_DLGBORDER;
227 }
228
229 //Clear certain frame bits when the window doesn't have a titlebar
230 if(!(*OSFrameStyle & FCF_TITLEBAR)) {
231 *OSFrameStyle &= ~(FCF_MINBUTTON|FCF_MAXBUTTON|FCF_SYSMENU);
232 }
233 return TRUE;
234}
235//******************************************************************************
236//******************************************************************************
237BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
238{
239 if(offset == OSLIB_QWL_USER)
240 offset = QWL_USER;
241
242 return WinSetWindowULong(hwnd, offset, value);
243}
244//******************************************************************************
245//******************************************************************************
246ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
247{
248 if(offset == OSLIB_QWL_USER)
249 offset = QWL_USER;
250
251 return WinQueryWindowULong(hwnd, offset);
252}
253//******************************************************************************
254//******************************************************************************
255BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
256{
257 return WinPostMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
258}
259//******************************************************************************
260//******************************************************************************
261ULONG OSLibSendMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
262{
263 return (ULONG)WinSendMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
264}
265//******************************************************************************
266//******************************************************************************
267//******************************************************************************
268//******************************************************************************
269BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle)
270{
271 return WinAlarm(hwndDeskTop,flStyle);
272}
273//******************************************************************************
274//******************************************************************************
275APIRET OSLibDosBeep(ULONG freg,ULONG dur)
276{
277 return DosBeep(freg,dur);
278}
279//******************************************************************************
280//******************************************************************************
281HWND OSLibWinQueryFocus(HWND hwndDeskTop)
282{
283 return WinQueryFocus(hwndDeskTop);
284}
285//******************************************************************************
286//******************************************************************************
287HWND OSLibWinWindowFromID(HWND hwndParent,ULONG id)
288{
289 return WinWindowFromID(hwndParent,id);
290}
291//******************************************************************************
292//******************************************************************************
293BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus, BOOL activate)
294{
295 return WinFocusChange (hwndDeskTop, hwndNewFocus, activate ? FC_NOLOSEACTIVE : 0);
296}
297//******************************************************************************
298//******************************************************************************
299BOOL OSLibWinIsChild (HWND hwnd, HWND hwndOf)
300{
301 return WinIsChild (hwnd, hwndOf);
302}
303//******************************************************************************
304//******************************************************************************
305ULONG OSLibGetWindowHeight(HWND hwnd)
306{
307 RECTL rect;
308
309 return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
310}
311//******************************************************************************
312//******************************************************************************
313LONG OSLibWinQuerySysValue(HWND hwndDeskTop,LONG iSysValue)
314{
315 return WinQuerySysValue(hwndDeskTop,iSysValue);
316}
317//******************************************************************************
318//******************************************************************************
319ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer)
320{
321 return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
322}
323//******************************************************************************
324//******************************************************************************
325BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText)
326{
327 return WinSetDlgItemText(hwndDlg,idItem,pszText);
328}
329//******************************************************************************
330//******************************************************************************
331BOOL OSLibWinQueryPointerPos(HWND hwndDeskTop,PPOINT pptlPoint)
332{
333 return WinQueryPointerPos(hwndDeskTop,(PPOINTL)pptlPoint);
334}
335//******************************************************************************
336//******************************************************************************
337HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
338{
339 return WinQueryWindow(hwnd, lCode);
340}
341//******************************************************************************
342//******************************************************************************
343BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx,
344 LONG cy, ULONG fl)
345{
346 HWND hwndParent = hwndInsertBehind;
347 BOOL rc;
348
349 if(fl & SWP_MOVE) {
350 switch(hwndParent)
351 {
352 case HWNDOS_TOP:
353 case HWNDOS_BOTTOM:
354 hwndParent = HWND_DESKTOP;
355 break;
356 }
357 y = MapOS2ToWin32Y(hwndParent, cy, y);
358 }
359 rc = WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
360 dprintf(("WinSetWindowPos %x %x %d %d %d %d %x returned %d (%x)", hwnd, hwndInsertBehind, x, y, cx, cy, fl, rc, WinGetLastError(GetThreadHAB())));
361 return rc;
362}
363//******************************************************************************
364//******************************************************************************
365BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num)
366{
367 return WinSetMultWindowPos(GetThreadHAB(), pswp, num);
368}
369//******************************************************************************
370//******************************************************************************
371BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
372{
373 BOOL rc = 1;
374
375 if(fl & SWP_SHOW) {
376 rc = WinShowWindow(hwnd, TRUE);
377 }
378 if(rc == 0)
379 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
380 rc = WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, fl);
381 if(rc == 0)
382 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
383 return rc;
384}
385//******************************************************************************
386//******************************************************************************
387BOOL OSLibWinDestroyWindow(HWND hwnd)
388{
389 return WinDestroyWindow(hwnd);
390}
391//******************************************************************************
392//******************************************************************************
393BOOL OSLibWinQueryWindowRect(HWND hwnd, PRECT pRect, int RelativeTo)
394{
395 BOOL rc;
396 RECTLOS2 rectl;
397
398 rc = WinQueryWindowRect(hwnd, (PRECTL)&rectl);
399 if(rc) {
400 if(RelativeTo == RELATIVE_TO_SCREEN) {
401 MapOS2ToWin32Rectl(OSLIB_HWND_DESKTOP, hwnd, &rectl, pRect);
402 }
403 else MapOS2ToWin32Rectl(&rectl, pRect);
404 }
405 else memset(pRect, 0, sizeof(RECT));
406 return rc;
407}
408//******************************************************************************
409//******************************************************************************
410BOOL OSLibWinIsIconic(HWND hwnd)
411{
412 SWP swp;
413 BOOL rc;
414
415 rc = WinQueryWindowPos(hwnd, &swp);
416 if(rc == FALSE) {
417 dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
418 return FALSE;
419 }
420
421 if(swp.fl & SWP_MINIMIZE)
422 return TRUE;
423 else return FALSE;
424}
425//******************************************************************************
426//******************************************************************************
427BOOL OSLibWinSetActiveWindow(HWND hwnd)
428{
429 return WinSetActiveWindow(HWND_DESKTOP, hwnd);
430}
431//******************************************************************************
432//******************************************************************************
433BOOL OSLibWinSetFocus(HWND hwnd)
434{
435 return WinSetFocus(HWND_DESKTOP, hwnd);
436}
437//******************************************************************************
438//******************************************************************************
439BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
440{
441 return WinEnableWindow(hwnd, fEnable);
442}
443//******************************************************************************
444//******************************************************************************
445BOOL OSLibWinIsWindowEnabled(HWND hwnd)
446{
447 return WinIsWindowEnabled(hwnd);
448}
449//******************************************************************************
450//******************************************************************************
451BOOL OSLibWinIsWindowVisible(HWND hwnd)
452{
453 return WinIsWindowVisible(hwnd);
454}
455//******************************************************************************
456//******************************************************************************
457BOOL OSLibWinQueryActiveWindow()
458{
459 return WinQueryActiveWindow(HWND_DESKTOP);
460}
461//******************************************************************************
462//******************************************************************************
463LONG OSLibWinQueryWindowTextLength(HWND hwnd)
464{
465 return WinQueryWindowTextLength(hwnd);
466}
467//******************************************************************************
468//******************************************************************************
469LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz)
470{
471 return WinQueryWindowText(hwnd, length, lpsz);
472}
473//******************************************************************************
474//******************************************************************************
475BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz)
476{
477 return WinSetWindowText(hwnd, lpsz);
478}
479//******************************************************************************
480//******************************************************************************
481BOOL OSLibWinFlashWindow(HWND hwnd, BOOL fFlash)
482{
483 return WinFlashWindow(hwnd, fFlash);
484}
485//******************************************************************************
486//******************************************************************************
487HWND OSLibWinWindowFromPoint(HWND hwnd, PVOID ppoint)
488{
489 return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE);
490}
491//******************************************************************************
492//******************************************************************************
493BOOL OSLibWinMinimizeWindow(HWND hwnd)
494{
495 return WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_MINIMIZE);
496}
497//******************************************************************************
498//******************************************************************************
499BOOL OSLibWinGetBorderSize(HWND hwnd, OSLIBPOINT *pointl)
500{
501 pointl->x = 0;
502 pointl->y = 0;
503 return (BOOL) WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP( &pointl), 0);
504}
505//******************************************************************************
506//******************************************************************************
507BOOL OSLibWinSetIcon(HWND hwnd, HANDLE hIcon)
508{
509 return (BOOL) WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIcon, 0);
510}
511//******************************************************************************
512//******************************************************************************
513BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp)
514{
515 return WinQueryWindowPos(hwnd, pswp);
516}
517//******************************************************************************
518//******************************************************************************
519void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
520{
521 HWND hWindow = pswp->hwnd;
522 HWND hWndInsertAfter = pswp->hwndInsertBehind;
523 long x = pswp->x;
524 long y = pswp->y;
525 long cx = pswp->cx;
526 long cy = pswp->cy;
527 UINT fuFlags = (UINT)pswp->fl;
528 ULONG parentHeight;
529
530 HWND hWinAfter;
531 ULONG flags = 0;
532 SWP swpFrame, swpClient;
533 POINTL point;
534
535 HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
536
537 if (hWndInsertAfter == HWND_TOP)
538 hWinAfter = HWND_TOP_W;
539 else if (hWndInsertAfter == HWND_BOTTOM)
540 hWinAfter = HWND_BOTTOM_W;
541 else
542 hWinAfter = (HWND) hWndInsertAfter;
543
544 //***********************************
545 // convert PM flags to Windows flags
546 //***********************************
547 if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
548 if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
549 if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
550 if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
551 if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
552 if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
553 if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
554 if ( fuFlags & SWP_NOADJUST) flags |= SWP_NOSENDCHANGING_W;
555
556 WinQueryWindowPos(hFrame, &swpFrame);
557
558 if(fuFlags & (SWP_MOVE | SWP_SIZE))
559 {
560 point.x = swpFrame.x;
561 point.y = swpFrame.y;
562 if(hParent)
563 {
564 WinMapWindowPoints(hParent, HWND_DESKTOP, &point, 1);
565 }
566 point.y = OSLibQueryScreenHeight() - point.y - swpFrame.cy;
567
568 cy = swpFrame.cy;
569 cx = swpFrame.cx;
570 x = point.x;
571 y = point.y;
572
573 if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
574 flags |= SWP_NOMOVE_W;
575
576 if ((pswp->cx == pswpOld->cx) && (pswp->cy == pswpOld->cy))
577 flags |= SWP_NOSIZE_W;
578
579 if (fuFlags & SWP_SIZE)
580 {
581 if (pswp->cy != pswpOld->cy)
582 {
583 flags &= ~SWP_NOMOVE_W;
584 }
585 }
586 }
587
588 pswpOld->x = pswp->x;
589 pswpOld->y = swpFrame.cy - pswp->y - pswp->cy;
590 pswpOld->cx = pswp->cx;
591 pswpOld->cy = pswp->cy;
592
593 dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
594 x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
595
596 pwpos->flags = (UINT)flags;
597 pwpos->cy = cy;
598 pwpos->cx = cx;
599 pwpos->x = x;
600 pwpos->y = y;
601 pwpos->hwndInsertAfter = hWinAfter;
602 pwpos->hwnd = hWindow;
603}
604//******************************************************************************
605//******************************************************************************
606void OSLibMapSWPtoWINDOWPOSFrame(PSWP pswp, struct tagWINDOWPOS *pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
607{
608 HWND hWindow = pswp->hwnd;
609 HWND hWndInsertAfter = pswp->hwndInsertBehind;
610 long x = pswp->x;
611 long y = pswp->y;
612 long cx = pswp->cx;
613 long cy = pswp->cy;
614 UINT fuFlags = (UINT)pswp->fl;
615 ULONG parentHeight;
616
617 HWND hWinAfter;
618 ULONG flags = 0;
619 SWP swpClient;
620 POINTL point;
621
622 HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
623
624 if (hWndInsertAfter == HWND_TOP)
625 hWinAfter = HWND_TOP_W;
626 else if (hWndInsertAfter == HWND_BOTTOM)
627 hWinAfter = HWND_BOTTOM_W;
628 else
629 hWinAfter = (HWND) hWndInsertAfter;
630
631 //***********************************
632 // convert PM flags to Windows flags
633 //***********************************
634 if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
635 if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
636 if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
637 if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
638 if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
639 if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
640 if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
641 if ( fuFlags & SWP_NOADJUST) flags |= SWP_NOSENDCHANGING_W;
642
643 WinQueryWindowPos(WinWindowFromID(hFrame, FID_CLIENT), &swpClient);
644
645 if(fuFlags & (SWP_MOVE | SWP_SIZE))
646 {
647 point.x = x;
648 point.y = y;
649 if(hParent)
650 {
651 WinMapWindowPoints(hParent, HWND_DESKTOP, &point, 1);
652 }
653 point.y = OSLibQueryScreenHeight() - point.y - cy;
654
655 x = point.x;
656 y = point.y;
657
658 if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
659 flags |= SWP_NOMOVE_W;
660
661 if ((pswp->cx == pswpOld->cx) && (pswp->cy == pswpOld->cy))
662 flags |= SWP_NOSIZE_W;
663
664 if (fuFlags & SWP_SIZE)
665 {
666 if (pswp->cy != pswpOld->cy)
667 {
668 flags &= ~SWP_NOMOVE_W;
669 }
670 }
671 }
672
673 pswpOld->x = swpClient.x;
674 pswpOld->y = pswp->cy - swpClient.y - swpClient.cy;
675 pswpOld->cx = swpClient.cx;
676 pswpOld->cy = swpClient.cy;
677
678 dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
679 x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
680
681 pwpos->flags = (UINT)flags;
682 pwpos->cy = cy;
683 pwpos->cx = cx;
684 pwpos->x = x;
685 pwpos->y = y;
686 pwpos->hwndInsertAfter = hWinAfter;
687 pwpos->hwnd = hWindow;
688}
689//******************************************************************************
690//******************************************************************************
691void OSLibMapWINDOWPOStoSWP(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
692{
693 BOOL fCvt = FALSE;
694
695 HWND hWnd = pwpos->hwnd;
696 HWND hWndInsertAfter = pwpos->hwndInsertAfter;
697 long x = pwpos->x;
698 long y = pwpos->y;
699 long cx = pwpos->cx;
700 long cy = pwpos->cy;
701 UINT fuFlags = pwpos->flags;
702 ULONG parentHeight;
703
704 HWND hWinAfter;
705 ULONG flags = 0;
706 HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
707
708 if (hWndInsertAfter == HWND_TOPMOST_W)
709// hWinAfter = HWND_TOPMOST;
710 hWinAfter = HWND_TOP;
711 else if (hWndInsertAfter == HWND_NOTOPMOST_W)
712// hWinAfter = HWND_NOTOPMOST;
713 hWinAfter = HWND_TOP;
714 else if (hWndInsertAfter == HWND_TOP_W)
715 hWinAfter = HWND_TOP;
716 else if (hWndInsertAfter == HWND_BOTTOM_W)
717 hWinAfter = HWND_BOTTOM;
718 else
719 hWinAfter = (HWND) hWndInsertAfter;
720
721 if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
722 if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
723 if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
724 if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
725 if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
726 if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
727 if ( fuFlags & SWP_HIDEWINDOW_W) flags |= SWP_HIDE;
728 if ( fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
729
730 if (flags & (SWP_MOVE | SWP_SIZE))
731 {
732 if (hParent == NULLHANDLE)
733 parentHeight = ScreenHeight;
734 else
735 parentHeight = OSLibGetWindowHeight(hParent);
736
737 if ((flags & SWP_MOVE) == 0)
738 {
739 x = pswpOld->x;
740 y = pswpOld->y;
741
742 if (!((y == 0) && (pswpOld->cy == 0)))
743 {
744 y = parentHeight - y - pswpOld->cy;
745 }
746 }
747
748 if (flags & SWP_SIZE)
749 {
750 if (cy != pswpOld->cy)
751 flags |= SWP_MOVE;
752 }
753 else
754 {
755 cx = pswpOld->cx;
756 cy = pswpOld->cy;
757 }
758 y = parentHeight - y - cy;
759
760
761 if ((pswpOld->x == x) && (pswpOld->y == y))
762 flags &= ~SWP_MOVE;
763
764 if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
765 flags &= ~SWP_SIZE;
766 }
767
768 pswp->fl = flags;
769 pswp->cy = cy;
770 pswp->cx = cx;
771 pswp->x = x;
772 pswp->y = y;
773 pswp->hwndInsertBehind = hWinAfter;
774 pswp->hwnd = hWindow;
775 pswp->ulReserved1 = 0;
776 pswp->ulReserved2 = 0;
777}
778//******************************************************************************
779//Position in screen coordinates
780//******************************************************************************
781void OSLibMapWINDOWPOStoSWPFrame(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
782{
783 BOOL fCvt = FALSE;
784
785 HWND hWnd = pwpos->hwnd;
786 HWND hWndInsertAfter = pwpos->hwndInsertAfter;
787 long x = pwpos->x;
788 long y = pwpos->y;
789 long cx = pwpos->cx;
790 long cy = pwpos->cy;
791 UINT fuFlags = pwpos->flags;
792 ULONG parentHeight;
793 POINTL point;
794
795 HWND hWinAfter;
796 ULONG flags = 0;
797 HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
798
799 if (hWndInsertAfter == HWND_TOPMOST_W)
800// hWinAfter = HWND_TOPMOST;
801 hWinAfter = HWND_TOP;
802 else if (hWndInsertAfter == HWND_NOTOPMOST_W)
803// hWinAfter = HWND_NOTOPMOST;
804 hWinAfter = HWND_TOP;
805 else if (hWndInsertAfter == HWND_TOP_W)
806 hWinAfter = HWND_TOP;
807 else if (hWndInsertAfter == HWND_BOTTOM_W)
808 hWinAfter = HWND_BOTTOM;
809 else
810 hWinAfter = (HWND) hWndInsertAfter;
811
812 if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
813 if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
814 if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
815 if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
816 if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
817 if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
818 if ( fuFlags & SWP_HIDEWINDOW_W) flags |= SWP_HIDE;
819 if ( fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
820
821 if (flags & (SWP_MOVE | SWP_SIZE))
822 {
823 point.x = x;
824 point.y = y;
825
826 if(hParent) {
827 parentHeight = OSLibGetWindowHeight(hParent);
828
829 point.y = ScreenHeight - point.y - cy;
830 WinMapWindowPoints(HWND_DESKTOP, hParent, &point, 1);
831 point.y = parentHeight - point.y - cy;
832 }
833 else parentHeight = ScreenHeight;
834
835 x = point.x;
836 y = point.y;
837
838 if (flags & SWP_SIZE)
839 {
840 if (cy != pswpOld->cy)
841 flags |= SWP_MOVE;
842 }
843 else
844 {
845 cx = pswpOld->cx;
846 cy = pswpOld->cy;
847 }
848 y = parentHeight - y - cy;
849
850
851 if ((pswpOld->x == x) && (pswpOld->y == y))
852 flags &= ~SWP_MOVE;
853
854 if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
855 flags &= ~SWP_SIZE;
856 }
857
858 pswp->fl = flags;
859 pswp->cy = cy;
860 pswp->cx = cx;
861 pswp->x = x;
862 pswp->y = y;
863 pswp->hwndInsertBehind = hWinAfter;
864 pswp->hwnd = hWindow;
865 pswp->ulReserved1 = 0;
866 pswp->ulReserved2 = 0;
867}
868//******************************************************************************
869//******************************************************************************
870BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
871{
872 BOOL rc;
873
874 WinMapWindowPoints(hwndFrame, HWND_DESKTOP, (PPOINTL)pRect, 2);
875
876 rc = WinCalcFrameRect(hwndFrame, (PRECTL)pRect, fClient);
877 WinMapWindowPoints(HWND_DESKTOP, hwndFrame, (PPOINTL)pRect, 2);
878
879 return rc;
880}
881//******************************************************************************
882//******************************************************************************
883BOOL OSLibGetMinMaxInfo(HWND hwndFrame, MINMAXINFO *pMinMax)
884{
885 TRACKINFO tinfo;
886
887 memset(&tinfo, 0, sizeof(TRACKINFO));
888 WinSendMsg(hwndFrame, WM_QUERYTRACKINFO, (MPARAM)0,(MPARAM)&tinfo);
889
890 pMinMax->ptMinTrackSize.x = tinfo.ptlMinTrackSize.x;
891 pMinMax->ptMinTrackSize.y = tinfo.ptlMinTrackSize.y;
892 pMinMax->ptMaxTrackSize.x = tinfo.ptlMaxTrackSize.x;
893 pMinMax->ptMaxTrackSize.y = tinfo.ptlMaxTrackSize.y;
894 return TRUE;
895}
896//******************************************************************************
897//******************************************************************************
898HWND OSLibWinBeginEnumWindows(HWND hwnd)
899{
900 if(hwnd == OSLIB_HWND_DESKTOP) hwnd = HWND_DESKTOP;
901 else
902 if(hwnd == OSLIB_HWND_OBJECT) hwnd = HWND_OBJECT;
903
904 return WinBeginEnumWindows(hwnd);
905}
906//******************************************************************************
907//******************************************************************************
908HWND OSLibWinGetNextWindow(HWND hwndEnum)
909{
910 return WinGetNextWindow(hwndEnum);
911}
912//******************************************************************************
913//******************************************************************************
914HWND OSLibWinQueryClientWindow(HWND hwndFrame)
915{
916 HWND hwndClient = 0;
917
918 if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME)
919 hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
920
921 return hwndClient;
922}
923//******************************************************************************
924//******************************************************************************
925BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
926{
927 return WinEndEnumWindows(hwndEnum);
928}
929//******************************************************************************
930//******************************************************************************
931BOOL OSLibWinQueryWindowProcess(HWND hwnd, ULONG *pid, ULONG *tid)
932{
933 return WinQueryWindowProcess(hwnd, pid, tid);
934}
935//******************************************************************************
936//******************************************************************************
937BOOL OSLibWinMapWindowPoints (HWND hwndFrom, HWND hwndTo, OSLIBPOINT *pptl, ULONG num)
938{
939 return WinMapWindowPoints (hwndFrom, hwndTo, (PPOINTL)pptl, num);
940}
941//******************************************************************************
942//******************************************************************************
943BOOL OSLibWinEnableScrollBar(HWND hwndParent, int scrollBar, BOOL fEnable)
944{
945 HWND hwndScroll;
946
947 if(scrollBar == OSLIB_VSCROLL) {
948 hwndScroll = WinWindowFromID(hwndParent, FID_VERTSCROLL);
949 }
950 else hwndScroll = WinWindowFromID(hwndParent, FID_HORZSCROLL);
951
952 if(hwndScroll == NULL)
953 return FALSE;
954
955 return WinEnableWindow(hwndScroll, fEnable);
956}
957//******************************************************************************
958//******************************************************************************
959HWND OSLibWinQueryObjectWindow(VOID)
960{
961 return WinQueryObjectWindow(HWND_DESKTOP);
962}
963//******************************************************************************
964//******************************************************************************
965BOOL OSLibWinShowScrollBar(HWND hwndParent, HWND hwndScroll, int scrollBar,
966 BOOL fShow, BOOL fForceChange)
967{
968 HWND hwndObj = WinQueryObjectWindow(HWND_DESKTOP),hwndCurPar = WinQueryWindow(hwndScroll,QW_PARENT);
969
970 if(hwndScroll == NULL) {
971 dprintf(("OSLibWinShowScrollBar: scrollbar %d (parent %x) not found!", scrollBar, hwndParent));
972 return FALSE;
973 }
974
975 if ((fShow && hwndCurPar == hwndObj) || (!fShow && hwndCurPar != hwndObj) || fForceChange)
976 {
977 //CB: bug: winhlp32: hide vert scrollbar on maximize doesn't update the frame
978 WinSetParent(hwndScroll,fShow ? hwndParent:HWND_OBJECT,FALSE);
979 WinSendMsg(hwndParent, WM_UPDATEFRAME,
980 MPFROMLONG( ( scrollBar == OSLIB_VSCROLL ) ? FCF_VERTSCROLL
981 : FCF_HORZSCROLL),
982 MPVOID );
983 }
984 return TRUE;
985}
986//******************************************************************************
987//******************************************************************************
988HWND OSLibWinQueryScrollBarHandle(HWND hwndParent, int scrollBar)
989{
990 if(scrollBar == OSLIB_VSCROLL) {
991 return WinWindowFromID(hwndParent, FID_VERTSCROLL);
992 }
993 else return WinWindowFromID(hwndParent, FID_HORZSCROLL);
994}
995//******************************************************************************
996//******************************************************************************
997ULONG OSLibWinGetScrollPos(HWND hwndParent, HWND hwndScroll)
998{
999 if(hwndScroll == NULL)
1000 return 0;
1001
1002 return (ULONG)WinSendMsg(hwndScroll, SBM_QUERYPOS, 0, 0);
1003}
1004//******************************************************************************
1005//******************************************************************************
1006ULONG OSLibWinSetScrollPos(HWND hwndParent, HWND hwndScroll, int pos, int fRedraw)
1007{
1008 ULONG oldPos;
1009
1010 if(hwndScroll == NULL)
1011 return 0;
1012
1013 oldPos = (ULONG)WinSendMsg(hwndScroll, SBM_QUERYPOS, 0, 0);
1014
1015 if(WinSendMsg(hwndScroll, SBM_SETPOS, MPFROMSHORT(pos), MPFROMLONG(fRedraw)) == FALSE)
1016 return 0;
1017
1018 return oldPos;
1019}
1020//******************************************************************************
1021//******************************************************************************
1022BOOL OSLibWinSetScrollRange(HWND hwndParent, HWND hwndScroll, int minpos,
1023 int maxpos, int fRedraw)
1024{
1025 if(hwndScroll == NULL)
1026 return 0;
1027
1028 return (BOOL)WinSendMsg( hwndScroll, SBM_SETSCROLLBAR,
1029 MPFROMLONG(WinSendMsg(hwndScroll, SBM_QUERYPOS, 0, 0)),
1030 MPFROM2SHORT( minpos ,maxpos ) );
1031}
1032//******************************************************************************
1033//******************************************************************************
1034BOOL OSLibWinSetScrollPageSize(HWND hwndParent, HWND hwndScroll, int pagesize,
1035 int totalsize, int fRedraw)
1036{
1037 if(hwndScroll == NULL)
1038 return 0;
1039
1040 return (BOOL)WinSendMsg( hwndScroll, SBM_SETTHUMBSIZE,
1041 MPFROM2SHORT(pagesize, totalsize),
1042 0);
1043}
1044//******************************************************************************
1045//******************************************************************************
1046void OSLibTranslateScrollCmdAndMsg(ULONG *msg, ULONG *scrollcmd)
1047{
1048 switch(*scrollcmd)
1049 {
1050 case SB_LINEUP:
1051 *scrollcmd = SB_LINEUP_W;
1052 break;
1053 case SB_LINEDOWN:
1054 *scrollcmd = SB_LINEDOWN_W;
1055 break;
1056 case SB_PAGEUP:
1057 *scrollcmd = SB_PAGEUP_W;
1058 break;
1059 case SB_PAGEDOWN:
1060 *scrollcmd = SB_PAGEDOWN_W;
1061 break;
1062 case SB_SLIDERTRACK:
1063 *scrollcmd = SB_THUMBTRACK_W;
1064 break;
1065 case SB_SLIDERPOSITION:
1066 *scrollcmd = SB_THUMBPOSITION_W;
1067 break;
1068 case SB_ENDSCROLL:
1069 *scrollcmd = SB_ENDSCROLL_W;
1070 break;
1071 }
1072 *msg = (*msg == WM_HSCROLL) ? WM_HSCROLL_W : WM_VSCROLL_W;
1073 return;
1074}
1075//******************************************************************************
1076//******************************************************************************
1077void OSLibSetWindowStyle(HWND hwnd, ULONG dwStyle)
1078{
1079 ULONG OSWinStyle, OSFrameStyle, borderWidth, borderHeight,dwExStyle;
1080
1081 OSLibWinConvertStyle(dwStyle, &dwExStyle, &OSWinStyle, &OSFrameStyle, &borderWidth, &borderHeight);
1082
1083 OSWinStyle = OSWinStyle & ~(WS_TABSTOP | WS_GROUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
1084
1085 WinSetWindowULong(hwnd, QWL_STYLE,
1086 (WinQueryWindowULong(hwnd, QWL_STYLE) & ~0xffff0000) |
1087 OSWinStyle);
1088
1089 //CB: bug: it doesn't work with child windows!
1090
1091 if(OSFrameStyle & FCF_TITLEBAR)
1092 {
1093 WinSetParent(OSLibWinObjectWindowFromID(hwnd, FID_TITLEBAR), hwnd, FALSE);
1094 WinSetParent(OSLibWinObjectWindowFromID(hwnd, FID_MENU), hwnd, FALSE);
1095 }
1096 else
1097 {
1098 WinSetParent(WinWindowFromID(hwnd, FID_TITLEBAR), HWND_OBJECT, FALSE);
1099 WinSetParent(WinWindowFromID(hwnd, FID_MENU), HWND_OBJECT, FALSE);
1100 }
1101 if(OSFrameStyle & FCF_SYSMENU)
1102 WinSetParent(OSLibWinObjectWindowFromID(hwnd, FID_SYSMENU), hwnd, FALSE);
1103 else
1104 WinSetParent(WinWindowFromID(hwnd, FID_SYSMENU), HWND_OBJECT, FALSE);
1105
1106 if(OSFrameStyle & FCF_MINBUTTON | OSFrameStyle & FCF_MAXBUTTON)
1107 WinSetParent(OSLibWinObjectWindowFromID(hwnd, FID_MINMAX), hwnd, FALSE);
1108 else
1109 WinSetParent(WinWindowFromID(hwnd, FID_MINMAX), HWND_OBJECT, FALSE);
1110
1111 if(OSFrameStyle & FCF_VERTSCROLL)
1112 WinSetParent(OSLibWinObjectWindowFromID(hwnd, FID_VERTSCROLL), hwnd, FALSE);
1113 else
1114 WinSetParent(WinWindowFromID(hwnd, FID_VERTSCROLL), HWND_OBJECT, FALSE);
1115
1116 if(OSFrameStyle & FCF_HORZSCROLL)
1117 WinSetParent(OSLibWinObjectWindowFromID(hwnd, FID_HORZSCROLL), hwnd, FALSE);
1118 else
1119 WinSetParent(WinWindowFromID(hwnd, FID_HORZSCROLL), HWND_OBJECT, FALSE);
1120
1121#if 0
1122 WNDPARAMS wndparam = {0};
1123 FRAMECDATA framecdata = {0};
1124
1125 framecdata.cb = sizeof(FRAMECDATA);
1126
1127 wndparam.fsStatus = WPM_CTLDATA;
1128 wndparam.cbCtlData = framecdata.cb;
1129 wndparam.pCtlData = (PVOID)&framecdata;
1130 WinSendMsg(hwnd, WM_QUERYWINDOWPARAMS, &wndparam, 0);
1131
1132 wndparam.fsStatus = WPM_CTLDATA;
1133 wndparam.pCtlData = (PVOID)&framecdata;
1134 framecdata.flCreateFlags = OSFrameStyle;
1135 WinSendMsg(hwnd, WM_SETWINDOWPARAMS, &wndparam, 0);
1136#endif
1137
1138 WinSendMsg(hwnd, WM_UPDATEFRAME,
1139 MPFROMLONG(FCF_TITLEBAR | FCF_SYSMENU | FCF_MINMAX |
1140 FCF_MENU | FCF_VERTSCROLL | FCF_HORZSCROLL),
1141 MPVOID);
1142}
1143//******************************************************************************
1144//******************************************************************************
1145HWND OSLibWinObjectWindowFromID(HWND hwndOwner, ULONG ID)
1146{
1147 HWND hwndNext, hwndFound=0;
1148 HENUM henum;
1149
1150 henum = WinBeginEnumWindows(HWND_OBJECT);
1151 while ((hwndNext = WinGetNextWindow(henum)) != 0)
1152 {
1153 if(WinQueryWindow(hwndNext, QW_OWNER) == hwndOwner &&
1154 WinQueryWindowUShort(hwndNext, QWS_ID) == ID)
1155 {
1156 hwndFound = hwndNext;
1157 break;
1158 }
1159 }
1160 WinEndEnumWindows(henum);
1161 return hwndFound;
1162}
1163//******************************************************************************
1164//******************************************************************************
1165BOOL OSLibSetWindowID(HWND hwnd, ULONG value)
1166{
1167 dprintf(("OSLibSetWindowID hwnd:%x ID:%x", hwnd, value));
1168 return WinSetWindowULong(hwnd, QWS_ID, value);
1169}
1170//******************************************************************************
1171//******************************************************************************
1172PVOID OSLibWinSubclassWindow(HWND hwnd,PVOID newWndProc)
1173{
1174 return WinSubclassWindow(hwnd,(PFNWP)newWndProc);
1175}
1176//******************************************************************************
1177//******************************************************************************
1178BOOL OSLibSetWindowRestoreRect(HWND hwnd, PRECT pRect)
1179{
1180 ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
1181
1182 WinSetWindowUShort(hwnd, QWS_XRESTORE, (USHORT)pRect->left );
1183 WinSetWindowUShort(hwnd, QWS_YRESTORE, (USHORT)(yHeight - pRect->top -
1184 (pRect->bottom - pRect->top)));
1185 WinSetWindowUShort(hwnd, QWS_CXRESTORE, (USHORT)(pRect->right - pRect->left));
1186 WinSetWindowUShort(hwnd, QWS_CYRESTORE, (USHORT)(pRect->bottom - pRect->top));
1187 return TRUE;
1188}
1189//******************************************************************************
1190//******************************************************************************
1191BOOL OSLibSetWindowMinPos(HWND hwnd, ULONG x, ULONG y)
1192{
1193 ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
1194
1195 WinSetWindowUShort(hwnd, QWS_XMINIMIZE, (USHORT)x );
1196 WinSetWindowUShort(hwnd, QWS_YMINIMIZE, (USHORT)(yHeight - y -
1197 ( 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER)) -
1198 WinQuerySysValue( HWND_DESKTOP, SV_CYICON)));
1199 return TRUE;
1200}
1201//******************************************************************************
1202//******************************************************************************
Note: See TracBrowser for help on using the repository browser.