Subversion Repositories filter_foundry

Rev

Rev 426 | Rev 430 | 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"
31
 
32
#include "version.h"
33
 
422 daniel-mar 34
//#define force_msctls_trackbar32
35
 
259 daniel-mar 36
HWND preview_hwnd;
37
HCURSOR hCurHandOpen;
38
HCURSOR hCurHandGrab;
419 daniel-mar 39
 
259 daniel-mar 40
HCURSOR hCurHandQuestion;
419 daniel-mar 41
HICON hIconCautionSign;
259 daniel-mar 42
 
422 daniel-mar 43
// This method will register the "slider" class used in dialogs.
44
typedef int(__cdecl* f_RegisterSlider)(HINSTANCE hInstanceDll, DWORD* MessageID);
45
int RegisterSlider(HINSTANCE hInstanceDll, DWORD* MessageID) {
46
        f_RegisterSlider fRegisterSlider;
47
 
427 daniel-mar 48
        if (!gdata->pluginDllModule) return 0;
49
        fRegisterSlider = (f_RegisterSlider)(void*)GetProcAddress(gdata->pluginDllModule, "RegisterSlider");
422 daniel-mar 50
        if (fRegisterSlider != 0) {
51
                return fRegisterSlider(hInstanceDll, MessageID);
52
        }
53
        else {
54
                return 0;
55
        }
56
}
57
 
58
// This method will unregister the "slider" class used in dialogs.
59
typedef int(__cdecl* f_UnregisterSlider)(HINSTANCE hInstanceDll);
60
int UnregisterSlider(HINSTANCE hInstanceDll) {
61
        f_UnregisterSlider fUnregisterSlider;
62
 
427 daniel-mar 63
        if (!gdata->pluginDllModule) return 0;
64
        fUnregisterSlider = (f_UnregisterSlider)(void*)GetProcAddress(gdata->pluginDllModule, "UnregisterSlider");
422 daniel-mar 65
        if (fUnregisterSlider != 0) {
66
                return fUnregisterSlider(hInstanceDll);
67
        }
68
        else {
69
                return 0;
70
        }
71
}
72
 
73
typedef int(__cdecl* f_SetSliderRange)(HWND hWnd, int nMin, int nMax);
74
int SetSliderRange(HWND hWnd, int nMin, int nMax) {
75
        f_SetSliderRange fSetSliderRange;
76
 
427 daniel-mar 77
        if (!gdata->pluginDllModule) return 0;
78
        fSetSliderRange = (f_SetSliderRange)(void*)GetProcAddress(gdata->pluginDllModule, "SetSliderRange");
422 daniel-mar 79
        if (fSetSliderRange != 0) {
80
                return fSetSliderRange(hWnd, nMin, nMax);
81
        }
82
        else {
83
                return 0;
84
        }
85
}
86
 
426 daniel-mar 87
typedef int(__cdecl* f_SetSliderPos)(HWND hWnd, int nPos, BOOL bRepaint);
88
int SetSliderPos(HWND hWnd, int nPos, BOOL bRepaint) {
422 daniel-mar 89
        f_SetSliderPos fSetSliderPos;
90
 
427 daniel-mar 91
        if (!gdata->pluginDllModule) return 0;
92
        fSetSliderPos = (f_SetSliderPos)(void*)GetProcAddress(gdata->pluginDllModule, "SetSliderPos");
422 daniel-mar 93
        if (fSetSliderPos != 0) {
426 daniel-mar 94
                return fSetSliderPos(hWnd, nPos, bRepaint);
422 daniel-mar 95
        }
96
        else {
97
                return 0;
98
        }
99
}
100
 
426 daniel-mar 101
typedef int(__cdecl* f_GetSliderPos)(HWND hWnd, BOOL bPixelPosition);
102
int GetSliderPos(HWND hWnd, BOOL bPixelPosition) {
422 daniel-mar 103
        f_GetSliderPos fGetSliderPos;
104
 
427 daniel-mar 105
        if (!gdata->pluginDllModule) return 0;
106
        fGetSliderPos = (f_GetSliderPos)(void*)GetProcAddress(gdata->pluginDllModule, "GetSliderPos");
422 daniel-mar 107
        if (fGetSliderPos != 0) {
426 daniel-mar 108
                int res = fGetSliderPos(hWnd, bPixelPosition);
422 daniel-mar 109
                return res;
110
        }
111
        else {
112
                return 0;
113
        }
114
}
115
 
