Subversion Repositories filter_foundry

Rev

Rev 459 | Rev 461 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
259 daniel-mar 1
/*
2
    This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
3
    Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.com.au
4
    Copyright (C) 2018-2021 Daniel Marschall, ViaThinkSoft
5
 
6
    This program is free software; you can redistribute it and/or modify
7
    it under the terms of the GNU General Public License as published by
8
    the Free Software Foundation; either version 2 of the License, or
9
    (at your option) any later version.
10
 
11
    This program is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU General Public License for more details.
15
 
16
    You should have received a copy of the GNU General Public License
17
    along with this program; if not, write to the Free Software
18
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
*/
20
 
21
/* Win32 user interface routines */
22
 
23
#include "world.h"
24
 
25
#include "PIAbout.h"
26
 
27
#include <windows.h>
28
#include <commctrl.h>
29
 
30
#include "ff.h"
439 daniel-mar 31
#include "slider_win.h"
259 daniel-mar 32
#include "version.h"
33
 
34
HWND preview_hwnd;
35
HCURSOR hCurHandOpen;
36
HCURSOR hCurHandGrab;
419 daniel-mar 37
 
259 daniel-mar 38
HCURSOR hCurHandQuestion;
419 daniel-mar 39
HICON hIconCautionSign;
259 daniel-mar 40
 
41
extern HINSTANCE hDllInstance;
42
 
43
void DoAbout(AboutRecordPtr pb){
44
        char text[1000];
45
        char title[200];
46
        PlatformData *p = (PlatformData*)pb->platformData;
47
 
48
        if (gdata && gdata->standalone) {
393 daniel-mar 49
                sprintf(title, "About %s", gdata->parm.szTitle);
259 daniel-mar 50
                sprintf(text,  "%s by %s\n" /* {Title} by {Author} */
51
                               "%s\n" /* {Copyright} */
52
                               "\n"
53
                               "This plugin was built using Filter Foundry " VERSION_STR
268 daniel-mar 54
                                #ifdef _WIN64
259 daniel-mar 55
                               " (64 bit)\n"
268 daniel-mar 56
                                #else
259 daniel-mar 57
                               " (32 bit)\n"
268 daniel-mar 58
                                #endif
259 daniel-mar 59
                               "(C) 2003-2009 Toby Thain, 2018-" RELEASE_YEAR " Daniel Marschall\n"
60
                               "available from " PROJECT_URL,
393 daniel-mar 61
                               gdata->parm.szTitle,
62
                               gdata->parm.szAuthor,
63
                               gdata->parm.szCopyright);
259 daniel-mar 64
        } else {
65
                sprintf(title, "About Filter Foundry");
66
                sprintf(text,  "Filter Foundry " VERSION_STR
268 daniel-mar 67
                                #ifdef _WIN64
259 daniel-mar 68
                               " (64 bit)\n"
268 daniel-mar 69
                                #else
259 daniel-mar 70
                               " (32 bit)\n"
268 daniel-mar 71
                                #endif
259 daniel-mar 72
                               "(C) 2003-2009 Toby Thain, 2018-" RELEASE_YEAR " Daniel Marschall\n"
73
                               "\n"
74
                               "Latest version available from\n"
75
                               PROJECT_URL "\n"
76
                               "\nPlease contact the author with any bug reports,\n"
77
                               "suggestions or comments.\n"
78
                               "If you use this program and like it, please consider\n"
79
                               "making a donation.");
80
        }
81
 
444 daniel-mar 82
        MessageBoxA((HWND)p->hwnd, text, title, MB_TASKMODAL|MB_ICONINFORMATION|MB_OK);
259 daniel-mar 83
}
84
 
