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

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

* empty log message *

File size: 9.5 KB
Line 
1/* $Id: oslibwin.cpp,v 1.6 1999-07-17 11:52:22 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, ULONG x, ULONG y, ULONG cx, ULONG cy,
41 HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame)
42{
43 HWND hwndClient;
44 RECTL rectl;
45
46 if(hwndParent == 0) {
47 hwndParent = HWND_DESKTOP;
48 }
49 if(WinQueryWindowRect(hwndParent, &rectl) == TRUE) {
50 y = OS2TOWIN32POINT(rectl.yTop - rectl.yBottom, y);
51 }
52 if(dwFrameStyle) {
53 dwWinStyle &= ~WS_CLIPCHILDREN; //invalid style according to docs
54 *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
55 &dwFrameStyle, WIN32_STDCLASS,
56 "", 0, 0, 0, &hwndClient) != 0;
57 if(*hwndFrame) {
58 if(pszName) {
59 WinSetWindowText(*hwndFrame, pszName);
60 }
61 WinSetWindowPos(*hwndFrame, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP,
62 x, y, cx, cy, SWP_SIZE | SWP_MOVE);
63
64 return hwndClient;
65 }
66 dprintf(("OSLibWinCreateWindow: WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
67 return 0;
68 }
69 hwndClient = WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, x, y, cx, cy,
70 Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,
71 NULL);
72 *hwndFrame = hwndClient;
73 return hwndClient;
74}
75//******************************************************************************
76//******************************************************************************
77BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle)
78{
79 *OSWinStyle = 0;
80 *OSFrameStyle = 0;
81
82 /* Window styles */
83 if(dwStyle & WINWS_MINIMIZE)
84 *OSWinStyle |= WS_MINIMIZED;
85 if(dwStyle & WINWS_VISIBLE)
86 *OSWinStyle |= WS_VISIBLE;
87 if(dwStyle & WINWS_DISABLED)
88 *OSWinStyle |= WS_DISABLED;
89 if(dwStyle & WINWS_CLIPSIBLINGS)
90 *OSWinStyle |= WS_CLIPSIBLINGS;
91 if(dwStyle & WINWS_CLIPCHILDREN)
92 *OSWinStyle |= WS_CLIPCHILDREN;
93 if(dwStyle & WINWS_MAXIMIZE)
94 *OSWinStyle |= WS_MAXIMIZED;
95 if(dwStyle & WINWS_GROUP)
96 *OSWinStyle |= WS_GROUP;
97 if(dwStyle & WINWS_TABSTOP)
98 *OSWinStyle |= WS_TABSTOP;
99
100 if(dwStyle & WINWS_CAPTION)
101 *OSFrameStyle |= FCF_TITLEBAR;
102 if(dwStyle & WINWS_BORDER)
103 *OSFrameStyle |= FCF_BORDER;
104 if(dwStyle & WINWS_DLGFRAME)
105 *OSFrameStyle |= FCF_DLGBORDER;
106 if(dwStyle & WINWS_VSCROLL)
107 *OSFrameStyle |= FCF_VERTSCROLL;
108 if(dwStyle & WINWS_HSCROLL)
109 *OSFrameStyle |= FCF_HORZSCROLL;
110 if(dwStyle & WINWS_SYSMENU)
111 *OSFrameStyle |= FCF_SYSMENU;
112 if(dwStyle & WINWS_THICKFRAME)
113 *OSFrameStyle |= FCF_SIZEBORDER; //??
114 if(dwStyle & WINWS_MINIMIZEBOX)
115 *OSFrameStyle |= FCF_MINBUTTON;
116 if(dwStyle & WINWS_MAXIMIZEBOX)
117 *OSFrameStyle |= FCF_MAXBUTTON;
118
119 return TRUE;
120}
121//******************************************************************************
122//******************************************************************************
123BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
124{
125 return WinSetWindowULong(hwnd, offset, value);
126}
127//******************************************************************************
128//******************************************************************************
129ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
130{
131 return WinQueryWindowULong(hwnd, offset);
132}
133//******************************************************************************
134//******************************************************************************
135BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
136{
137 return WinPostMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
138}
139//******************************************************************************
140//******************************************************************************
141HWND OSLibWinCreateMenu(HWND hwndParent, PVOID menutemplate)
142{
143 return WinCreateMenu(hwndParent, menutemplate);
144}
145//******************************************************************************
146//******************************************************************************
147HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
148{
149 return WinQueryWindow(hwnd, lCode);
150}
151//******************************************************************************
152//******************************************************************************
153BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx,
154 LONG cy, ULONG fl)
155{
156 return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
157}
158//******************************************************************************
159//******************************************************************************
160BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
161{
162 return WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, fl);
163}
164//******************************************************************************
165//******************************************************************************
166BOOL OSLibWinDestroyWindow(HWND hwnd)
167{
168 return WinDestroyWindow(hwnd);
169}
170//******************************************************************************
171//******************************************************************************
172BOOL OSLibWinQueryUpdateRect(HWND hwnd, PVOID pRect)
173{
174 return WinQueryUpdateRect(hwnd, (RECTL *)pRect);
175}
176//******************************************************************************
177//******************************************************************************
178BOOL OSLibWinIsIconic(HWND hwnd)
179{
180 SWP swp;
181 BOOL rc;
182
183 rc = WinQueryWindowPos(hwnd, &swp);
184 if(rc == FALSE) {
185 dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
186 return FALSE;
187 }
188
189 if(swp.fl & SWP_MINIMIZE)
190 return TRUE;
191 else return FALSE;
192}
193//******************************************************************************
194//******************************************************************************
195BOOL OSLibWinSetActiveWindow(HWND hwnd)
196{
197 return WinSetActiveWindow(HWND_DESKTOP, hwnd);
198}
199//******************************************************************************
200//******************************************************************************
201BOOL OSLibWinSetFocus(HWND hwnd)
202{
203 return WinSetFocus(HWND_DESKTOP, hwnd);
204}
205//******************************************************************************
206//******************************************************************************
207BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
208{
209 return WinEnableWindow(hwnd, fEnable);
210}
211//******************************************************************************
212//******************************************************************************
213BOOL OSLibWinIsWindowEnabled(HWND hwnd)
214{
215 return WinIsWindowEnabled(hwnd);
216}
217//******************************************************************************
218//******************************************************************************
219BOOL OSLibWinIsWindowVisible(HWND hwnd)
220{
221 return WinIsWindowVisible(hwnd);
222}
223//******************************************************************************
224//******************************************************************************
225BOOL OSLibWinQueryActiveWindow()
226{
227 return WinQueryActiveWindow(HWND_DESKTOP);
228}
229//******************************************************************************
230//******************************************************************************
231void OSLibWinPostQuitMessage(ULONG nExitCode)
232{
233 WinPostQueueMsg(GetThreadMessageQueue(), WM_QUIT, (MPARAM)nExitCode, 0);
234}
235//******************************************************************************
236//******************************************************************************
237LONG OSLibWinDispatchMsg(MSG *msg, BOOL isUnicode)
238{
239 QMSG qmsg;
240
241 WinToOS2MsgTranslate(msg, &qmsg, isUnicode);
242 return (LONG)WinDispatchMsg(GetThreadHAB(), &qmsg);
243}
244//******************************************************************************
245//******************************************************************************
246BOOL OSLibWinGetMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax, BOOL isUnicode)
247{
248 QMSG qmsg;
249 BOOL rc;
250
251 rc = WinGetMsg(GetThreadHAB(), &qmsg, TranslateWinMsg(uMsgFilterMin), TranslateWinMsg(uMsgFilterMax), 0);
252 OS2ToWinMsgTranslate(&qmsg, pMsg, isUnicode);
253 return rc;
254}
255//******************************************************************************
256//******************************************************************************
Note: See TracBrowser for help on using the repository browser.