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