444 daniel-mar 85
Boolean simplealert(TCHAR* s){
273 daniel-mar 86
        HWND hwnd;
456 daniel-mar 87
        TCHAR title[256] = { 0 };
259 daniel-mar 88
        if (gdata && gdata->standalone) {
444 daniel-mar 89
                #ifdef UNICODE
90
                mbstowcs(&title[0], (const char*)gdata->parm.szTitle, 256);
91
                #else
92
                strcpy(&title[0], gdata->parm.szTitle);
93
                #endif
259 daniel-mar 94
        }
444 daniel-mar 95
        else {
96
                xstrcpy(&title[0], (TCHAR*)TEXT("Filter Foundry"));
97
        }
273 daniel-mar 98
        hwnd = gdata ? gdata->hWndMainDlg : NULL;
413 daniel-mar 99
        return MessageBox(hwnd, s, title, MB_TASKMODAL|MB_ICONERROR|MB_OK) == IDOK;
259 daniel-mar 100
}
101
 
444 daniel-mar 102
Boolean simplewarning(TCHAR* s) {
320 daniel-mar 103
        HWND hwnd;
456 daniel-mar 104
        TCHAR title[256] = { 0 };
320 daniel-mar 105
        if (gdata && gdata->standalone) {
444 daniel-mar 106
                #ifdef UNICODE
107
                mbstowcs(&title[0], (const char*)gdata->parm.szTitle, 256);
108
                #else
109
                strcpy(&title[0], gdata->parm.szTitle);
110
                #endif
393 daniel-mar 111
        } else {
444 daniel-mar 112
                xstrcpy(&title[0], (TCHAR*)TEXT("Filter Foundry"));
320 daniel-mar 113
        }
114
        hwnd = gdata ? gdata->hWndMainDlg : NULL;
115
        return MessageBox(hwnd,s,title,MB_TASKMODAL|MB_ICONEXCLAMATION|MB_OK) == IDOK;
116
}
117
 
444 daniel-mar 118
Boolean showmessage(TCHAR *s) {
273 daniel-mar 119
        HWND hwnd;
456 daniel-mar 120
        TCHAR title[256] = { 0 };
259 daniel-mar 121
        if (gdata && gdata->standalone) {
444 daniel-mar 122
                #ifdef UNICODE
123
                mbstowcs(&title[0], (const char*)gdata->parm.szTitle, 256);
124
                #else
125
                strcpy(&title[0], gdata->parm.szTitle);
126
                #endif
259 daniel-mar 127
        }
444 daniel-mar 128
        else {
129
                xstrcpy(&title[0], (TCHAR*)TEXT("Filter Foundry"));
130
        }
273 daniel-mar 131
        hwnd = gdata ? gdata->hWndMainDlg : NULL;
132
        return MessageBox(hwnd,s,title,MB_TASKMODAL|MB_ICONINFORMATION|MB_OK) == IDOK;
259 daniel-mar 133
}
134
 
135
INT_PTR CALLBACK maindlgproc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
136
 
353 daniel-mar 137
// Description:
393 daniel-mar 138
//   Creates a tooltip for an item in a dialog box.
353 daniel-mar 139
// Parameters:
140
//   idTool - identifier of an dialog box item.
141
//   nDlg - window handle of the dialog box.
142
//   pszText - string to use as the tooltip text.
143
// Returns:
144
//   The handle to the tooltip.
145
//
444 daniel-mar 146
HWND CreateToolTip(int toolID, HWND hDlg, LPTSTR pszText) {
354 daniel-mar 147
        // Source: https://docs.microsoft.com/en-us/windows/win32/controls/create-a-tooltip-for-a-control (modified)
393 daniel-mar 148
 
354 daniel-mar 149
        HWND hwndTool, hwndTip;
150
        TOOLINFO toolInfo;
151
 
353 daniel-mar 152
        if (!toolID || !hDlg || !pszText) {
153
                return FALSE;
154
        }
155
        // Get the window of the tool.
354 daniel-mar 156
        hwndTool = GetDlgItem(hDlg, toolID);
353 daniel-mar 157
 
158
        // Create the tooltip. g_hInst is the global instance handle.
354 daniel-mar 159
        hwndTip = CreateWindowEx(0, TOOLTIPS_CLASS, NULL,
353 daniel-mar 160
                WS_POPUP | TTS_ALWAYSTIP /* | TTS_BALLOON*/,
161
                CW_USEDEFAULT, CW_USEDEFAULT,
162
                CW_USEDEFAULT, CW_USEDEFAULT,
163
                hDlg, NULL,
164
                hDllInstance, NULL);
165
 
166
        if (!hwndTool || !hwndTip) {
167
                return (HWND)NULL;
168
        }
169
 
170
        // Associate the tooltip with the tool.
354 daniel-mar 171
        memset(&toolInfo, 0, sizeof(TOOLINFO)); // toolInfo = { 0 };
353 daniel-mar 172
        toolInfo.cbSize = sizeof(toolInfo);
173
        toolInfo.hwnd = hDlg;
174
        toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
175
        toolInfo.uId = (UINT_PTR)hwndTool;
176
        toolInfo.lpszText = pszText;
177
        SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
178
 
179
        return hwndTip;
180
}
181
 
