3 * Purpose: 32bit interface to CTL3D functions for Watcom C/C++
4 * Author: Patrick Halke
16 #if defined(__WINDOWS_386__)
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
33 #define INDIR_HANDLE INDIR_PTR
34 #define INDIR_HWND INDIR_PTR
35 #define INDIR_HDC INDIR_PTR
37 #define INDIR_HANDLE INDIR_UINT
38 #define INDIR_HWND INDIR_UINT
39 #define INDIR_HDC INDIR_UINT
42 typedef struct tagCTL3DFUNCTIONS
{
44 /* Function Handles */
45 HINDIR _Ctl3dSubclassDlg
;
46 HINDIR _Ctl3dSubclassDlgEx
;
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
;
60 static CTL3DFUNCTIONS Ctl3dFunc
= { 0 };
62 static BOOL
load_functions( CTL3DFUNCTIONS
* functions
)
67 dll
= LoadLibrary( "CTL3D.DLL" );
68 if( dll
< HINSTANCE_ERROR
) {
74 proc
= GetProcAddress(dll
, "Ctl3dSubclassDlg");
75 functions
->_Ctl3dSubclassDlg
= GetIndirectFunctionHandle( proc
,
80 proc
= GetProcAddress( dll
, "Ctl3dSubclassDlgEx" );
81 functions
->_Ctl3dSubclassDlgEx
= GetIndirectFunctionHandle( proc
,
86 proc
= GetProcAddress( dll
, "Ctl3dGetVer" );
87 functions
->_Ctl3dGetVer
= GetIndirectFunctionHandle( proc
,
90 proc
= GetProcAddress( dll
, "Ctl3dEnabled" );
91 functions
->_Ctl3dEnabled
= GetIndirectFunctionHandle( proc
,
94 proc
= GetProcAddress( dll
, "Ctl3dCtlColor" );
95 functions
->_Ctl3dCtlColor
= GetIndirectFunctionHandle( proc
,
100 proc
= GetProcAddress( dll
, "Ctl3dCtlColorEx" );
101 functions
->_Ctl3dCtlColorEx
= GetIndirectFunctionHandle( proc
,
107 proc
= GetProcAddress( dll
, "Ctl3dColorChange" );
108 functions
->_Ctl3dColorChange
= GetIndirectFunctionHandle( proc
,
111 proc
= GetProcAddress( dll
, "Ctl3dSubclassCtl" );
112 functions
->_Ctl3dSubclassCtl
= GetIndirectFunctionHandle( proc
,
116 proc
= GetProcAddress( dll
, "Ctl3dDlgFramePaint" );
117 functions
->_Ctl3dDlgFramePaint
= GetIndirectFunctionHandle( proc
,
124 proc
= GetProcAddress( dll
, "Ctl3dAutoSubclass" );
125 functions
->_Ctl3dAutoSubclass
= GetIndirectFunctionHandle( proc
,
129 proc
= GetProcAddress( dll
, "Ctl3dRegister" );
130 functions
->_Ctl3dRegister
= GetIndirectFunctionHandle( proc
,
134 proc
= GetProcAddress( dll
, "Ctl3dUnregister" );
135 functions
->_Ctl3dUnregister
= GetIndirectFunctionHandle( proc
,
139 proc
= GetProcAddress( dll
, "Ctl3dWinIniChange" );
140 functions
->_Ctl3dWinIniChange
= GetIndirectFunctionHandle( proc
,
143 functions
->dll
= dll
;
147 static void unload_functions( CTL3DFUNCTIONS
* functions
)
149 FreeLibrary( functions
->dll
);
153 /* Function Definitions */
155 BOOL WINAPI
Ctl3dSubclassDlg(HWND hwnd
, WORD w
)
158 if (!load_functions(&Ctl3dFunc
))
161 return (BOOL
)InvokeIndirectFunction(Ctl3dFunc
._Ctl3dSubclassDlg
,
165 BOOL WINAPI
Ctl3dSubclassDlgEx(HWND hwnd
, DWORD dw
)
168 if (!load_functions(&Ctl3dFunc
))
171 return (BOOL
)InvokeIndirectFunction(Ctl3dFunc
._Ctl3dSubclassDlgEx
,
175 WORD WINAPI
Ctl3dGetVer(void)
178 if (!load_functions(&Ctl3dFunc
))
181 return (WORD
)InvokeIndirectFunction(Ctl3dFunc
._Ctl3dGetVer
);
184 BOOL WINAPI
Ctl3dEnabled(void)
187 if (!load_functions(&Ctl3dFunc
))
190 return (BOOL
)InvokeIndirectFunction(Ctl3dFunc
._Ctl3dEnabled
);
193 HBRUSH WINAPI
Ctl3dCtlColor(HDC hdc
, LONG l
)
196 if (!load_functions(&Ctl3dFunc
))
199 return (HBRUSH
)InvokeIndirectFunction(Ctl3dFunc
._Ctl3dCtlColor
,
203 HBRUSH WINAPI
Ctl3dCtlColorEx(UINT ui
, WPARAM wp
, LPARAM lp
)
206 if (!load_functions(&Ctl3dFunc
))
209 return (HBRUSH
)InvokeIndirectFunction(Ctl3dFunc
._Ctl3dCtlColorEx
,
213 BOOL WINAPI
Ctl3dColorChange(void)
216 if (!load_functions(&Ctl3dFunc
))
219 return (BOOL
)InvokeIndirectFunction(Ctl3dFunc
._Ctl3dColorChange
);
222 BOOL WINAPI
Ctl3dSubclassCtl(HWND hwnd
)
225 if (!load_functions(&Ctl3dFunc
))
228 return (BOOL
)InvokeIndirectFunction(Ctl3dFunc
._Ctl3dSubclassCtl
,
232 LONG WINAPI
Ctl3dDlgFramePaint(HWND hwnd
, UINT ui
, WPARAM wp
, LPARAM lp
)
235 if (!load_functions(&Ctl3dFunc
))
238 return (LONG
)InvokeIndirectFunction(Ctl3dFunc
._Ctl3dDlgFramePaint
,
242 BOOL WINAPI
Ctl3dAutoSubclass(HANDLE hnd
)
245 if (!load_functions(&Ctl3dFunc
))
248 return (BOOL
)InvokeIndirectFunction(Ctl3dFunc
._Ctl3dAutoSubclass
,
252 BOOL WINAPI
Ctl3dRegister(HANDLE hnd
)
255 if (!load_functions(&Ctl3dFunc
))
258 return (BOOL
)InvokeIndirectFunction(Ctl3dFunc
._Ctl3dRegister
,
262 BOOL WINAPI
Ctl3dUnregister(HANDLE hnd
)
265 if (!load_functions(&Ctl3dFunc
))
268 return (BOOL
)InvokeIndirectFunction(Ctl3dFunc
._Ctl3dUnregister
,
272 VOID WINAPI
Ctl3dWinIniChange(void)
275 if (!load_functions(&Ctl3dFunc
))
278 InvokeIndirectFunction(Ctl3dFunc
._Ctl3dWinIniChange
);
285 #endif // __WINDOWS_386__