259 daniel-mar 116
extern HINSTANCE hDllInstance;
117
 
118
void DoAbout(AboutRecordPtr pb){
119
        char text[1000];
120
        char title[200];
121
        PlatformData *p = (PlatformData*)pb->platformData;
122
 
123
        if (gdata && gdata->standalone) {
393 daniel-mar 124
                sprintf(title, "About %s", gdata->parm.szTitle);
259 daniel-mar 125
                sprintf(text,  "%s by %s\n" /* {Title} by {Author} */
126
                               "%s\n" /* {Copyright} */
127
                               "\n"
128
                               "This plugin was built using Filter Foundry " VERSION_STR
268 daniel-mar 129
                                #ifdef _WIN64
259 daniel-mar 130
                               " (64 bit)\n"
268 daniel-mar 131
                                #else
259 daniel-mar 132
                               " (32 bit)\n"
268 daniel-mar 133
                                #endif
259 daniel-mar 134
                               "(C) 2003-2009 Toby Thain, 2018-" RELEASE_YEAR " Daniel Marschall\n"
135
                               "available from " PROJECT_URL,
393 daniel-mar 136
                               gdata->parm.szTitle,
137
                               gdata->parm.szAuthor,
138
                               gdata->parm.szCopyright);
259 daniel-mar 139
        } else {
140
                sprintf(title, "About Filter Foundry");
141
                sprintf(text,  "Filter Foundry " VERSION_STR
268 daniel-mar 142
                                #ifdef _WIN64
259 daniel-mar 143
                               " (64 bit)\n"
268 daniel-mar 144
                                #else
259 daniel-mar 145
                               " (32 bit)\n"
268 daniel-mar 146
                                #endif
259 daniel-mar 147
                               "(C) 2003-2009 Toby Thain, 2018-" RELEASE_YEAR " Daniel Marschall\n"
148
                               "\n"
149
                               "Latest version available from\n"
150
                               PROJECT_URL "\n"
151
                               "\nPlease contact the author with any bug reports,\n"
152
                               "suggestions or comments.\n"
153
                               "If you use this program and like it, please consider\n"
154
                               "making a donation.");
155
        }
156
 
412 daniel-mar 157
        MessageBox((HWND)p->hwnd, text, title, MB_TASKMODAL|MB_ICONINFORMATION|MB_OK);
259 daniel-mar 158
}
159
 
160
Boolean simplealert(char *s){
273 daniel-mar 161
        HWND hwnd;
259 daniel-mar 162
        char* title;
163
        if (gdata && gdata->standalone) {
393 daniel-mar 164
                title = gdata->parm.szTitle;
259 daniel-mar 165
        } else {
166
                title = _strdup("Filter Foundry");
167
        }
273 daniel-mar 168
        hwnd = gdata ? gdata->hWndMainDlg : NULL;
413 daniel-mar 169
        return MessageBox(hwnd, s, title, MB_TASKMODAL|MB_ICONERROR|MB_OK) == IDOK;
259 daniel-mar 170
}
171
 
320 daniel-mar 172
Boolean simplewarning(char* s) {
173
        HWND hwnd;
174
        char* title;
175
        if (gdata && gdata->standalone) {
393 daniel-mar 176
                title = gdata->parm.szTitle;
177
        } else {
320 daniel-mar 178
                title = _strdup("Filter Foundry");
179
        }
180
        hwnd = gdata ? gdata->hWndMainDlg : NULL;
181
        return MessageBox(hwnd,s,title,MB_TASKMODAL|MB_ICONEXCLAMATION|MB_OK) == IDOK;
182
}
183
 
353 daniel-mar 184
Boolean showmessage(char *s) {
273 daniel-mar 185
        HWND hwnd;
259 daniel-mar 186
        char* title;
187
        if (gdata && gdata->standalone) {
393 daniel-mar 188
                title = gdata->parm.szTitle;
259 daniel-mar 189
        } else {
190
                title = _strdup("Filter Foundry");
191
        }
273 daniel-mar 192
        hwnd = gdata ? gdata->hWndMainDlg : NULL;
193
        return MessageBox(hwnd,s,title,MB_TASKMODAL|MB_ICONINFORMATION|MB_OK) == IDOK;
259 daniel-mar 194
}
195
 