445 daniel-mar 182
#define IDT_TIMER_INITPREVIEW_DRAW 1111
183
 
453 daniel-mar 184
WNDPROC lpControlEditWndProc[8];
185
 
186
LRESULT CALLBACK ControlTextWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
187
        extern Boolean doupdates;
188
        int sliderNum;
189
        for (sliderNum = 0; sliderNum < 8; sliderNum++) {
190
                if (hWnd == GetDlgItem(gdata->hWndMainDlg, FIRSTCTLTEXTITEM + sliderNum)) {
191
                        if ((uMsg == WM_KEYDOWN) && (wParam == VK_UP) && doupdates)
192
                        {
193
                                uint8_t sliderVal = slider[sliderNum] < 255 ? slider[sliderNum] + 1 : slider[sliderNum];
194
                                slider[sliderNum] = sliderVal;
195
 
196
                                SETCTLTEXTINT(gdata->hWndMainDlg, FIRSTCTLTEXTITEM + sliderNum, sliderVal, false);
197
                                REPAINTCTL(gdata->hWndMainDlg, FIRSTCTLTEXTITEM + sliderNum);
198
 
199
                                recalc_preview(gpb, gdata->hWndMainDlg);
200
 
201
                                return 0;
202
                        }
203
                        if ((uMsg == WM_KEYDOWN) && (wParam == VK_DOWN) && doupdates)
204
                        {
205
                                uint8_t sliderVal = slider[sliderNum] > 0 ? slider[sliderNum] - 1 : slider[sliderNum];
206
                                slider[sliderNum] = sliderVal;
207
 
208
                                SETCTLTEXTINT(gdata->hWndMainDlg, FIRSTCTLTEXTITEM + sliderNum, sliderVal, false);
209
                                REPAINTCTL(gdata->hWndMainDlg, FIRSTCTLTEXTITEM + sliderNum);
210
 
211
                                recalc_preview(gpb, gdata->hWndMainDlg);
212
 
213
                                return 0;
214
                        }
215
                        return CallWindowProc(lpControlEditWndProc[sliderNum], hWnd, uMsg, wParam, lParam);
216
                }
217
        }
218
        return 0; // should not happen
219
}
220
 
