Rev 471 | Rev 477 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 471 | Rev 476 | ||
---|---|---|---|
Line 26... | Line 26... | ||
26 | 26 | ||
27 | // PLUGIN.DLL Sliders: This method will register the "slider" class used in dialogs. |
27 | // PLUGIN.DLL Sliders: This method will register the "slider" class used in dialogs. |
28 | typedef BOOL(__cdecl* f_RegisterSlider)(HINSTANCE hInstanceDll, DWORD* MessageID); |
28 | typedef BOOL(__cdecl* f_RegisterSlider)(HINSTANCE hInstanceDll, DWORD* MessageID); |
29 | BOOL RegisterSlider(HINSTANCE hInstanceDll, DWORD* MessageID) { |
29 | BOOL RegisterSlider(HINSTANCE hInstanceDll, DWORD* MessageID) { |
30 | f_RegisterSlider fRegisterSlider; |
30 | f_RegisterSlider fRegisterSlider; |
31 | HMODULE hPlugin; |
- | |
32 | BOOL res; |
31 | BOOL res; |
33 | 32 | ||
34 | hPlugin = LoadLibrary(TEXT("PLUGIN.DLL")); |
- | |
35 | if (!hPlugin) return false; |
33 | if (!gdata->libPluginDll) return false; |
36 | fRegisterSlider = (f_RegisterSlider)(void*)GetProcAddress(hPlugin, "RegisterSlider"); |
34 | fRegisterSlider = (f_RegisterSlider)(void*)GetProcAddress(gdata->libPluginDll, "RegisterSlider"); |
37 | res = (fRegisterSlider != 0) ? fRegisterSlider(hInstanceDll, MessageID) : false; |
35 | res = (fRegisterSlider != 0) ? fRegisterSlider(hInstanceDll, MessageID) : false; |
38 | FreeLibrary(hPlugin); |
- | |
39 | return res; |
36 | return res; |
40 | } |
37 | } |
41 | 38 | ||
42 | // PLUGIN.DLL Sliders: This method will unregister the "slider" class used in dialogs. |
39 | // PLUGIN.DLL Sliders: This method will unregister the "slider" class used in dialogs. |
43 | typedef BOOL(__cdecl* f_UnRegisterSlider)(HINSTANCE hInstanceDll); |
40 | typedef BOOL(__cdecl* f_UnRegisterSlider)(HINSTANCE hInstanceDll); |
44 | BOOL UnRegisterSlider(HINSTANCE hInstanceDll) { |
41 | BOOL UnRegisterSlider(HINSTANCE hInstanceDll) { |
45 | f_UnRegisterSlider fUnRegisterSlider; |
42 | f_UnRegisterSlider fUnRegisterSlider; |
46 | HMODULE hPlugin; |
- | |
47 | BOOL res; |
43 | BOOL res; |
48 | 44 | ||
49 | hPlugin = LoadLibrary(TEXT("PLUGIN.DLL")); |
- | |
50 | if (!hPlugin) return false; |
45 | if (!gdata->libPluginDll) return false; |
51 | fUnRegisterSlider = (f_UnRegisterSlider)(void*)GetProcAddress(hPlugin, "UnRegisterSlider"); |
46 | fUnRegisterSlider = (f_UnRegisterSlider)(void*)GetProcAddress(gdata->libPluginDll, "UnRegisterSlider"); |
52 | res = (fUnRegisterSlider != 0) ? fUnRegisterSlider(hInstanceDll) : false; |
47 | res = (fUnRegisterSlider != 0) ? fUnRegisterSlider(hInstanceDll) : false; |
53 | FreeLibrary(hPlugin); |
- | |
54 | return res; |
48 | return res; |
55 | } |
49 | } |
56 | 50 | ||
57 | // PLUGIN.DLL Sliders: Set slider range (min/max) |
51 | // PLUGIN.DLL Sliders: Set slider range (min/max) |
58 | typedef int(__cdecl* f_SetSliderRange)(HWND hWnd, int nMin, int nMax); |
52 | typedef int(__cdecl* f_SetSliderRange)(HWND hWnd, int nMin, int nMax); |
59 | int SetSliderRange(HWND hWnd, int nMin, int nMax) { |
53 | int SetSliderRange(HWND hWnd, int nMin, int nMax) { |
60 | f_SetSliderRange fSetSliderRange; |
54 | f_SetSliderRange fSetSliderRange; |
61 | HMODULE hPlugin; |
- | |
62 | int res; |
55 | int res; |
63 | 56 | ||
64 | hPlugin = LoadLibrary(TEXT("PLUGIN.DLL")); |
- | |
65 | if (!hPlugin) return 0; |
57 | if (!gdata->libPluginDll) return 0; |
66 | fSetSliderRange = (f_SetSliderRange)(void*)GetProcAddress(hPlugin, "SetSliderRange"); |
58 | fSetSliderRange = (f_SetSliderRange)(void*)GetProcAddress(gdata->libPluginDll, "SetSliderRange"); |
67 | res = (fSetSliderRange != 0) ? fSetSliderRange(hWnd, nMin, nMax) : 0; |
59 | res = (fSetSliderRange != 0) ? fSetSliderRange(hWnd, nMin, nMax) : 0; |
68 | FreeLibrary(hPlugin); |
- | |
69 | return res; |
60 | return res; |
70 | } |
61 | } |
71 | 62 | ||
72 | // PLUGIN.DLL Sliders : Sets slider position |
63 | // PLUGIN.DLL Sliders : Sets slider position |
73 | typedef int(__cdecl* f_SetSliderPos)(HWND hWnd, int nPos, BOOL bRepaint); |
64 | typedef int(__cdecl* f_SetSliderPos)(HWND hWnd, int nPos, BOOL bRepaint); |
74 | int SetSliderPos(HWND hWnd, int nPos, BOOL bRepaint) { |
65 | int SetSliderPos(HWND hWnd, int nPos, BOOL bRepaint) { |
75 | f_SetSliderPos fSetSliderPos; |
66 | f_SetSliderPos fSetSliderPos; |
76 | HMODULE hPlugin; |
- | |
77 | int res; |
67 | int res; |
78 | 68 | ||
79 | hPlugin = LoadLibrary(TEXT("PLUGIN.DLL")); |
- | |
80 | if (!hPlugin) return 0; |
69 | if (!gdata->libPluginDll) return 0; |
81 | fSetSliderPos = (f_SetSliderPos)(void*)GetProcAddress(hPlugin, "SetSliderPos"); |
70 | fSetSliderPos = (f_SetSliderPos)(void*)GetProcAddress(gdata->libPluginDll, "SetSliderPos"); |
82 | res = (fSetSliderPos != 0) ? fSetSliderPos(hWnd, nPos, bRepaint) : 0; |
71 | res = (fSetSliderPos != 0) ? fSetSliderPos(hWnd, nPos, bRepaint) : 0; |
83 | FreeLibrary(hPlugin); |
- | |
84 | return res; |
72 | return res; |
85 | } |
73 | } |
86 | 74 | ||
87 | // PLUGIN.DLL Sliders : Get slider position |
75 | // PLUGIN.DLL Sliders : Get slider position |
88 | typedef int(__cdecl* f_GetSliderPos)(HWND hWnd, BOOL bPixelPosition); |
76 | typedef int(__cdecl* f_GetSliderPos)(HWND hWnd, BOOL bPixelPosition); |
89 | int GetSliderPos(HWND hWnd, BOOL bPixelPosition) { |
77 | int GetSliderPos(HWND hWnd, BOOL bPixelPosition) { |
90 | f_GetSliderPos fGetSliderPos; |
78 | f_GetSliderPos fGetSliderPos; |
91 | HMODULE hPlugin; |
- | |
92 | int res; |
79 | int res; |
93 | 80 | ||
94 | hPlugin = LoadLibrary(TEXT("PLUGIN.DLL")); |
- | |
95 | if (!hPlugin) return 0; |
81 | if (!gdata->libPluginDll) return 0; |
96 | fGetSliderPos = (f_GetSliderPos)(void*)GetProcAddress(hPlugin, "GetSliderPos"); |
82 | fGetSliderPos = (f_GetSliderPos)(void*)GetProcAddress(gdata->libPluginDll, "GetSliderPos"); |
97 | res = (fGetSliderPos != 0) ? fGetSliderPos(hWnd, bPixelPosition) : 0; |
83 | res = (fGetSliderPos != 0) ? fGetSliderPos(hWnd, bPixelPosition) : 0; |
98 | FreeLibrary(hPlugin); |
- | |
99 | return res; |
84 | return res; |
100 | } |
85 | } |
101 | 86 | ||
102 | LRESULT CALLBACK DummyWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { |
87 | LRESULT CALLBACK DummyWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { |
103 | return DefWindowProc(hwnd, uMsg, wParam, lParam); |
88 | return DefWindowProc(hwnd, uMsg, wParam, lParam); |
Line 172... | Line 157... | ||
172 | } |
157 | } |
173 | return false; |
158 | return false; |
174 | } |
159 | } |
175 | } |
160 | } |
176 | 161 | ||
177 | void Slider_Uninit_PluginDll() { |
- | |
178 | #ifndef use_plugin_dll_sliders |
- | |
179 | return; |
- | |
180 | #else |
- | |
181 | if (gdata->pluginDllSliderInitialized) { |
- | |
182 | if (UnRegisterSlider(hDllInstance)) { |
- | |
183 | gdata->pluginDllSliderInitialized = false; |
- | |
184 | } else { |
- | |
185 | simplealert(TEXT("UnRegisterSlider failed")); |
- | |
186 | } |
- | |
187 | } |
- | |
188 | #endif |
- | |
189 | - | ||
190 | } |
- | |
191 | - | ||
192 | Boolean Slider_Init_PluginDll(LPCTSTR targetClass) { |
162 | Boolean Slider_Init_PluginDll(LPCTSTR targetClass) { |
193 | 163 | ||
194 | #ifndef use_plugin_dll_sliders |
164 | #ifndef use_plugin_dll_sliders |
195 | return false; |
165 | return false; |
196 | #else |
166 | #else |
197 | if (!gdata->pluginDllSliderInitialized) { |
167 | if (gdata->pluginDllSliderInitialized) return true; |
- | 168 | ||
- | 169 | if (!gdata->libPluginDll) { |
|
- | 170 | // DM 16.04.2022 : It is important that PLUGIN.DLL stays loaded, otherwise |
|
- | 171 | // DialogBoxParamA crashes. Can be reproduced if all 8BX modules are disabled in Photoshop 7 |
|
- | 172 | // (they keep PLUGIN.DLL loaded). |
|
- | 173 | gdata->libPluginDll = LoadLibrary(TEXT("Plugin.dll")); |
|
- | 174 | } |
|
- | 175 | ||
198 | if (RegisterSlider(hDllInstance, &gdata->pluginDllSliderMessageId)) { |
176 | if (gdata->libPluginDll && RegisterSlider(hDllInstance, &gdata->pluginDllSliderMessageId)) { |
199 | gdata->pluginDllSliderInitialized = true; |
177 | gdata->pluginDllSliderInitialized = true; |
- | 178 | ||
- | 179 | // Make "FoundrySlider" a subclass of "slider" then |
|
- | 180 | return MakeSimpleSubclass(targetClass, TEXT("slider")); |
|
200 | } |
181 | } |
201 | else { |
182 | else { |
202 | // This can happen if PLUGIN.DLL is not existing |
183 | // This can happen if PLUGIN.DLL is not existing |
203 | // It will also happen if a previous uninitialization failed (or was forgotten) |
184 | // It will also happen if a previous uninitialization failed (or was forgotten) |
204 | return false; // Fall back to Windows sliders |
185 | return false; // Fall back to Windows sliders |
205 | } |
186 | } |
- | 187 | #endif |
|
- | 188 | ||
206 | } |
189 | } |
207 | 190 | ||
- | 191 | void Slider_Uninit_PluginDll() { |
|
- | 192 | #ifndef use_plugin_dll_sliders |
|
- | 193 | return; |
|
- | 194 | #else |
|
- | 195 | if (gdata->pluginDllSliderInitialized) { |
|
- | 196 | if (UnRegisterSlider(hDllInstance)) { |
|
208 | // Make "FoundrySlider" a subclass of "slider" then |
197 | gdata->pluginDllSliderInitialized = false; |
- | 198 | ||
- | 199 | if (gdata->libPluginDll) { |
|
- | 200 | FreeLibrary(gdata->libPluginDll); |
|
- | 201 | gdata->libPluginDll = 0; |
|
- | 202 | } |
|
- | 203 | } |
|
- | 204 | else { |
|
209 | return MakeSimpleSubclass(targetClass, TEXT("slider")); |
205 | simplealert((TCHAR*)TEXT("UnRegisterSlider failed")); |
- | 206 | } |
|
- | 207 | } |
|
210 | #endif |
208 | #endif |
211 | 209 | ||
212 | } |
210 | } |
213 | 211 | ||
214 | typedef void(__stdcall* f_InitCommonControls)(); |
212 | typedef void(__stdcall* f_InitCommonControls)(); |
215 | typedef BOOL(__stdcall* f_InitCommonControlsEx)(const INITCOMMONCONTROLSEX* picce); |
213 | typedef BOOL(__stdcall* f_InitCommonControlsEx)(const INITCOMMONCONTROLSEX* picce); |
216 | Boolean Slider_Init_MsTrackbar(LPCTSTR targetClass) { |
214 | Boolean Slider_Init_MsTrackbar(LPCTSTR targetClass) { |
217 | f_InitCommonControls fInitCommonControls; |
215 | f_InitCommonControls fInitCommonControls; |
218 | f_InitCommonControlsEx fInitCommonControlsEx; |
216 | f_InitCommonControlsEx fInitCommonControlsEx; |
219 | HMODULE libComctl32; |
- | |
220 | 217 | ||
221 | // Make sure that Comctl32 is loaded |
218 | // Make sure that Comctl32 is loaded |
- | 219 | if (!gdata->libComctl32) { |
|
222 | libComctl32 = LoadLibrary(TEXT("Comctl32.dll")); |
220 | gdata->libComctl32 = LoadLibrary(TEXT("Comctl32.dll")); |
- | 221 | } |
|
223 | if (libComctl32) { |
222 | if (gdata->libComctl32) { |
224 | fInitCommonControlsEx = (f_InitCommonControlsEx)(void*)GetProcAddress(libComctl32, "InitCommonControlsEx"); |
223 | fInitCommonControlsEx = (f_InitCommonControlsEx)(void*)GetProcAddress(gdata->libComctl32, "InitCommonControlsEx"); |
225 | if (fInitCommonControlsEx != 0) { |
224 | if (fInitCommonControlsEx != 0) { |
226 | INITCOMMONCONTROLSEX icce; |
225 | INITCOMMONCONTROLSEX icce; |
227 | icce.dwSize = sizeof(INITCOMMONCONTROLSEX); |
226 | icce.dwSize = sizeof(INITCOMMONCONTROLSEX); |
228 | icce.dwICC = ICC_BAR_CLASSES; |
227 | icce.dwICC = ICC_BAR_CLASSES; |
229 | fInitCommonControlsEx(&icce); |
228 | fInitCommonControlsEx(&icce); |
230 | } |
229 | } |
231 | else { |
230 | else { |
232 | fInitCommonControls = (f_InitCommonControls)(void*)GetProcAddress(libComctl32, "InitCommonControls"); |
231 | fInitCommonControls = (f_InitCommonControls)(void*)GetProcAddress(gdata->libComctl32, "InitCommonControls"); |
233 | if (fInitCommonControls != 0) { |
232 | if (fInitCommonControls != 0) { |
234 | fInitCommonControls(); |
233 | fInitCommonControls(); |
235 | } |
234 | } |
236 | } |
235 | } |
237 | // There seems to be a bug in Windows NT 3.11 (if PLUGIN.DLL does not exist): |
- | |
238 | // If we call FreeLibrary, and then open Filter Foundry again, |
- | |
239 | // then you get an error message "BRUSHES" cannot initialize Comctl32.dll ... |
- | |
240 | // I am not sure if it is OK to do a FreeLibrary after you have called InitCommonControls. |
- | |
241 | // Isn't that a contradiction? |
- | |
242 | //FreeLibrary(libComctl32); |
- | |
243 | } |
- | |
244 | 236 | ||
245 | // Make "FoundrySlider" a subclass of "msctls_trackbar32" then |
237 | // Make "FoundrySlider" a subclass of "msctls_trackbar32" then |
246 | return MakeSimpleSubclass(targetClass, TEXT("msctls_trackbar32")); |
238 | return MakeSimpleSubclass(targetClass, TEXT("msctls_trackbar32")); |
247 | } |
239 | } |
- | 240 | else { |
|
- | 241 | return false; |
|
- | 242 | } |
|
- | 243 | } |
|
- | 244 | ||
- | 245 | void Slider_Uninit_MsTrackbar() { |
|
- | 246 | if (gdata->libComctl32 != 0) { |
|
- | 247 | FreeLibrary(gdata->libComctl32); |
|
- | 248 | gdata->libComctl32 = 0; |
|
- | 249 | } |
|
- | 250 | } |
|
248 | 251 | ||
249 | Boolean Slider_Init_None(LPCTSTR targetClass) { |
252 | Boolean Slider_Init_None(LPCTSTR targetClass) { |
250 | // Make "FoundrySlider" a subclass of "STATIC" (making it invisible) |
253 | // Make "FoundrySlider" a subclass of "STATIC" (making it invisible) |
251 | return MakeSimpleSubclass(targetClass, WC_STATIC); |
254 | return MakeSimpleSubclass(targetClass, WC_STATIC); |
252 | } |
255 | } |
- | 256 | ||
- | 257 | void Slider_Uninit_None() { |
|
- | 258 | // Nothing here |
|
- | 259 | } |
|
253 | 260 |