196
INT_PTR CALLBACK maindlgproc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
197
 
353 daniel-mar 198
// Description:
393 daniel-mar 199
//   Creates a tooltip for an item in a dialog box.
353 daniel-mar 200
// Parameters:
201
//   idTool - identifier of an dialog box item.
202
//   nDlg - window handle of the dialog box.
203
//   pszText - string to use as the tooltip text.
204
// Returns:
205
//   The handle to the tooltip.
206
//
207
HWND CreateToolTip(int toolID, HWND hDlg, PTSTR pszText) {
354 daniel-mar 208
        // Source: https://docs.microsoft.com/en-us/windows/win32/controls/create-a-tooltip-for-a-control (modified)
393 daniel-mar 209
 
354 daniel-mar 210
        HWND hwndTool, hwndTip;
211
        TOOLINFO toolInfo;
212
 
353 daniel-mar 213
        if (!toolID || !hDlg || !pszText) {
214
                return FALSE;
215
        }
216
        // Get the window of the tool.
354 daniel-mar 217
        hwndTool = GetDlgItem(hDlg, toolID);
353 daniel-mar 218
 
219
        // Create the tooltip. g_hInst is the global instance handle.
354 daniel-mar 220
        hwndTip = CreateWindowEx(0, TOOLTIPS_CLASS, NULL,
353 daniel-mar 221
                WS_POPUP | TTS_ALWAYSTIP /* | TTS_BALLOON*/,
222
                CW_USEDEFAULT, CW_USEDEFAULT,
223
                CW_USEDEFAULT, CW_USEDEFAULT,
224
                hDlg, NULL,
225
                hDllInstance, NULL);
226
 
227
        if (!hwndTool || !hwndTip) {
228
                return (HWND)NULL;
229
        }
230
 
231
        // Associate the tooltip with the tool.
354 daniel-mar 232
        memset(&toolInfo, 0, sizeof(TOOLINFO)); // toolInfo = { 0 };
353 daniel-mar 233
        toolInfo.cbSize = sizeof(toolInfo);
234
        toolInfo.hwnd = hDlg;
235
        toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
236
        toolInfo.uId = (UINT_PTR)hwndTool;
237
        toolInfo.lpszText = pszText;
238
        SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
239
 
240
        return hwndTip;
241
}
242
 
