Rev 417 | Rev 420 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 417 | Rev 419 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | #include "version.h" |
32 | #include "version.h" |
33 | 33 | ||
34 | HWND preview_hwnd; |
34 | HWND preview_hwnd; |
35 | HCURSOR hCurHandOpen; |
35 | HCURSOR hCurHandOpen; |
36 | HCURSOR hCurHandGrab; |
36 | HCURSOR hCurHandGrab; |
- | 37 | ||
37 | HCURSOR hCurHandQuestion; |
38 | HCURSOR hCurHandQuestion; |
38 | HCURSOR hCurHandPoint; |
39 | HICON hIconCautionSign; |
39 | 40 | ||
40 | extern HINSTANCE hDllInstance; |
41 | extern HINSTANCE hDllInstance; |
41 | 42 | ||
42 | void DoAbout(AboutRecordPtr pb){ |
43 | void DoAbout(AboutRecordPtr pb){ |
43 | char text[1000]; |
44 | char text[1000]; |
Line 194... | Line 195... | ||
194 | hfnt = GetStockObject(ANSI_FIXED_FONT); |
195 | hfnt = GetStockObject(ANSI_FIXED_FONT); |
195 | 196 | ||
196 | hCurHandOpen = LoadCursor(hDllInstance, "HAND_OPEN"); |
197 | hCurHandOpen = LoadCursor(hDllInstance, "HAND_OPEN"); |
197 | hCurHandGrab = LoadCursor(hDllInstance, "HAND_GRAB"); |
198 | hCurHandGrab = LoadCursor(hDllInstance, "HAND_GRAB"); |
198 | hCurHandQuestion = LoadCursor(hDllInstance, "HAND_QUESTION"); |
199 | hCurHandQuestion = LoadCursor(hDllInstance, "HAND_QUESTION"); |
199 | hCurHandPoint = LoadCursor(NULL, IDC_HAND); |
- | |
200 | 200 | ||
- | 201 | hIconCautionSign = LoadIcon(hDllInstance, "CAUTION_ICO"); |
|
- | 202 | ||
- | 203 | // Note: The whole class "Preview" gets the mouse cursor, not just the single item! |
|
201 | preview_hwnd = GetDlgItem(hDlg, PREVIEWITEM); |
204 | preview_hwnd = GetDlgItem(hDlg, PREVIEWITEM); |
202 | GetClientRect(preview_hwnd, &preview_rect); |
205 | GetClientRect(preview_hwnd, &preview_rect); |
203 | SetClassLongPtr(preview_hwnd, GCLP_HCURSOR, (LONG_PTR)hCurHandOpen); |
206 | SetClassLongPtr(preview_hwnd, GCLP_HCURSOR, (LONG_PTR)hCurHandOpen); |
204 | 207 | ||
- | 208 | // Note: The whole class "Caution" gets the mouse cursor, not just the single item! |
|
205 | SetClassLongPtr(GetDlgItem(hDlg, FIRSTICONITEM), GCLP_HCURSOR, (LONG_PTR)hCurHandQuestion); |
209 | SetClassLongPtr(GetDlgItem(hDlg, FIRSTICONITEM), GCLP_HCURSOR, (LONG_PTR)hCurHandQuestion); |
206 | 210 | ||
207 | for(i = 0; i < 4; ++i){ |
211 | for(i = 0; i < 4; ++i){ |
208 | // If Visual Themes are applied, SS_ICON will be ignored for controls which are not exactly "STATIC" class. |
- | |
209 | // Our derivated "CautionSign" class won't work. So we need to set the icon explicitly. |
- | |
210 | SendDlgItemMessage(hDlg, FIRSTICONITEM+i, STM_SETICON, (WPARAM)LoadImage(hDllInstance, "CAUTION_ICO",IMAGE_ICON,16,16, LR_DEFAULTCOLOR), 0); |
- | |
211 | CreateToolTip(FIRSTICONITEM + i, hDlg, _strdup("Syntax error! Click to see details.")); |
212 | CreateToolTip(FIRSTICONITEM + i, hDlg, _strdup("Error in expression! Click to see details.")); |
212 | } |
213 | } |
213 | 214 | ||
214 | CreateToolTip(ZOOMINITEM, hDlg, _strdup("Zoom in")); |
215 | CreateToolTip(ZOOMINITEM, hDlg, _strdup("Zoom in")); |
215 | CreateToolTip(ZOOMOUTITEM, hDlg, _strdup("Zoom out")); |
216 | CreateToolTip(ZOOMOUTITEM, hDlg, _strdup("Zoom out")); |
216 | CreateToolTip(ZOOMLEVELITEM, hDlg, _strdup("Fully zoom in/out")); |
217 | CreateToolTip(ZOOMLEVELITEM, hDlg, _strdup("Fully zoom in/out")); |
217 | 218 | ||
218 | // Note: Actually, the whole class gets the cursor, not just these three controls!! |
- | |
219 | if (hCurHandPoint) { |
- | |
220 | SetClassLongPtr(GetDlgItem(hDlg, ZOOMINITEM), GCLP_HCURSOR, (LONG_PTR)hCurHandPoint); |
- | |
221 | SetClassLongPtr(GetDlgItem(hDlg, ZOOMOUTITEM), GCLP_HCURSOR, (LONG_PTR)hCurHandPoint); |
- | |
222 | SetClassLongPtr(GetDlgItem(hDlg, ZOOMLEVELITEM), GCLP_HCURSOR, (LONG_PTR)hCurHandPoint); |
- | |
223 | } |
- | |
224 | - | ||
225 | for(i = 0; i < 8; ++i){ |
219 | for(i = 0; i < 8; ++i){ |
226 | SendDlgItemMessage(hDlg,FIRSTCTLITEM+i, TBM_SETRANGE,TRUE,MAKELONG(0,255)); |
220 | SendDlgItemMessage(hDlg,FIRSTCTLITEM+i, TBM_SETRANGE,TRUE,MAKELONG(0,255)); |
227 | SendDlgItemMessage(hDlg,FIRSTCTLITEM+i, TBM_SETTICFREQ,SLIDERPAGE,0); |
221 | SendDlgItemMessage(hDlg,FIRSTCTLITEM+i, TBM_SETTICFREQ,SLIDERPAGE,0); |
228 | SendDlgItemMessage(hDlg,FIRSTCTLITEM+i, TBM_SETPAGESIZE,0,SLIDERPAGE); |
222 | SendDlgItemMessage(hDlg,FIRSTCTLITEM+i, TBM_SETPAGESIZE,0,SLIDERPAGE); |
229 | SendDlgItemMessage(hDlg,FIRSTCTLTEXTITEM+i, EM_SETLIMITTEXT,3,0); |
223 | SendDlgItemMessage(hDlg,FIRSTCTLTEXTITEM+i, EM_SETLIMITTEXT,3,0); |
Line 238... | Line 232... | ||
238 | case WM_DESTROY: |
232 | case WM_DESTROY: |
239 | gdata->hWndMainDlg = 0; |
233 | gdata->hWndMainDlg = 0; |
240 | DestroyCursor(hCurHandOpen); |
234 | DestroyCursor(hCurHandOpen); |
241 | DestroyCursor(hCurHandGrab); |
235 | DestroyCursor(hCurHandGrab); |
242 | DestroyCursor(hCurHandQuestion); |
236 | DestroyCursor(hCurHandQuestion); |
- | 237 | DestroyIcon(hIconCautionSign); |
|
243 | break; |
238 | break; |
244 | case WM_DRAWITEM: |
239 | case WM_DRAWITEM: |
245 | pdi = (DRAWITEMSTRUCT*)lParam; |
240 | pdi = (DRAWITEMSTRUCT*)lParam; |
246 | if(pdi->itemAction == ODA_DRAWENTIRE){ |
241 | if(pdi->itemAction == ODA_DRAWENTIRE){ |
247 | switch(pdi->CtlID){ |
242 | switch(pdi->CtlID){ |
248 | case PREVIEWITEM: |
243 | case PREVIEWITEM: |
249 | drawpreview(hDlg,pdi->hDC,PILOCKHANDLE(preview_handle,false)); |
244 | drawpreview(hDlg,pdi->hDC,PILOCKHANDLE(preview_handle,false)); |
250 | PIUNLOCKHANDLE(preview_handle); |
245 | PIUNLOCKHANDLE(preview_handle); |
251 | break; |
246 | break; |
- | 247 | case FIRSTICONITEM: |
|
- | 248 | case FIRSTICONITEM + 1: |
|
- | 249 | case FIRSTICONITEM + 2: |
|
- | 250 | case FIRSTICONITEM + 3: |
|
- | 251 | DrawIcon(pdi->hDC, 0, 0, hIconCautionSign); |
|
- | 252 | break; |
|
252 | default: |
253 | default: |
253 | return false; |
254 | return false; |
254 | } |
255 | } |
255 | }else |
256 | }else |
256 | return false; // we couldn't handle the message |
257 | return false; // we couldn't handle the message |
257 | break; |
258 | break; |
258 | case WM_COMMAND: |
259 | case WM_COMMAND: |
259 | item = LOWORD(wParam); |
260 | item = LOWORD(wParam); |
260 | switch(HIWORD(wParam)){ |
261 | switch(HIWORD(wParam)){ |
261 | case BN_CLICKED: //case STN_CLICKED: |
262 | //case BN_CLICKED: |
- | 263 | case STN_CLICKED: |
|
- | 264 | // BN_CLICKED = Button clicked |
|
- | 265 | // STN_CLICKED = Static controls with SS_NOTIFY clicked |
|
- | 266 | // Both have the same ordinal number |
|
262 | if(item==PREVIEWITEM && GetCursorPos(&origpos)){ |
267 | if(item==PREVIEWITEM && GetCursorPos(&origpos)){ |
263 | panning = true; |
268 | panning = true; |
264 | origscroll = preview_scroll; |
269 | origscroll = preview_scroll; |
265 | SetCursor(hCurHandGrab); |
270 | SetCursor(hCurHandGrab); |
266 | SetCapture(hDlg); |
271 | SetCapture(hDlg); |
Line 307... | Line 312... | ||
307 | // ALL Versions of Windows show the confusing error message "Invalid Cursor Handle" when DialogBoxParamA |
312 | // ALL Versions of Windows show the confusing error message "Invalid Cursor Handle" when DialogBoxParamA |
308 | // tries to open a dialog with a control which class is unknown. |
313 | // tries to open a dialog with a control which class is unknown. |
309 | // "msctls_trackbar32" is not included in Windows NT 3.1, and since there is no OCX or RegSvr32, |
314 | // "msctls_trackbar32" is not included in Windows NT 3.1, and since there is no OCX or RegSvr32, |
310 | // there seems no possibility to support this version of Windows at this point. |
315 | // there seems no possibility to support this version of Windows at this point. |
311 | if (GetClassInfo(hDllInstance, "msctls_trackbar32", &clx) == 0) { |
316 | if (GetClassInfo(hDllInstance, "msctls_trackbar32", &clx) == 0) { |
312 | simplealert("This plugin requires the Microsoft Trackbar Control (msctls_trackbar32) which is not found on your system."); |
317 | //simplealert(_strdup("This plugin requires the Microsoft Trackbar Control (msctls_trackbar32) which was not found on your system.")); |
313 | return false; |
318 | //return false; |
314 | } |
- | |
315 | 319 | ||
316 | // For the preview image, we register a class, so that we can assign a mouse cursor to this class. |
320 | // We simply hide the sliders and let the user enter the numeric values in the edit-box. |
- | 321 | // At least the plugin runs on Windows NT 3.1 ! |
|
- | 322 | simplewarning(_strdup("Visual sliders are not available because the Microsoft Trackbar Control (msctls_trackbar32) was not found on your system.")); |
|
317 | GetClassInfo(hDllInstance, "STATIC", &clx); |
323 | GetClassInfo(hDllInstance, "STATIC", &clx); |
318 | clx.lpszClassName = "Preview"; |
324 | clx.lpszClassName = "msctls_trackbar32"; |
319 | if (RegisterClass(&clx) == 0) { |
325 | if (RegisterClass(&clx) == 0) { |
320 | char s[100]; |
326 | char s[100]; |
321 | strcpy(s, "RegisterClass failed: "); |
327 | strcpy(s, "RegisterClass failed: "); |
322 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL); |
328 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL); |
323 | dbg(s); |
329 | dbg(s); |
324 | } |
330 | } |
- | 331 | } |
|
325 | 332 | ||
326 | // For the caution images, we register a class, so that we can assign a mouse cursor to this class. |
333 | // For the preview image and caution symbols, we register a class, so that we can assign a mouse cursor to this class. |
327 | GetClassInfo(hDllInstance, "STATIC", &clx); |
334 | GetClassInfo(hDllInstance, "STATIC", &clx); |
- | 335 | clx.lpszClassName = "Preview"; |
|
- | 336 | if (RegisterClass(&clx) == 0) { |
|
- | 337 | char s[100]; |
|
- | 338 | strcpy(s, "RegisterClass failed: "); |
|
- | 339 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL); |
|
- | 340 | dbg(s); |
|
- | 341 | } |
|
- | 342 | GetClassInfo(hDllInstance, "Button", &clx); |
|
328 | clx.lpszClassName = "CautionSign"; |
343 | clx.lpszClassName = "Caution"; |
329 | if (RegisterClass(&clx) == 0) { |
344 | if (RegisterClass(&clx) == 0) { |
330 | char s[100]; |
345 | char s[100]; |
331 | strcpy(s, "RegisterClass failed: "); |
346 | strcpy(s, "RegisterClass failed: "); |
332 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL); |
347 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL); |
333 | dbg(s); |
348 | dbg(s); |
334 | } |
349 | } |
335 | 350 | ||
336 | // Now show the dialog |
351 | // Now show the dialog |
337 | p = (PlatformData*)pb->platformData; |
352 | p = (PlatformData*)pb->platformData; |
- | 353 | ||
- | 354 | // Note: "Invalid Cursor Handle" is the error when an unrecognized control class is detected |
|
338 | res = DialogBoxParam(hDllInstance,MAKEINTRESOURCE(gdata->standalone ? ID_PARAMDLG : ID_MAINDLG), |
355 | res = DialogBoxParam(hDllInstance,MAKEINTRESOURCE(gdata->standalone ? ID_PARAMDLG : ID_MAINDLG), |
339 | (HWND)p->hwnd,maindlgproc,0); |
356 | (HWND)p->hwnd,maindlgproc,0); |
340 | if (res == 0) { |
357 | if (res == 0) { |
341 | simplealert("DialogBoxParam in valid parent window handle"); |
358 | simplealert(_strdup("DialogBoxParam in valid parent window handle")); |
342 | } |
359 | } |
343 | if (res == -1) { |
360 | if (res == -1) { |
344 | char s[100]; |
361 | char s[100]; |
345 | strcpy(s, "DialogBoxParam failed: "); |
362 | strcpy(s, "DialogBoxParam failed: "); |
346 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL); |
363 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL); |
347 | dbg(s); |
364 | dbg(s); |
348 | } |
365 | } |
349 | 366 | ||
350 | // Clean up after the dialog has been closed |
367 | // Clean up after the dialog has been closed |
351 | UnregisterClass("Preview", hDllInstance); |
368 | UnregisterClass("Preview", hDllInstance); |
352 | UnregisterClass("CautionSign", hDllInstance); |
369 | UnregisterClass("Caution", hDllInstance); |
353 | 370 | ||
354 | return res == IDOK; |
371 | return res == IDOK; |
355 | } |
372 | } |
356 | 373 |