source: trunk/src/user32/new/oslibwin.cpp@ 323

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

* empty log message *

File size: 10.7 KB
Line 
1/* $Id: oslibwin.cpp,v 1.8 1999-07-17 15:23:38 sandervl Exp $ */
2/*
3 * Window API wrappers for OS/2
4 *
5 *
6 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 */
12#define INCL_WIN
13#define INCL_PM
14#include <os2.h>
15#include <os2wrap.h>
16#include <stdlib.h>
17#include <string.h>
18
19#include <misc.h>
20#include <oslibwin.h>
21#include "oslibstyle.h"
22#include "oslibutil.h"
23#include "oslibmsg.h"
24#include "pmwindow.h"
25
26//******************************************************************************
27//******************************************************************************
28BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw)
29{
30 if(hwndParent == OSLIB_HWND_DESKTOP)
31 {
32 hwndParent = HWND_DESKTOP;
33 }
34
35 return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
36}
37//******************************************************************************
38//******************************************************************************
39HWND OSLibWinCreateWindow(HWND hwndParent, ULONG dwWinStyle, ULONG dwFrameStyle,
40 char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame)
41{
42 HWND hwndClient;
43 RECTL rectl;
44
45 if(pszName && *pszName == 0) {
46 pszName = NULL;
47 }
48 if(hwndParent == 0) {
49 hwndParent = HWND_DESKTOP;
50 }
51 if(dwFrameStyle) {
52 dwWinStyle &= ~WS_CLIPCHILDREN; //invalid style according to docs
53 *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
54 &dwFrameStyle, WIN32_STDCLASS,
55 "", 0, 0, 0, &hwndClient) != 0;
56 if(*hwndFrame) {
57 if(pszName) {
58 WinSetWindowText(*hwndFrame, pszName);
59 }
60 return hwndClient;
61 }
62 dprintf(("OSLibWinCreateWindow: WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
63 return 0;
64 }
65 hwndClient = WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, 0, 0, 0, 0,
66 Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,
67 NULL);
68 *hwndFrame = hwndClient;
69 return hwndClient;
70}
71//******************************************************************************
72//******************************************************************************
73BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle)
74{
75 *OSWinStyle = 0;
76 *OSFrameStyle = 0;
77
78 /* Window styles */
79 if(dwStyle & WINWS_MINIMIZE)
80 *OSWinStyle |= WS_MINIMIZED;
81//Done explicitely in CreateWindowExA
82#if 0
83 if(dwStyle & WINWS_VISIBLE)
84 *OSWinStyle |= WS_VISIBLE;
85#endif
86 if(dwStyle & WINWS_DISABLED)
87 *OSWinStyle |= WS_DISABLED;
88 if(dwStyle & WINWS_CLIPSIBLINGS)
89 *OSWinStyle |= WS_CLIPSIBLINGS;
90 if(dwStyle & WINWS_CLIPCHILDREN)
91 *OSWinStyle |= WS_CLIPCHILDREN;
92 if(dwStyle & WINWS_MAXIMIZE)
93 *OSWinStyle |= WS_MAXIMIZED;
94 if(dwStyle & WINWS_GROUP)
95 *OSWinStyle |= WS_GROUP;
96 if(dwStyle & WINWS_TABSTOP)
97 *OSWinStyle |= WS_TABSTOP;
98
99 if(dwStyle & WINWS_CAPTION)
100 *OSFrameStyle |= FCF_TITLEBAR;
101 if(dwStyle & WINWS_BORDER)
102 *OSFrameStyle |= FCF_BORDER;
103 if(dwStyle & WINWS_DLGFRAME)
104 *OSFrameStyle |= FCF_DLGBORDER;
105 if(dwStyle & WINWS_VSCROLL)
106 *OSFrameStyle |= FCF_VERTSCROLL;
107 if(dwStyle & WINWS_HSCROLL)
108 *OSFrameStyle |= FCF_HORZSCROLL;
109 if(dwStyle & WINWS_SYSMENU)
110 *OSFrameStyle |= FCF_SYSMENU;
111 if(dwStyle & WINWS_THICKFRAME)
112 *OSFrameStyle |= FCF_SIZEBORDER; //??
113 if(dwStyle & WINWS_MINIMIZEBOX)
114 *OSFrameStyle |= FCF_MINBUTTON;
115 if(dwStyle & WINWS_MAXIMIZEBOX)
116 *OSFrameStyle |= FCF_MAXBUTTON;
117
118 return TRUE;
119}
120//******************************************************************************
121//******************************************************************************
122BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
123{
124 return WinSetWindowULong(hwnd, offset, value);
125}
126//******************************************************************************
127//******************************************************************************
128ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
129{
130 return WinQueryWindowULong(hwnd, offset);
131}
132//******************************************************************************
133//******************************************************************************
134BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
135{
136 return WinPostMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
137}
138//******************************************************************************
139//******************************************************************************
140HWND OSLibWinCreateMenu(HWND hwndParent, PVOID menutemplate)
141{
142 return WinCreateMenu(hwndParent, menutemplate);
143}
144//******************************************************************************
145//******************************************************************************
146BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle)
147{
148 return WinAlarm(hwndDeskTop,flStyle);
149}
150//******************************************************************************
151//******************************************************************************
152APIRET OSLibDosBeep(ULONG freg,ULONG dur)
153{
154 return DosBeep(freg,dur);
155}
156//******************************************************************************
157//******************************************************************************
158LONG OSLibWinQueryWindowTextLength(HWND hwnd)
159{
160 return WinQueryWindowTextLength(hwnd);
161}
162//******************************************************************************
163//******************************************************************************
164LONG OSLibWinQueryWindowText(HWND hwnd,LONG lLength,char* pun)
165{
166 return WinQueryWindowText(hwnd,lLength,pun);
167}
168//******************************************************************************
169//******************************************************************************
170HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
171{
172 return WinQueryWindow(hwnd, lCode);
173}
174//******************************************************************************
175//******************************************************************************
176BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx,
177 LONG cy, ULONG fl)
178{
179 RECTL rectl;
180 HWND hwndParent;
181
182 if(fl & SWP_MOVE) {
183 hwndParent = WinQueryWindow(hwnd, QW_PARENT);
184 if(WinQueryWindowRect(hwnd, &rectl)) {
185 y = OS2TOWIN32POINT(rectl.yTop - rectl.yBottom, y);
186 }
187 }
188 return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
189}
190//******************************************************************************
191//******************************************************************************
192BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
193{
194 BOOL rc;
195
196 if(fl & SWP_SHOW) {
197 rc = WinShowWindow(hwnd, TRUE);
198 }
199 if(rc == 0)
200 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
201 rc = WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, fl);
202 if(rc == 0)
203 dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
204 return rc;
205}
206//******************************************************************************
207//******************************************************************************
208BOOL OSLibWinDestroyWindow(HWND hwnd)
209{
210 return WinDestroyWindow(hwnd);
211}
212//******************************************************************************
213//******************************************************************************
214BOOL OSLibWinQueryUpdateRect(HWND hwnd, PVOID pRect)
215{
216 return WinQueryUpdateRect(hwnd, (RECTL *)pRect);
217}
218//******************************************************************************
219//******************************************************************************
220BOOL OSLibWinIsIconic(HWND hwnd)
221{
222 SWP swp;
223 BOOL rc;
224
225 rc = WinQueryWindowPos(hwnd, &swp);
226 if(rc == FALSE) {
227 dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
228 return FALSE;
229 }
230
231 if(swp.fl & SWP_MINIMIZE)
232 return TRUE;
233 else return FALSE;
234}
235//******************************************************************************
236//******************************************************************************
237BOOL OSLibWinSetActiveWindow(HWND hwnd)
238{
239 return WinSetActiveWindow(HWND_DESKTOP, hwnd);
240}
241//******************************************************************************
242//******************************************************************************
243BOOL OSLibWinSetFocus(HWND hwnd)
244{
245 return WinSetFocus(HWND_DESKTOP, hwnd);
246}
247//******************************************************************************
248//******************************************************************************
249BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
250{
251 return WinEnableWindow(hwnd, fEnable);
252}
253//******************************************************************************
254//******************************************************************************
255BOOL OSLibWinIsWindowEnabled(HWND hwnd)
256{
257 return WinIsWindowEnabled(hwnd);
258}
259//******************************************************************************
260//******************************************************************************
261BOOL OSLibWinIsWindowVisible(HWND hwnd)
262{
263 return WinIsWindowVisible(hwnd);
264}
265//******************************************************************************
266//******************************************************************************
267BOOL OSLibWinQueryActiveWindow()
268{
269 return WinQueryActiveWindow(HWND_DESKTOP);
270}
271//******************************************************************************
272//******************************************************************************
273void OSLibWinPostQuitMessage(ULONG nExitCode)
274{
275 WinPostQueueMsg(GetThreadMessageQueue(), WM_QUIT, (MPARAM)nExitCode, 0);
276}
277//******************************************************************************
278//******************************************************************************
279LONG OSLibWinDispatchMsg(MSG *msg, BOOL isUnicode)
280{
281 QMSG qmsg;
282
283 WinToOS2MsgTranslate(msg, &qmsg, isUnicode);
284 return (LONG)WinDispatchMsg(GetThreadHAB(), &qmsg);
285}
286//******************************************************************************
287//******************************************************************************
288BOOL OSLibWinGetMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax, BOOL isUnicode)
289{
290 QMSG qmsg;
291 BOOL rc;
292
293 rc = WinGetMsg(GetThreadHAB(), &qmsg, TranslateWinMsg(uMsgFilterMin), TranslateWinMsg(uMsgFilterMax), 0);
294 OS2ToWinMsgTranslate(&qmsg, pMsg, isUnicode);
295 return rc;
296}
297//******************************************************************************
298//******************************************************************************
299
Note: See TracBrowser for help on using the repository browser.