259 daniel-mar 243
INT_PTR CALLBACK maindlgproc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam){
244
        static POINT origpos;
245
        static Point origscroll;
246
        static Boolean panning = false;
247
 
248
        int item,i;
249
        POINT newpos;
250
        DRAWITEMSTRUCT *pdi;
251
        Point newscroll;
252
        HGDIOBJ hfnt;
253
 
254
        extern Boolean doupdates;
255
        extern Handle preview_handle;
256
 
427 daniel-mar 257
        if ((gdata->pluginDllSliderMessageId != 0) && (wMsg == gdata->pluginDllSliderMessageId)) {
422 daniel-mar 258
                // This is for the PLUGIN.DLL sliders only
259
                if (doupdates) {
260
                        int sliderNum = wParam - FIRSTCTLITEM;
261
                        uint8_t sliderVal = (uint8_t)(lParam & 0xFFFF);
262
                        slider[sliderNum] = sliderVal;
263
 
264
                        SETCTLTEXTINT(hDlg, FIRSTCTLTEXTITEM + sliderNum, sliderVal, false);
265
                        REPAINTCTL(hDlg, FIRSTCTLTEXTITEM + sliderNum);
266
 
267
                        recalc_preview(gpb, hDlg);
268
                }
269
                return true;
270
        }
271
 
419 daniel-mar 272
        switch (wMsg) {
259 daniel-mar 273
        case WM_INITDIALOG:
274
                gdata->hWndMainDlg = hDlg;
275
 
276
                if(gdata->standalone){
393 daniel-mar 277
                        SetWindowText(hDlg,gdata->parm.szTitle); // window title bar
259 daniel-mar 278
                }
279
                centre_window(hDlg);
280
 
281
                hfnt = GetStockObject(ANSI_FIXED_FONT);
282
 
402 daniel-mar 283
                hCurHandOpen = LoadCursor(hDllInstance, "HAND_OPEN");
284
                hCurHandGrab = LoadCursor(hDllInstance, "HAND_GRAB");
285
                hCurHandQuestion = LoadCursor(hDllInstance, "HAND_QUESTION");
259 daniel-mar 286
 
419 daniel-mar 287
                hIconCautionSign = LoadIcon(hDllInstance, "CAUTION_ICO");
288
 
289
                // Note: The whole class "Preview" gets the mouse cursor, not just the single item!
259 daniel-mar 290
                preview_hwnd = GetDlgItem(hDlg, PREVIEWITEM);
291
                GetClientRect(preview_hwnd, &preview_rect);
292
                SetClassLongPtr(preview_hwnd, GCLP_HCURSOR, (LONG_PTR)hCurHandOpen);
293
 
419 daniel-mar 294
                // Note: The whole class "Caution" gets the mouse cursor, not just the single item!
259 daniel-mar 295
                SetClassLongPtr(GetDlgItem(hDlg, FIRSTICONITEM), GCLP_HCURSOR, (LONG_PTR)hCurHandQuestion);
296
 
297
                for(i = 0; i < 4; ++i){
419 daniel-mar 298
                        CreateToolTip(FIRSTICONITEM + i, hDlg, _strdup("Error in expression! Click to see details."));
259 daniel-mar 299
                }
300
 
355 daniel-mar 301
                CreateToolTip(ZOOMINITEM, hDlg, _strdup("Zoom in"));
302
                CreateToolTip(ZOOMOUTITEM, hDlg, _strdup("Zoom out"));
417 daniel-mar 303
                CreateToolTip(ZOOMLEVELITEM, hDlg, _strdup("Fully zoom in/out"));
353 daniel-mar 304
 
259 daniel-mar 305
                for(i = 0; i < 8; ++i){
427 daniel-mar 306
                        if (gdata->pluginDllSliderMessageId == 0) {
422 daniel-mar 307
                                // Non PLUGIN.DLL sliders
308
                                SetWindowLongPtr(GetDlgItem(hDlg, FIRSTCTLITEM + i), GWL_STYLE, TBS_HORZ | TBS_AUTOTICKS | WS_CHILD | WS_VISIBLE);
309
                                SendDlgItemMessage(hDlg, FIRSTCTLITEM + i, TBM_SETRANGE, TRUE, MAKELONG(0, 255));
310
                                SendDlgItemMessage(hDlg, FIRSTCTLITEM + i, TBM_SETTICFREQ, SLIDERPAGE, 0);
311
                                SendDlgItemMessage(hDlg, FIRSTCTLITEM + i, TBM_SETPAGESIZE, 0, SLIDERPAGE);
312
                        }
313
                        else {
314
                                // PLUGIN.DLL sliders
315
                                SetSliderRange(GetDlgItem(hDlg, FIRSTCTLITEM + i), 0, 255);
316
                        }
259 daniel-mar 317
                        SendDlgItemMessage(hDlg,FIRSTCTLTEXTITEM+i,     EM_SETLIMITTEXT,3,0);
318
                }
319
                for(i = 0; i < 4; ++i){
320
                        SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i,        EM_SETLIMITTEXT,MAXEXPR-1,0); // we need 1 byte as NUL terminator, so our formula can be max 1023
321
                        SendDlgItemMessage(hDlg,FIRSTEXPRITEM+i,        WM_SETFONT,(WPARAM)hfnt,false);
322
                }
323
 
324
                maindlginit(hDlg);
325
                break;
326
        case WM_DESTROY:
327
                gdata->hWndMainDlg = 0;
328
                DestroyCursor(hCurHandOpen);
329
                DestroyCursor(hCurHandGrab);
330
                DestroyCursor(hCurHandQuestion);
419 daniel-mar 331
                DestroyIcon(hIconCautionSign);
259 daniel-mar 332
                break;
333
        case WM_DRAWITEM:
334
                pdi = (DRAWITEMSTRUCT*)lParam;
335
                if(pdi->itemAction == ODA_DRAWENTIRE){
336
                        switch(pdi->CtlID){
337
                        case PREVIEWITEM:
338
                                drawpreview(hDlg,pdi->hDC,PILOCKHANDLE(preview_handle,false));
339
                                PIUNLOCKHANDLE(preview_handle);
340
                                break;
419 daniel-mar 341
                        case FIRSTICONITEM:
342
                        case FIRSTICONITEM + 1:
343
                        case FIRSTICONITEM + 2:
344
                        case FIRSTICONITEM + 3:
345
                                DrawIcon(pdi->hDC, 0, 0, hIconCautionSign);
346
                                break;
259 daniel-mar 347
                        default:
348
                                return false;
349
                        }
350
                }else
351
                        return false; // we couldn't handle the message
352
                break;
353
        case WM_COMMAND:
354
                item = LOWORD(wParam);
355
                switch(HIWORD(wParam)){
419 daniel-mar 356
                //case BN_CLICKED:
357
                case STN_CLICKED:
358
                        // BN_CLICKED = Button clicked
359
                        // STN_CLICKED = Static controls with SS_NOTIFY clicked
360
                        // Both have the same ordinal number
259 daniel-mar 361
                        if(item==PREVIEWITEM && GetCursorPos(&origpos)){
362
                                panning = true;
363
                                origscroll = preview_scroll;
364
                                SetCursor(hCurHandGrab);
422 daniel-mar 365
                                SetCapture(hDlg);              
259 daniel-mar 366
                                break;
367
                        }
419 daniel-mar 368
                /* ... falls through ... */
259 daniel-mar 369
                case EN_CHANGE:
370
                        if(doupdates && !maindlgitem(hDlg,item))
371
                                EndDialog(hDlg,item);
372
                }
373
                break;
374
//      case WM_LBUTTONDOWN: break;
375
        case WM_MOUSEMOVE:
376
                if(panning && GetCursorPos(&newpos)){
273 daniel-mar 377
                        newscroll.h = (int16)(origscroll.h - zoomfactor*((double)newpos.x - (double)origpos.x));
378
                        newscroll.v = (int16)(origscroll.v - zoomfactor*((double)newpos.y - (double)origpos.y));
259 daniel-mar 379
                        if( newscroll.h != preview_scroll.h || newscroll.v != preview_scroll.v ){
380
                                preview_scroll = newscroll;
381
                                recalc_preview(gpb,hDlg);
382
                        }
383
                }
384
                break;
385
        case WM_LBUTTONUP:
386
                ReleaseCapture();
387
                panning = false;
388
                break;
389
        case WM_HSCROLL:
422 daniel-mar 390
                // Only for non-Plugin.dll-sliders
259 daniel-mar 391
                item = GetDlgCtrlID((HWND)lParam);
427 daniel-mar 392
                if(doupdates && gdata->pluginDllSliderMessageId == 0 && item>=FIRSTCTLITEM && item<=FIRSTCTLITEM+7)
259 daniel-mar 393
                        slidermoved(hDlg,item);
394
                break;
395
        default:
396
                return false;
397
        }
