25,84 → 25,64 |
// https://misc.daniel-marschall.de/projects/filter_factory/sliders.html |
|
// PLUGIN.DLL Sliders: This method will register the "slider" class used in dialogs. |
#ifdef use_plugin_dll_sliders |
typedef BOOL(__cdecl* f_RegisterSlider)(HINSTANCE hInstanceDll, DWORD* MessageID); |
BOOL RegisterSlider(HINSTANCE hInstanceDll, DWORD* MessageID) { |
f_RegisterSlider fRegisterSlider; |
BOOL res; |
|
if (!gdata->pluginDllSliderInfo.hLib) return false; |
fRegisterSlider = (f_RegisterSlider)(void*)GetProcAddress(gdata->pluginDllSliderInfo.hLib, "RegisterSlider"); |
if (!gdata->libPluginDll) return false; |
fRegisterSlider = (f_RegisterSlider)(void*)GetProcAddress(gdata->libPluginDll, "RegisterSlider"); |
res = (fRegisterSlider != 0) ? fRegisterSlider(hInstanceDll, MessageID) : false; |
return res; |
} |
#endif |
|
// PLUGIN.DLL Sliders: This method will unregister the "slider" class used in dialogs. |
#ifdef use_plugin_dll_sliders |
typedef BOOL(__cdecl* f_UnRegisterSlider)(HINSTANCE hInstanceDll); |
BOOL UnRegisterSlider(HINSTANCE hInstanceDll) { |
f_UnRegisterSlider fUnRegisterSlider; |
BOOL res; |
|
if (!gdata->pluginDllSliderInfo.hLib) return false; |
fUnRegisterSlider = (f_UnRegisterSlider)(void*)GetProcAddress(gdata->pluginDllSliderInfo.hLib, "UnRegisterSlider"); |
if (!gdata->libPluginDll) return false; |
fUnRegisterSlider = (f_UnRegisterSlider)(void*)GetProcAddress(gdata->libPluginDll, "UnRegisterSlider"); |
res = (fUnRegisterSlider != 0) ? fUnRegisterSlider(hInstanceDll) : false; |
return res; |
} |
#endif |
|
// PLUGIN.DLL Sliders: Set slider range (min/max) |
#ifdef use_plugin_dll_sliders |
typedef int(__cdecl* f_SetSliderRange)(HWND hWnd, int nMin, int nMax); |
int SetSliderRange(HWND hWnd, int nMin, int nMax) { |
f_SetSliderRange fSetSliderRange; |
int res; |
|
if (!gdata->pluginDllSliderInfo.hLib) return 0; |
fSetSliderRange = (f_SetSliderRange)(void*)GetProcAddress(gdata->pluginDllSliderInfo.hLib, "SetSliderRange"); |
if (!gdata->libPluginDll) return 0; |
fSetSliderRange = (f_SetSliderRange)(void*)GetProcAddress(gdata->libPluginDll, "SetSliderRange"); |
res = (fSetSliderRange != 0) ? fSetSliderRange(hWnd, nMin, nMax) : 0; |
return res; |
} |
#endif |
|
// PLUGIN.DLL Sliders : Sets slider position |
#ifdef use_plugin_dll_sliders |
typedef int(__cdecl* f_SetSliderPos)(HWND hWnd, int nPos, BOOL bRepaint); |
int SetSliderPos(HWND hWnd, int nPos, BOOL bRepaint) { |
f_SetSliderPos fSetSliderPos; |
int res; |
|
if (!gdata->pluginDllSliderInfo.hLib) return 0; |
fSetSliderPos = (f_SetSliderPos)(void*)GetProcAddress(gdata->pluginDllSliderInfo.hLib, "SetSliderPos"); |
if (!gdata->libPluginDll) return 0; |
fSetSliderPos = (f_SetSliderPos)(void*)GetProcAddress(gdata->libPluginDll, "SetSliderPos"); |
res = (fSetSliderPos != 0) ? fSetSliderPos(hWnd, nPos, bRepaint) : 0; |
return res; |
} |
#else |
int SetSliderPos(HWND hWnd, int nPos, BOOL bRepaint) { |
// This dummy is required, otherwise ui_compat.h won't compile |
return 0; |
} |
#endif |
|
// PLUGIN.DLL Sliders : Get slider position |
#ifdef use_plugin_dll_sliders |
typedef int(__cdecl* f_GetSliderPos)(HWND hWnd, BOOL bPixelPosition); |
int GetSliderPos(HWND hWnd, BOOL bPixelPosition) { |
f_GetSliderPos fGetSliderPos; |
int res; |
|
if (!gdata->pluginDllSliderInfo.hLib) return 0; |
fGetSliderPos = (f_GetSliderPos)(void*)GetProcAddress(gdata->pluginDllSliderInfo.hLib, "GetSliderPos"); |
if (!gdata->libPluginDll) return 0; |
fGetSliderPos = (f_GetSliderPos)(void*)GetProcAddress(gdata->libPluginDll, "GetSliderPos"); |
res = (fGetSliderPos != 0) ? fGetSliderPos(hWnd, bPixelPosition) : 0; |
return res; |
} |
#else |
int GetSliderPos(HWND hWnd, BOOL bPixelPosition) { |
// This dummy is required, otherwise ui_compat.h won't compile |
return 0; |
} |
#endif |
|
LRESULT CALLBACK DummyWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { |
return DefWindowProc(hwnd, uMsg, wParam, lParam); |
184,26 → 164,22 |
#ifndef use_plugin_dll_sliders |
return false; |
#else |
if (gdata->pluginDllSliderInfo.initialized) return true; |
if (gdata->pluginDllSliderInitialized) return true; |
|
if (!gdata->pluginDllSliderInfo.hLib) { |
if (!gdata->libPluginDll) { |
// DM 16.04.2022 : It is important that PLUGIN.DLL stays loaded, otherwise |
// DialogBoxParamA crashes. Can be reproduced if all 8BX modules are disabled in Photoshop 7 |
// (they keep PLUGIN.DLL loaded). |
gdata->pluginDllSliderInfo.hLib = LoadLibrary(TEXT("Plugin.dll")); |
gdata->libPluginDll = LoadLibrary(TEXT("Plugin.dll")); |
} |
|
if (gdata->pluginDllSliderInfo.hLib && RegisterSlider(hDllInstance, &gdata->pluginDllSliderInfo.messageId)) { |
if (gdata->libPluginDll && RegisterSlider(hDllInstance, &gdata->pluginDllSliderMessageId)) { |
gdata->pluginDllSliderInitialized = true; |
|
// Make "FoundrySlider" a subclass of "slider" then |
if (MakeSimpleSubclass(targetClass, TEXT("slider"))) { |
gdata->pluginDllSliderInfo.initialized = true; |
return true; |
return MakeSimpleSubclass(targetClass, TEXT("slider")); |
} |
else { |
return false; |
} |
} |
else { |
// This can happen if PLUGIN.DLL is not existing |
// It will also happen if a previous uninitialization failed (or was forgotten) |
return false; // Fall back to Windows sliders |
216,20 → 192,21 |
#ifndef use_plugin_dll_sliders |
return; |
#else |
if (!gdata->pluginDllSliderInfo.initialized) return; |
if (gdata->pluginDllSliderInitialized) { |
if (UnRegisterSlider(hDllInstance)) { |
gdata->pluginDllSliderInitialized = false; |
|
if (!UnRegisterSlider(hDllInstance)) { |
if (gdata->libPluginDll) { |
FreeLibrary(gdata->libPluginDll); |
gdata->libPluginDll = 0; |
} |
} |
else { |
simplealert((TCHAR*)TEXT("UnRegisterSlider failed")); |
return; |
} |
|
gdata->pluginDllSliderInfo.initialized = false; |
|
if (gdata->pluginDllSliderInfo.hLib) { |
FreeLibrary(gdata->pluginDllSliderInfo.hLib); |
gdata->pluginDllSliderInfo.hLib = 0; |
} |
#endif |
|
} |
|
typedef void(__stdcall* f_InitCommonControls)(); |
238,14 → 215,12 |
f_InitCommonControls fInitCommonControls; |
f_InitCommonControlsEx fInitCommonControlsEx; |
|
if (gdata->comctlSliderInfo.initialized) return true; |
|
// Make sure that Comctl32 is loaded |
if (!gdata->comctlSliderInfo.hLib) { |
gdata->comctlSliderInfo.hLib = LoadLibrary(TEXT("Comctl32.dll")); |
if (!gdata->libComctl32) { |
gdata->libComctl32 = LoadLibrary(TEXT("Comctl32.dll")); |
} |
if (gdata->comctlSliderInfo.hLib) { |
fInitCommonControlsEx = (f_InitCommonControlsEx)(void*)GetProcAddress(gdata->comctlSliderInfo.hLib, "InitCommonControlsEx"); |
if (gdata->libComctl32) { |
fInitCommonControlsEx = (f_InitCommonControlsEx)(void*)GetProcAddress(gdata->libComctl32, "InitCommonControlsEx"); |
if (fInitCommonControlsEx != 0) { |
INITCOMMONCONTROLSEX icce; |
icce.dwSize = sizeof(INITCOMMONCONTROLSEX); |
253,7 → 228,7 |
fInitCommonControlsEx(&icce); |
} |
else { |
fInitCommonControls = (f_InitCommonControls)(void*)GetProcAddress(gdata->comctlSliderInfo.hLib, "InitCommonControls"); |
fInitCommonControls = (f_InitCommonControls)(void*)GetProcAddress(gdata->libComctl32, "InitCommonControls"); |
if (fInitCommonControls != 0) { |
fInitCommonControls(); |
} |
260,46 → 235,25 |
} |
|
// Make "FoundrySlider" a subclass of "msctls_trackbar32" then |
if (MakeSimpleSubclass(targetClass, TEXT("msctls_trackbar32"))) { |
gdata->comctlSliderInfo.initialized = true; |
return true; |
return MakeSimpleSubclass(targetClass, TEXT("msctls_trackbar32")); |
} |
else { |
return false; |
} |
} |
else { |
return false; |
} |
} |
|
void Slider_Uninit_MsTrackbar() { |
if (!gdata->comctlSliderInfo.initialized) return; |
|
gdata->comctlSliderInfo.initialized = false; |
|
if (gdata->comctlSliderInfo.hLib != 0) { |
FreeLibrary(gdata->comctlSliderInfo.hLib); |
gdata->comctlSliderInfo.hLib = 0; |
if (gdata->libComctl32 != 0) { |
FreeLibrary(gdata->libComctl32); |
gdata->libComctl32 = 0; |
} |
} |
|
Boolean Slider_Init_None(LPCTSTR targetClass) { |
// Make "FoundrySlider" a subclass of "STATIC" (making it invisible) |
|
if (gdata->noneSliderInfo.initialized) return true; |
|
if (MakeSimpleSubclass(targetClass, WC_STATIC)) { |
gdata->noneSliderInfo.initialized = true; |
return true; |
return MakeSimpleSubclass(targetClass, WC_STATIC); |
} |
else { |
return false; |
} |
} |
|
void Slider_Uninit_None() { |
if (!gdata->noneSliderInfo.initialized) return; |
|
// Nothing here |
} |