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