398
 
399
        return true;
400
}
401
 
402
Boolean maindialog(FilterRecordPtr pb){
403
        PlatformData *p;
412 daniel-mar 404
        WNDCLASS clx;
405
        INT_PTR res;
427 daniel-mar 406
        DWORD sliderMsgId;
259 daniel-mar 407
 
422 daniel-mar 408
        // Register the FoundrySlider control class
409
        #ifdef force_msctls_trackbar32
427 daniel-mar 410
        gdata->pluginDllModule = 0;
422 daniel-mar 411
        #else
427 daniel-mar 412
        gdata->pluginDllModule = LoadLibraryA("PLUGIN.DLL");
422 daniel-mar 413
        #endif
427 daniel-mar 414
        sliderMsgId = 0;
415
        RegisterSlider(hDllInstance, &sliderMsgId); // PLUGIN.DLL (only Photoshop) registers the class "slider"
416
        if (sliderMsgId != 0) {
417
                // RegisterSlider will "remember" if it has gave you a message ID
418
                // and it will NOT give it to you again! (instead, the out value stays untouched)
419
                gdata->pluginDllSliderMessageId = sliderMsgId;
422 daniel-mar 420
        }
421
        if (GetClassInfo(hDllInstance, "slider", &clx) != 0) {
422
                clx.lpszClassName = "FoundrySlider";
423
                if (RegisterClass(&clx) == 0) {
424
                        char s[100];
425
                        strcpy(s, "RegisterClass failed: ");
426
                        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL);
427
                        dbg(s);
428
                }
429
        }
