]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * File: ctl3d32.c | |
3 | * Purpose: 32bit interface to CTL3D functions for Watcom C/C++ | |
4 | * Author: Patrick Halke | |
5 | * Created: 1995 | |
6 | * Updated: | |
7 | * Copyright: (c) 1995 | |
8 | */ | |
9 | ||
10 | #include <malloc.h> | |
11 | ||
12 | #include <windows.h> | |
13 | ||
14 | #include "ctl3d.h" | |
15 | ||
16 | #if defined(__WINDOWS_386__) | |
17 | ||
18 | #ifdef __cplusplus | |
19 | extern "C" { | |
20 | #endif | |
21 | ||
22 | #undef FAR | |
23 | #define FAR | |
24 | ||
25 | #define INDIR_INT INDIR_WORD | |
26 | #define INDIR_UINT INDIR_WORD | |
27 | #define INDIR_WPARAM INDIR_UINT | |
28 | #define INDIR_LPARAM INDIR_DWORD | |
29 | #define INDIR_LONG INDIR_DWORD | |
30 | #define INDIR_ULONG INDIR_DWORD | |
31 | ||
32 | #ifdef STRICT | |
33 | #define INDIR_HANDLE INDIR_PTR | |
34 | #define INDIR_HWND INDIR_PTR | |
35 | #define INDIR_HDC INDIR_PTR | |
36 | #else | |
37 | #define INDIR_HANDLE INDIR_UINT | |
38 | #define INDIR_HWND INDIR_UINT | |
39 | #define INDIR_HDC INDIR_UINT | |
40 | #endif | |
41 | ||
42 | typedef struct tagCTL3DFUNCTIONS { | |
43 | HINSTANCE dll; | |
44 | /* Function Handles */ | |
45 | HINDIR _Ctl3dSubclassDlg; | |
46 | HINDIR _Ctl3dSubclassDlgEx; | |
47 | HINDIR _Ctl3dGetVer; | |
48 | HINDIR _Ctl3dEnabled; | |
49 | HINDIR _Ctl3dCtlColor; | |
50 | HINDIR _Ctl3dCtlColorEx; | |
51 | HINDIR _Ctl3dColorChange; | |
52 | HINDIR _Ctl3dSubclassCtl; | |
53 | HINDIR _Ctl3dDlgFramePaint; | |
54 | HINDIR _Ctl3dAutoSubclass; | |
55 | HINDIR _Ctl3dRegister; | |
56 | HINDIR _Ctl3dUnregister; | |
57 | HINDIR _Ctl3dWinIniChange; | |
58 | } CTL3DFUNCTIONS; | |
59 | ||
60 | static CTL3DFUNCTIONS Ctl3dFunc = { 0 }; | |
61 | ||
62 | static BOOL load_functions( CTL3DFUNCTIONS* functions ) | |
63 | { | |
64 | FARPROC proc; | |
65 | HINSTANCE dll; | |
66 | ||
67 | dll = LoadLibrary( "CTL3D.DLL" ); | |
68 | if( dll < HINSTANCE_ERROR ) { | |
69 | return( FALSE ); | |
70 | } | |
71 | ||
72 | /* Function thunks */ | |
73 | ||
74 | proc = GetProcAddress(dll, "Ctl3dSubclassDlg"); | |
75 | functions->_Ctl3dSubclassDlg = GetIndirectFunctionHandle( proc, | |
76 | INDIR_HWND, | |
77 | INDIR_WORD, | |
78 | INDIR_ENDLIST ); | |
79 | ||
80 | proc = GetProcAddress( dll, "Ctl3dSubclassDlgEx" ); | |
81 | functions->_Ctl3dSubclassDlgEx = GetIndirectFunctionHandle( proc, | |
82 | INDIR_HWND, | |
83 | INDIR_DWORD, | |
84 | INDIR_ENDLIST ); | |
85 | ||
86 | proc = GetProcAddress( dll, "Ctl3dGetVer" ); | |
87 | functions->_Ctl3dGetVer = GetIndirectFunctionHandle( proc, | |
88 | INDIR_ENDLIST ); | |
89 | ||
90 | proc = GetProcAddress( dll, "Ctl3dEnabled" ); | |
91 | functions->_Ctl3dEnabled = GetIndirectFunctionHandle( proc, | |
92 | INDIR_ENDLIST ); | |
93 | ||
94 | proc = GetProcAddress( dll, "Ctl3dCtlColor" ); | |
95 | functions->_Ctl3dCtlColor = GetIndirectFunctionHandle( proc, | |
96 | INDIR_HDC, | |
97 | INDIR_LONG, | |
98 | INDIR_ENDLIST ); | |
99 | ||
100 | proc = GetProcAddress( dll, "Ctl3dCtlColorEx" ); | |
101 | functions->_Ctl3dCtlColorEx = GetIndirectFunctionHandle( proc, | |
102 | INDIR_UINT, | |
103 | INDIR_WPARAM, | |
104 | INDIR_LPARAM, | |
105 | INDIR_ENDLIST ); | |
106 | ||
107 | proc = GetProcAddress( dll, "Ctl3dColorChange" ); | |
108 | functions->_Ctl3dColorChange = GetIndirectFunctionHandle( proc, | |
109 | INDIR_ENDLIST ); | |
110 | ||
111 | proc = GetProcAddress( dll, "Ctl3dSubclassCtl" ); | |
112 | functions->_Ctl3dSubclassCtl = GetIndirectFunctionHandle( proc, | |
113 | INDIR_HWND, | |
114 | INDIR_ENDLIST ); | |
115 | ||
116 | proc = GetProcAddress( dll, "Ctl3dDlgFramePaint" ); | |
117 | functions->_Ctl3dDlgFramePaint = GetIndirectFunctionHandle( proc, | |
118 | INDIR_HWND, | |
119 | INDIR_UINT, | |
120 | INDIR_WPARAM, | |
121 | INDIR_LPARAM, | |
122 | INDIR_ENDLIST ); | |
123 | ||
124 | proc = GetProcAddress( dll, "Ctl3dAutoSubclass" ); | |
125 | functions->_Ctl3dAutoSubclass = GetIndirectFunctionHandle( proc, | |
126 | INDIR_HANDLE, | |
127 | INDIR_ENDLIST ); | |
128 | ||
129 | proc = GetProcAddress( dll, "Ctl3dRegister" ); | |
130 | functions->_Ctl3dRegister = GetIndirectFunctionHandle( proc, | |
131 | INDIR_HANDLE, | |
132 | INDIR_ENDLIST ); | |
133 | ||
134 | proc = GetProcAddress( dll, "Ctl3dUnregister" ); | |
135 | functions->_Ctl3dUnregister = GetIndirectFunctionHandle( proc, | |
136 | INDIR_HANDLE, | |
137 | INDIR_ENDLIST ); | |
138 | ||
139 | proc = GetProcAddress( dll, "Ctl3dWinIniChange" ); | |
140 | functions->_Ctl3dWinIniChange = GetIndirectFunctionHandle( proc, | |
141 | INDIR_ENDLIST ); | |
142 | ||
143 | functions->dll = dll; | |
144 | return( TRUE ); | |
145 | } | |
146 | ||
147 | static void unload_functions( CTL3DFUNCTIONS * functions ) | |
148 | { | |
149 | FreeLibrary( functions->dll ); | |
150 | functions->dll = 0; | |
151 | } | |
152 | ||
153 | /* Function Definitions */ | |
154 | ||
155 | BOOL WINAPI Ctl3dSubclassDlg(HWND hwnd, WORD w) | |
156 | { | |
157 | if (!Ctl3dFunc.dll) | |
158 | if (!load_functions(&Ctl3dFunc)) | |
159 | return FALSE; | |
160 | ||
161 | return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dSubclassDlg, | |
162 | hwnd, w); | |
163 | } | |
164 | ||
165 | BOOL WINAPI Ctl3dSubclassDlgEx(HWND hwnd, DWORD dw) | |
166 | { | |
167 | if (!Ctl3dFunc.dll) | |
168 | if (!load_functions(&Ctl3dFunc)) | |
169 | return FALSE; | |
170 | ||
171 | return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dSubclassDlgEx, | |
172 | hwnd, dw); | |
173 | } | |
174 | ||
175 | WORD WINAPI Ctl3dGetVer(void) | |
176 | { | |
177 | if (!Ctl3dFunc.dll) | |
178 | if (!load_functions(&Ctl3dFunc)) | |
179 | return FALSE; | |
180 | ||
181 | return (WORD)InvokeIndirectFunction(Ctl3dFunc._Ctl3dGetVer); | |
182 | } | |
183 | ||
184 | BOOL WINAPI Ctl3dEnabled(void) | |
185 | { | |
186 | if (!Ctl3dFunc.dll) | |
187 | if (!load_functions(&Ctl3dFunc)) | |
188 | return FALSE; | |
189 | ||
190 | return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dEnabled); | |
191 | } | |
192 | ||
193 | HBRUSH WINAPI Ctl3dCtlColor(HDC hdc, LONG l) | |
194 | { | |
195 | if (!Ctl3dFunc.dll) | |
196 | if (!load_functions(&Ctl3dFunc)) | |
197 | return FALSE; | |
198 | ||
199 | return (HBRUSH)InvokeIndirectFunction(Ctl3dFunc._Ctl3dCtlColor, | |
200 | hdc, l); | |
201 | } | |
202 | ||
203 | HBRUSH WINAPI Ctl3dCtlColorEx(UINT ui, WPARAM wp, LPARAM lp) | |
204 | { | |
205 | if (!Ctl3dFunc.dll) | |
206 | if (!load_functions(&Ctl3dFunc)) | |
207 | return FALSE; | |
208 | ||
209 | return (HBRUSH)InvokeIndirectFunction(Ctl3dFunc._Ctl3dCtlColorEx, | |
210 | ui, wp, lp); | |
211 | } | |
212 | ||
213 | BOOL WINAPI Ctl3dColorChange(void) | |
214 | { | |
215 | if (!Ctl3dFunc.dll) | |
216 | if (!load_functions(&Ctl3dFunc)) | |
217 | return FALSE; | |
218 | ||
219 | return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dColorChange); | |
220 | } | |
221 | ||
222 | BOOL WINAPI Ctl3dSubclassCtl(HWND hwnd) | |
223 | { | |
224 | if (!Ctl3dFunc.dll) | |
225 | if (!load_functions(&Ctl3dFunc)) | |
226 | return FALSE; | |
227 | ||
228 | return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dSubclassCtl, | |
229 | hwnd); | |
230 | } | |
231 | ||
232 | LONG WINAPI Ctl3dDlgFramePaint(HWND hwnd, UINT ui, WPARAM wp, LPARAM lp) | |
233 | { | |
234 | if (!Ctl3dFunc.dll) | |
235 | if (!load_functions(&Ctl3dFunc)) | |
236 | return FALSE; | |
237 | ||
238 | return (LONG)InvokeIndirectFunction(Ctl3dFunc._Ctl3dDlgFramePaint, | |
239 | hwnd, ui, wp, lp); | |
240 | } | |
241 | ||
242 | BOOL WINAPI Ctl3dAutoSubclass(HANDLE hnd) | |
243 | { | |
244 | if (!Ctl3dFunc.dll) | |
245 | if (!load_functions(&Ctl3dFunc)) | |
246 | return FALSE; | |
247 | ||
248 | return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dAutoSubclass, | |
249 | hnd); | |
250 | } | |
251 | ||
252 | BOOL WINAPI Ctl3dRegister(HANDLE hnd) | |
253 | { | |
254 | if (!Ctl3dFunc.dll) | |
255 | if (!load_functions(&Ctl3dFunc)) | |
256 | return FALSE; | |
257 | ||
258 | return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dRegister, | |
259 | hnd); | |
260 | } | |
261 | ||
262 | BOOL WINAPI Ctl3dUnregister(HANDLE hnd) | |
263 | { | |
264 | if (!Ctl3dFunc.dll) | |
265 | if (!load_functions(&Ctl3dFunc)) | |
266 | return FALSE; | |
267 | ||
268 | return (BOOL)InvokeIndirectFunction(Ctl3dFunc._Ctl3dUnregister, | |
269 | hnd); | |
270 | } | |
271 | ||
272 | VOID WINAPI Ctl3dWinIniChange(void) | |
273 | { | |
274 | if (!Ctl3dFunc.dll) | |
275 | if (!load_functions(&Ctl3dFunc)) | |
276 | return; | |
277 | ||
278 | InvokeIndirectFunction(Ctl3dFunc._Ctl3dWinIniChange); | |
279 | } | |
280 | ||
281 | #ifdef __cplusplus | |
282 | } | |
283 | #endif | |
284 | ||
285 | #endif // __WINDOWS_386__ |