259 daniel-mar 221
INT_PTR CALLBACK maindlgproc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam){
222
        static POINT origpos;
223
        static Point origscroll;
224
        static Boolean panning = false;
225
 
226
        int item,i;
227
        POINT newpos;
228
        DRAWITEMSTRUCT *pdi;
456 daniel-mar 229
        Point newscroll = { 0, 0 };
259 daniel-mar 230
        HGDIOBJ hfnt;
231
 
232
        extern Boolean doupdates;
233
        extern Handle preview_handle;
234
 
460 daniel-mar 235
        WNDPROC wndProcStatic, wndProcButton;
236
 
427 daniel-mar 237
        if ((gdata->pluginDllSliderMessageId != 0) && (wMsg == gdata->pluginDllSliderMessageId)) {
422 daniel-mar 238
                // This is for the PLUGIN.DLL sliders only
239
                if (doupdates) {
444 daniel-mar 240
                        int sliderNum = (int)wParam - FIRSTCTLITEM;
454 daniel-mar 241
                        int sliderVal = (lParam & 0xFFFF);
453 daniel-mar 242
                        if (sliderVal < 0) sliderVal = 0;
456 daniel-mar 243
                        else if (sliderVal > 255) sliderVal = 255;
244
                        slider[sliderNum] = (uint8_t)sliderVal;
422 daniel-mar 245
 
246
                        SETCTLTEXTINT(hDlg, FIRSTCTLTEXTITEM + sliderNum, sliderVal, false);
247
                        REPAINTCTL(hDlg, FIRSTCTLTEXTITEM + sliderNum);
248
 
249
                        recalc_preview(gpb, hDlg);
250
                }
251
                return true;
252
        }
253
 
419 daniel-mar 254
        switch (wMsg) {
445 daniel-mar 255
        case WM_TIMER:
256
                switch (wParam)
257
                {
258
                case IDT_TIMER_INITPREVIEW_DRAW:
446 daniel-mar 259
                        KillTimer(hDlg, IDT_TIMER_INITPREVIEW_DRAW);
445 daniel-mar 260
                        recalc_preview(gpb, hDlg);
261
                        return 0;
262
                }
263
                break;
259 daniel-mar 264
        case WM_INITDIALOG:
265
                gdata->hWndMainDlg = hDlg;
266
 
267
                if(gdata->standalone){
444 daniel-mar 268
                        SetWindowTextA(hDlg,gdata->parm.szTitle); // window title bar
259 daniel-mar 269
                }
270
                centre_window(hDlg);
271
 
272
                hfnt = GetStockObject(ANSI_FIXED_FONT);
273
 
444 daniel-mar 274
                hCurHandOpen = LoadCursorA(hDllInstance, "HAND_OPEN");
275
                hCurHandGrab = LoadCursorA(hDllInstance, "HAND_GRAB");
276
                hCurHandQuestion = LoadCursorA(hDllInstance, "HAND_QUESTION");
259 daniel-mar 277
 
444 daniel-mar 278
                hIconCautionSign = LoadIconA(hDllInstance, "CAUTION_ICO");
419 daniel-mar 279
 
280
                // Note: The whole class "Preview" gets the mouse cursor, not just the single item!
259 daniel-mar 281
                preview_hwnd = GetDlgItem(hDlg, PREVIEWITEM);
282
                GetClientRect(preview_hwnd, &preview_rect);
283
                SetClassLongPtr(preview_hwnd, GCLP_HCURSOR, (LONG_PTR)hCurHandOpen);
284
 
419 daniel-mar 285
                // Note: The whole class "Caution" gets the mouse cursor, not just the single item!
259 daniel-mar 286
                SetClassLongPtr(GetDlgItem(hDlg, FIRSTICONITEM), GCLP_HCURSOR, (LONG_PTR)hCurHandQuestion);
287
 
288
                for(i = 0; i < 4; ++i){
444 daniel-mar 289
                        CreateToolTip(FIRSTICONITEM + i, hDlg, (TCHAR*)TEXT("Error in expression! Click to see details."));
259 daniel-mar 290
                }
291
 
444 daniel-mar 292
                CreateToolTip(ZOOMINITEM, hDlg, (TCHAR*)TEXT("Zoom in"));
293
                CreateToolTip(ZOOMOUTITEM, hDlg, (TCHAR*)TEXT("Zoom out"));
294
                CreateToolTip(ZOOMLEVELITEM, hDlg, (TCHAR*)TEXT("Fully zoom in/out"));
353 daniel-mar 295
 
259 daniel-mar 296
                for(i = 0; i < 8; ++i){
427 daniel-mar 297
                        if (gdata->pluginDllSliderMessageId == 0) {
422 daniel-mar 298
                                // Non PLUGIN.DLL sliders
299
                                SetWindowLongPtr(GetDlgItem(hDlg, FIRSTCTLITEM + i), GWL_STYLE, TBS_HORZ | TBS_AUTOTICKS | WS_CHILD | WS_VISIBLE);
300
                                SendDlgItemMessage(hDlg, FIRSTCTLITEM + i, TBM_SETRANGE, TRUE, MAKELONG(0, 255));
301
                                SendDlgItemMessage(hDlg, FIRSTCTLITEM + i, TBM_SETTICFREQ, SLIDERPAGE, 0);
302
                                SendDlgItemMessage(hDlg, FIRSTCTLITEM + i, TBM_SETPAGESIZE, 0, SLIDERPAGE);
303
                        }
304
                        else {
305
                                // PLUGIN.DLL sliders
306
                                SetSliderRange(GetDlgItem(hDlg, FIRSTCTLITEM + i), 0, 255);
307
                        }
259 daniel-mar 308
                        SendDlgItemMessage(hDlg,FIRSTCTLTEXTITEM+i,     EM_SETLIMITTEXT,3,0);
309
                }
310
                for(i = 0; i < 4; ++i){
311
                        SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i,        EM_SETLIMITTEXT,MAXEXPR-1,0); // we need 1 byte as NUL terminator, so our formula can be max 1023
312
                        SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i,        WM_SETFONT,(WPARAM)hfnt,false);
313
                }