430
        else if (GetClassInfo(hDllInstance, "msctls_trackbar32", &clx) != 0) {
431
                // We couldn't get the sliders from PLUGIN.DLL (probably not running in Photoshop)
432
                // Try the Microsoft Trackbar Control instead
433
                clx.lpszClassName = "FoundrySlider";
434
                if (RegisterClass(&clx) == 0) {
435
                        char s[100];
436
                        strcpy(s, "RegisterClass failed: ");
437
                        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL);
438
                        dbg(s);
439
                }
440
        }
441
        else {
442
                // This will happen if we neither have PLUGIN.DLL, nor the Microsoft Trackbar Control (msctls_trackbar32)
443
                // "msctls_trackbar32" is not included in Windows NT 3.1, and since there is no OCX or RegSvr32,
444
                // there seems no possibility to support this version of Windows at this point.
445
                // It is included in Windows NT 3.5x
446
 
447
                //simplealert(_strdup("This plugin requires Photoshop's PLUGIN.DLL or the Microsoft Trackbar Control (msctls_trackbar32) which was not found on your system."));
419 daniel-mar 448
                //return false;
449
 
450
                // We simply hide the sliders and let the user enter the numeric values in the edit-box.
451
                // At least the plugin runs on Windows NT 3.1 !
422 daniel-mar 452
                simplewarning(_strdup("Visual sliders are not available because neither PLUGIN.DLL nor the Microsoft Trackbar Control (msctls_trackbar32) was found on your system."));
419 daniel-mar 453
                GetClassInfo(hDllInstance, "STATIC", &clx);
422 daniel-mar 454
                clx.lpszClassName = "FoundrySlider";
419 daniel-mar 455
                if (RegisterClass(&clx) == 0) {
456
                        char s[100];
457
                        strcpy(s, "RegisterClass failed: ");
458
                        FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL);
459
                        dbg(s);
460
                }
413 daniel-mar 461
        }
462
 
419 daniel-mar 463
        // For the preview image and caution symbols, we register a class, so that we can assign a mouse cursor to this class.
412 daniel-mar 464
        GetClassInfo(hDllInstance, "STATIC", &clx);
259 daniel-mar 465
        clx.lpszClassName = "Preview";
413 daniel-mar 466
        if (RegisterClass(&clx) == 0) {
467
                char s[100];
468
                strcpy(s, "RegisterClass failed: ");
469
                FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL);
470
                dbg(s);
471
        }
419 daniel-mar 472
        GetClassInfo(hDllInstance, "Button", &clx);
473
        clx.lpszClassName = "Caution";
413 daniel-mar 474
        if (RegisterClass(&clx) == 0) {
475
                char s[100];
476
                strcpy(s, "RegisterClass failed: ");
477
                FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL);
478
                dbg(s);
479
        }
259 daniel-mar 480
 
481
        // Now show the dialog
482
        p = (PlatformData*)pb->platformData;
419 daniel-mar 483
 
484
        // Note: "Invalid Cursor Handle" is the error when an unrecognized control class is detected
259 daniel-mar 485
        res = DialogBoxParam(hDllInstance,MAKEINTRESOURCE(gdata->standalone ? ID_PARAMDLG : ID_MAINDLG),
412 daniel-mar 486
                             (HWND)p->hwnd,maindlgproc,0);
487
        if (res == 0) {
419 daniel-mar 488
                simplealert(_strdup("DialogBoxParam in valid parent window handle"));
412 daniel-mar 489
        }
490
        if (res == -1) {
491
                char s[100];
492
                strcpy(s, "DialogBoxParam failed: ");
493
                FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, s + strlen(s), 0x100, NULL);
494
                dbg(s);
495
        }
259 daniel-mar 496
 
353 daniel-mar 497
        // Clean up after the dialog has been closed
259 daniel-mar 498
        UnregisterClass("Preview", hDllInstance);
419 daniel-mar 499
        UnregisterClass("Caution", hDllInstance);
422 daniel-mar 500
        UnregisterClass("FoundrySlider", hDllInstance);
501
        if (GetClassInfo(hDllInstance, "slider", &clx) != 0) {
502
                UnregisterSlider(hDllInstance);
420 daniel-mar 503
        }
427 daniel-mar 504
        if (gdata->pluginDllModule) {
505
                FreeLibrary(gdata->pluginDllModule);
422 daniel-mar 506
        }
259 daniel-mar 507
 
412 daniel-mar 508
        return res == IDOK;
259 daniel-mar 509
}
510