Rev 443 | Rev 454 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 443 | Rev 444 | ||
---|---|---|---|
Line 95... | Line 95... | ||
95 | else { |
95 | else { |
96 | return 0; |
96 | return 0; |
97 | } |
97 | } |
98 | } |
98 | } |
99 | 99 | ||
100 | Boolean MakeSimpleSubclass(LPCSTR targetClass, LPCSTR sourceClass) { |
100 | Boolean MakeSimpleSubclass(LPCTSTR targetClass, LPCTSTR sourceClass) { |
101 | WNDCLASS clx; |
101 | WNDCLASS clx; |
102 | 102 | ||
103 | if (GetClassInfoA(hDllInstance, sourceClass, &clx) != 0) { |
103 | if (GetClassInfo(hDllInstance, sourceClass, &clx) != 0) { |
104 | clx.lpszClassName = targetClass; |
104 | clx.lpszClassName = targetClass; |
105 | if (RegisterClass(&clx) == 0) { |
105 | if (RegisterClass(&clx) == 0) { |
106 | char s[100]; |
106 | TCHAR s[0x300]; |
107 | strcpy(s, "RegisterClass failed: "); |
107 | xstrcpy(s, (TCHAR*)TEXT("RegisterClass failed: ")); |
108 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL); |
108 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + xstrlen(s), 0x300 - xstrlen(s), NULL); |
109 | dbg(s); |
109 | dbg(&s[0]); |
110 | return false; |
110 | return false; |
111 | } |
111 | } |
112 | else { |
112 | else { |
113 | return true; |
113 | return true; |
114 | } |
114 | } |
Line 123... | Line 123... | ||
123 | #ifndef use_plugin_dll_sliders |
123 | #ifndef use_plugin_dll_sliders |
124 | return; |
124 | return; |
125 | #else |
125 | #else |
126 | WNDCLASS clx; |
126 | WNDCLASS clx; |
127 | 127 | ||
128 | if (GetClassInfo(hDllInstance, "slider", &clx) != 0) { |
128 | if (GetClassInfo(hDllInstance, TEXT("slider"), &clx) != 0) { |
129 | UnregisterSlider(hDllInstance); |
129 | UnregisterSlider(hDllInstance); |
130 | } |
130 | } |
131 | if (gdata->pluginDllModule) { |
131 | if (gdata->pluginDllModule) { |
132 | FreeLibrary(gdata->pluginDllModule); |
132 | FreeLibrary(gdata->pluginDllModule); |
133 | gdata->pluginDllModule = 0; |
133 | gdata->pluginDllModule = 0; |
134 | } |
134 | } |
135 | #endif |
135 | #endif |
136 | 136 | ||
137 | } |
137 | } |
138 | 138 | ||
139 | Boolean Slider_Init_PluginDll(LPCSTR targetClass) { |
139 | Boolean Slider_Init_PluginDll(LPCTSTR targetClass) { |
140 | 140 | ||
141 | #ifndef use_plugin_dll_sliders |
141 | #ifndef use_plugin_dll_sliders |
142 | return false; |
142 | return false; |
143 | #else |
143 | #else |
144 | DWORD sliderMsgId; |
144 | DWORD sliderMsgId; |
145 | 145 | ||
146 | // Try loading PLUGIN.DLL (only Photoshop) in order to register the class "slider" |
146 | // Try loading PLUGIN.DLL (only Photoshop) in order to register the class "slider" |
147 | gdata->pluginDllModule = LoadLibraryA("PLUGIN.DLL"); |
147 | gdata->pluginDllModule = LoadLibrary(TEXT("PLUGIN.DLL")); |
148 | if (!gdata->pluginDllModule) return false; |
148 | if (!gdata->pluginDllModule) return false; |
149 | sliderMsgId = 0; // important |
149 | sliderMsgId = 0; // important |
150 | RegisterSlider(hDllInstance, &sliderMsgId); |
150 | RegisterSlider(hDllInstance, &sliderMsgId); |
151 | if (sliderMsgId != 0) { |
151 | if (sliderMsgId != 0) { |
152 | // RegisterSlider will "remember" if it gave you a message ID before, |
152 | // RegisterSlider will "remember" if it gave you a message ID before, |
Line 156... | Line 156... | ||
156 | // So, we keep the message ID in the global (persistant) data, so we remember it. |
156 | // So, we keep the message ID in the global (persistant) data, so we remember it. |
157 | gdata->pluginDllSliderMessageId = sliderMsgId; |
157 | gdata->pluginDllSliderMessageId = sliderMsgId; |
158 | } |
158 | } |
159 | 159 | ||
160 | // Make "FoundrySlider" a subclass of "slider" then |
160 | // Make "FoundrySlider" a subclass of "slider" then |
161 | return MakeSimpleSubclass(targetClass, "slider"); |
161 | return MakeSimpleSubclass(targetClass, TEXT("slider")); |
162 | #endif |
162 | #endif |
163 | 163 | ||
164 | } |
164 | } |
165 | 165 | ||
166 | typedef void(__stdcall* f_InitCommonControls)(); |
166 | typedef void(__stdcall* f_InitCommonControls)(); |
167 | typedef BOOL(__stdcall* f_InitCommonControlsEx)(const INITCOMMONCONTROLSEX* picce); |
167 | typedef BOOL(__stdcall* f_InitCommonControlsEx)(const INITCOMMONCONTROLSEX* picce); |
168 | Boolean Slider_Init_MsTrackbar(LPCSTR targetClass) { |
168 | Boolean Slider_Init_MsTrackbar(LPCTSTR targetClass) { |
169 | f_InitCommonControls fInitCommonControls; |
169 | f_InitCommonControls fInitCommonControls; |
170 | f_InitCommonControlsEx fInitCommonControlsEx; |
170 | f_InitCommonControlsEx fInitCommonControlsEx; |
171 | HMODULE libComctl32; |
171 | HMODULE libComctl32; |
172 | 172 | ||
173 | // Make sure that Comctl32 is loaded |
173 | // Make sure that Comctl32 is loaded |
174 | libComctl32 = LoadLibraryA("Comctl32.dll"); |
174 | libComctl32 = LoadLibrary(TEXT("Comctl32.dll")); |
175 | if (libComctl32) { |
175 | if (libComctl32) { |
176 | fInitCommonControlsEx = (f_InitCommonControlsEx)(void*)GetProcAddress(libComctl32, "InitCommonControlsEx"); |
176 | fInitCommonControlsEx = (f_InitCommonControlsEx)(void*)GetProcAddress(libComctl32, "InitCommonControlsEx"); |
177 | if (fInitCommonControlsEx != 0) { |
177 | if (fInitCommonControlsEx != 0) { |
178 | INITCOMMONCONTROLSEX icce; |
178 | INITCOMMONCONTROLSEX icce; |
179 | icce.dwSize = sizeof(INITCOMMONCONTROLSEX); |
179 | icce.dwSize = sizeof(INITCOMMONCONTROLSEX); |
Line 193... | Line 193... | ||
193 | // Isn't that a contradiction? |
193 | // Isn't that a contradiction? |
194 | //FreeLibrary(libComctl32); |
194 | //FreeLibrary(libComctl32); |
195 | } |
195 | } |
196 | 196 | ||
197 | // Make "FoundrySlider" a subclass of "msctls_trackbar32" then |
197 | // Make "FoundrySlider" a subclass of "msctls_trackbar32" then |
198 | return MakeSimpleSubclass(targetClass, "msctls_trackbar32"); |
198 | return MakeSimpleSubclass(targetClass, TEXT("msctls_trackbar32")); |
199 | } |
199 | } |
200 | 200 | ||
201 | Boolean Slider_Init_None(LPCSTR targetClass) { |
201 | Boolean Slider_Init_None(LPCTSTR targetClass) { |
202 | // Make "FoundrySlider" a subclass of "STATIC" (making it invisible) |
202 | // Make "FoundrySlider" a subclass of "STATIC" (making it invisible) |
203 | return MakeSimpleSubclass(targetClass, "STATIC"); |
203 | return MakeSimpleSubclass(targetClass, TEXT("STATIC")); |
204 | } |
204 | } |