314
 
453 daniel-mar 315
                // Implement "up" and "down" keys for the edit controls
316
                // TODO: Better use a spin-edit?
317
                for (i = 0; i < 8; ++i) {
454 daniel-mar 318
                        #ifdef _WIN64
319
                        lpControlEditWndProc[i] = (WNDPROC)SetWindowLongPtr(GetDlgItem(hDlg, FIRSTCTLTEXTITEM + i), GWLP_WNDPROC, (LONG_PTR)&ControlTextWndProc);
320
                        #else
453 daniel-mar 321
                        lpControlEditWndProc[i] = (WNDPROC)SetWindowLongPtr(GetDlgItem(hDlg, FIRSTCTLTEXTITEM + i), GWL_WNDPROC, (LONG_PTR)&ControlTextWndProc);
454 daniel-mar 322
                        #endif
453 daniel-mar 323
                }
324
 
456 daniel-mar 325
                maindlginit(hDlg);
326
 
460 daniel-mar 327
                // Win32s (Win3.11) compatibility fix: Since GetClassInfo("Button") and GetClassInfo("Static") won't work,
328
                // we had replaced the WndProc by a dummy. Now, we find out the real Button and Static WndProcs and give them
329
                // to our classes, making them the intended superclasses. Messages which have been sent in between were lost,
330
                // though...
331
 
332
                wndProcStatic = (WNDPROC)GetWindowLongPtr(GetDlgItem(hDlg, FIRSTCTLLABELITEM), GWLP_WNDPROC);
333
                SetWindowLongPtr(GetDlgItem(hDlg, PREVIEWITEM), GWLP_WNDPROC, (LONG)wndProcStatic);
334
 
335
                wndProcButton = (WNDPROC)GetWindowLongPtr(GetDlgItem(hDlg, OPENITEM), GWLP_WNDPROC);
336
                SetWindowLongPtr(GetDlgItem(hDlg, FIRSTICONITEM), GWLP_WNDPROC, (LONG)wndProcButton);
337
                SetWindowLongPtr(GetDlgItem(hDlg, FIRSTICONITEM + 1), GWLP_WNDPROC, (LONG)wndProcButton);
338
                SetWindowLongPtr(GetDlgItem(hDlg, FIRSTICONITEM + 2), GWLP_WNDPROC, (LONG)wndProcButton);
339
                SetWindowLongPtr(GetDlgItem(hDlg, FIRSTICONITEM + 3), GWLP_WNDPROC, (LONG)wndProcButton);
340
 
456 daniel-mar 341
                // Some versions of Windows (NT 3.x) won't show the preview if it is calculated here.
342
                // So we need to put it in a timer.
343
                // Note that 1 millisecond is enough, even if the window needs longer than 1 millisecond to load.
344
                //recalc_preview(gpb, hDlg);
345
                SetTimer(hDlg, IDT_TIMER_INITPREVIEW_DRAW, 1, (TIMERPROC)NULL);
346
 
259 daniel-mar 347
                break;
348
        case WM_DESTROY:
349
                gdata->hWndMainDlg = 0;
350
                DestroyCursor(hCurHandOpen);
351
                DestroyCursor(hCurHandGrab);
352
                DestroyCursor(hCurHandQuestion);
419 daniel-mar 353
                DestroyIcon(hIconCautionSign);
259 daniel-mar 354
                break;
355
        case WM_DRAWITEM:
356
                pdi = (DRAWITEMSTRUCT*)lParam;
357
                if(pdi->itemAction == ODA_DRAWENTIRE){
358
                        switch(pdi->CtlID){
359
                        case PREVIEWITEM:
360
                                drawpreview(hDlg,pdi->hDC,PILOCKHANDLE(preview_handle,false));
361
                                PIUNLOCKHANDLE(preview_handle);
362
                                break;
419 daniel-mar 363
                        case FIRSTICONITEM:
364
                        case FIRSTICONITEM + 1:
365
                        case FIRSTICONITEM + 2:
366
                        case FIRSTICONITEM + 3:
367
                                DrawIcon(pdi->hDC, 0, 0, hIconCautionSign);
368
                                break;
259 daniel-mar 369
                        default:
370
                                return false;
371
                        }
372
                }else
373
                        return false; // we couldn't handle the message
374
                break;
375
        case WM_COMMAND:
376
                item = LOWORD(wParam);
377
                switch(HIWORD(wParam)){
419 daniel-mar 378
                //case BN_CLICKED:
379
                case STN_CLICKED:
380
                        // BN_CLICKED = Button clicked
381
                        // STN_CLICKED = Static controls with SS_NOTIFY clicked
382
                        // Both have the same ordinal number
259 daniel-mar 383
                        if(item==PREVIEWITEM && GetCursorPos(&origpos)){
384
                                panning = true;
385
                                origscroll = preview_scroll;
386
                                SetCursor(hCurHandGrab);
433 daniel-mar 387
                                SetCapture(hDlg);
259 daniel-mar 388
                                break;
389
                        }
419 daniel-mar 390
                /* ... falls through ... */
259 daniel-mar 391
                case EN_CHANGE:
392
                        if(doupdates && !maindlgitem(hDlg,item))
393
                                EndDialog(hDlg,item);
394
                }
395
                break;
396
//      case WM_LBUTTONDOWN: break;
397
        case WM_MOUSEMOVE:
398
                if(panning && GetCursorPos(&newpos)){
273 daniel-mar 399
                        newscroll.h = (int16)(origscroll.h - zoomfactor*((double)newpos.x - (double)origpos.x));
400
                        newscroll.v = (int16)(origscroll.v - zoomfactor*((double)newpos.y - (double)origpos.y));
259 daniel-mar 401
                        if( newscroll.h != preview_scroll.h || newscroll.v != preview_scroll.v ){
402
                                preview_scroll = newscroll;
403
                                recalc_preview(gpb,hDlg);
404
                        }
405
                }
406
                break;
407
        case WM_LBUTTONUP:
408
                ReleaseCapture();
409
                panning = false;
410
                break;
411
        case WM_HSCROLL:
422 daniel-mar 412
                // Only for non-Plugin.dll-sliders
259 daniel-mar 413
                item = GetDlgCtrlID((HWND)lParam);
427 daniel-mar 414
                if(doupdates && gdata->pluginDllSliderMessageId == 0 && item>=FIRSTCTLITEM && item<=FIRSTCTLITEM+7)
259 daniel-mar 415
                        slidermoved(hDlg,item);
416
                break;
417
        default:
418
                return false;
419
        }
420
 
421
        return true;
422
}
423
 
431 daniel-mar 424
Boolean maindialog(FilterRecordPtr pb){
425
        PlatformData *p;
426
        INT_PTR res;
427
 
428
        // First try to use the sliders from PLUGIN.DLL (only Photoshop)
444 daniel-mar 429
        if (!Slider_Init_PluginDll(TEXT("FoundrySlider"))) {
431 daniel-mar 430
                // If we couldn't get the sliders from PLUGIN.DLL (probably not running in Photoshop),
431
                // then try the Microsoft Trackbar Control instead
444 daniel-mar 432
                if (!Slider_Init_MsTrackbar(TEXT("FoundrySlider"))) {
431 daniel-mar 433
                        // This will happen if we neither have PLUGIN.DLL, nor the Microsoft Trackbar Control (msctls_trackbar32).
434
                        // "msctls_trackbar32" is not included in Windows NT 3.1, and since there is no OCX or RegSvr32.
435
                        // It is included in Windows NT 3.5x.
436
 
444 daniel-mar 437
                        //simplealert((TCHAR*)TEXT("This plugin requires Photoshop's PLUGIN.DLL or the Microsoft Trackbar Control (msctls_trackbar32) which was not found on your system."));
430 daniel-mar 438
                        //return false;
439
 
440
                        // We simply hide the sliders and let the user enter the numeric values in the edit-box.
444 daniel-mar 441
                        simplewarning((TCHAR*)TEXT("Visual sliders are not available because neither PLUGIN.DLL, nor the Microsoft Trackbar Control (msctls_trackbar32) was found on your system."));
442
                        Slider_Init_None(TEXT("FoundrySlider"));
419 daniel-mar 443
                }
413 daniel-mar 444
        }
445
 
431 daniel-mar 446
        // For the preview image and caution symbols, we register subclasses, so that we can assign a mouse cursor to this class.
460 daniel-mar 447
        MakeSimpleSubclass(TEXT("Preview"), WC_STATIC);
448
        MakeSimpleSubclass(TEXT("Caution"), WC_BUTTON);
259 daniel-mar 449
 
450
        // Now show the dialog
451
        p = (PlatformData*)pb->platformData;
419 daniel-mar 452
 
453
        // Note: "Invalid Cursor Handle" is the error when an unrecognized control class is detected
259 daniel-mar 454
        res = DialogBoxParam(hDllInstance,MAKEINTRESOURCE(gdata->standalone ? ID_PARAMDLG : ID_MAINDLG),
412 daniel-mar 455
                             (HWND)p->hwnd,maindlgproc,0);
456
        if (res == 0) {
459 daniel-mar 457
                simplealert((TCHAR*)TEXT("DialogBoxParam invalid parent window handle"));
412 daniel-mar 458
        }
459
        if (res == -1) {
444 daniel-mar 460
                TCHAR s[0x300];
461
                xstrcpy(s, (TCHAR*)TEXT("DialogBoxParam failed: "));
454 daniel-mar 462
                FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + xstrlen(s), 0x300 - (DWORD)xstrlen(s), NULL);
444 daniel-mar 463
                dbg(&s[0]);
412 daniel-mar 464
        }
259 daniel-mar 465
 
353 daniel-mar 466
        // Clean up after the dialog has been closed
444 daniel-mar 467
        UnregisterClass(TEXT("Preview"), hDllInstance);
468
        UnregisterClass(TEXT("Caution"), hDllInstance);
469
        UnregisterClass(TEXT("FoundrySlider"), hDllInstance);
431 daniel-mar 470
        Slider_Uninit_PluginDll();
259 daniel-mar 471
 
412 daniel-mar 472
        return res == IDOK;
259 daniel-mar 473
}