-
Notifications
You must be signed in to change notification settings - Fork 1
/
optionsdlg.c
586 lines (515 loc) · 18.1 KB
/
optionsdlg.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
//----------------------------------------------------------------------------
// EnsoniqFS plugin for TotalCommander
//
// OPTIONS DIALOG
//----------------------------------------------------------------------------
//
// (c) 2006 Thoralt Franz
//
// This source code was written using Dev-Cpp 4.9.9.2
// If you want to compile it, get Dev-Cpp. Normally the code should compile
// with other IDEs/compilers too (with small modifications), but I did not
// test it.
//
//----------------------------------------------------------------------------
// License
//----------------------------------------------------------------------------
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
//
// Alternatively, download a copy of the license here:
// http://www.gnu.org/licenses/gpl.txt
//----------------------------------------------------------------------------
#include <stdio.h>
#include <windows.h>
#include <process.h>
#include <commctrl.h>
#include "fsplugin.h"
#include "optionsdlg.h"
#include "log.h"
#include "error.h"
#include "resource.h"
#include "disk.h"
#include "ini.h"
#include "EnsoniqFS.h"
//----------------------------------------------------------------------------
// global flags and variables
//----------------------------------------------------------------------------
extern HINSTANCE g_hInst;
extern DISK *g_pDiskListRoot;
extern HINSTANCE g_hInst;
extern FsDefaultParamStruct g_DefaultParams; // initialization parameters
// needed to find INI file
// global options
extern int g_iOptionEnableFloppy;
extern int g_iOptionEnableCDROM;
extern int g_iOptionEnableImages;
extern int g_iOptionEnablePhysicalDisks;
extern int g_iOptionAutomaticRescan;
extern int g_iOptionEnableLogging;
extern int g_iOptionBankAdaption;
extern int g_iOptionBankSourceDevice;
extern int g_iOptionBankTargetDevice;
int m_iDeviceListChanged = 0;
//----------------------------------------------------------------------------
// OptionsDlg_OnCancel
//
// Gets called when the Cancel button was clicked, ends the dialog handling
//
// -> hWnd = window handle of options dialog
// <- --
//----------------------------------------------------------------------------
void OptionsDlg_OnCancel(HWND hWnd)
{
LOG("OptionsDlg_OnCancel()\n");
EndDialog(hWnd, IDCANCEL);
}
//----------------------------------------------------------------------------
// OptionsDlg_OnOK
//
// Gets called when the OK button was clicked
// Saves the status of the checkboxes to the global variables, writes them
// to the INI file, rescans device list if necessary
//
// -> hWnd = window handle of options dialog
// <- --
//----------------------------------------------------------------------------
void OptionsDlg_OnOK(HWND hWnd)
{
char *cName = g_DefaultParams.DefaultIniName;
LOG("OptionsDlg_OnOK()\n");
// save checkbox status
g_iOptionEnableFloppy =
(SendMessage(GetDlgItem(hWnd, IDC_CHK_FLOPPY),
(UINT)BM_GETCHECK, (WPARAM)0, (LPARAM)0)==BST_CHECKED)?1:0;
g_iOptionEnableCDROM =
(SendMessage(GetDlgItem(hWnd, IDC_CHK_CDROM),
(UINT)BM_GETCHECK, (WPARAM)0, (LPARAM)0)==BST_CHECKED)?1:0;
g_iOptionEnablePhysicalDisks =
(SendMessage(GetDlgItem(hWnd, IDC_CHK_PHYSICAL),
(UINT)BM_GETCHECK, (WPARAM)0, (LPARAM)0)==BST_CHECKED)?1:0;
g_iOptionEnableImages =
(SendMessage(GetDlgItem(hWnd, IDC_CHK_IMAGE),
(UINT)BM_GETCHECK, (WPARAM)0, (LPARAM)0)==BST_CHECKED)?1:0;
g_iOptionAutomaticRescan =
(SendMessage(GetDlgItem(hWnd, IDC_CHK_RESCAN),
(UINT)BM_GETCHECK, (WPARAM)0, (LPARAM)0)==BST_CHECKED)?1:0;
g_iOptionEnableLogging =
(SendMessage(GetDlgItem(hWnd, IDC_CHK_LOGGING),
(UINT)BM_GETCHECK, (WPARAM)0, (LPARAM)0)==BST_CHECKED)?1:0;
g_iOptionBankAdaption =
(SendMessage(GetDlgItem(hWnd, IDC_CHK_BANKADAPTION),
(UINT)BM_GETCHECK, (WPARAM)0, (LPARAM)0)==BST_CHECKED)?1:0;
LRESULT lResult = SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKSOURCEDEVICE),
(UINT)CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
// first entry of list (value 0) maps to value -1; lResult == -1 indicates no selection
if (lResult != -1 )
g_iOptionBankSourceDevice = lResult - 1;
lResult = SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKTARGETDEVICE),
(UINT)CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
int bankDeviceIndex = lResult;
g_iOptionBankTargetDevice = (bankDeviceIndex < 4) ? bankDeviceIndex : bankDeviceIndex + 1;
SetIniValueInt(cName, "[EnsoniqFS]", "EnableFloppy",
g_iOptionEnableFloppy);
SetIniValueInt(cName, "[EnsoniqFS]", "EnableCDROM",
g_iOptionEnableCDROM);
SetIniValueInt(cName, "[EnsoniqFS]", "EnablePhysicalDisks",
g_iOptionEnablePhysicalDisks);
SetIniValueInt(cName, "[EnsoniqFS]", "EnableImages",
g_iOptionEnableImages);
SetIniValueInt(cName, "[EnsoniqFS]", "AutomaticRescan",
g_iOptionAutomaticRescan);
SetIniValueInt(cName, "[EnsoniqFS]", "EnableLogging",
g_iOptionEnableLogging);
SetIniValueInt(cName, "[EnsoniqFS]", "BankAdaption",
g_iOptionBankAdaption);
SetIniValueInt(cName, "[EnsoniqFS]", "BankSourceDevice",
g_iOptionBankSourceDevice);
SetIniValueInt(cName, "[EnsoniqFS]", "BankTargetDevice",
g_iOptionBankTargetDevice);
if(m_iDeviceListChanged)
{
// rescan device list
FreeDiskList(1, g_pDiskListRoot);
g_pDiskListRoot = ScanDevices(0);
}
EndDialog(hWnd, IDOK);
}
//----------------------------------------------------------------------------
// OptionsDlg_ParseImageFiles
//
// Reads the INI file, parses for image files, adds all entries to ComboBox
//
// -> hWnd = window handle of options dialog
// <- --
//----------------------------------------------------------------------------
void OptionsDlg_ParseImageFiles(HWND hWnd)
{
INI_LINE *pLine, *pIniFile;
char *cLine;
// clear "File" ComboBox
SendMessage(GetDlgItem(hWnd, IDC_CBO_FILES),
(UINT)CB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
// open ini file, parse, add image file entries to List
LOG("Reading INI file: ");
if(ERR_OK!=ReadIniFile(g_DefaultParams.DefaultIniName, &pIniFile))
{
LOG("failed.\n");
return;
}
LOG("OK.\nParsing: ");
// try to find section header
pLine = pIniFile;
while(pLine)
{
if(0==strncmp("[EnsoniqFS]", pLine->cLine, 11)) break;
pLine = pLine->pNext;
}
// section not found?
if(NULL==pLine)
{
LOG("[EnsoniqFS] section not found.\n");
FreeIniLines(pIniFile);
return;
}
// skip [EnsoniqFS] section name
pLine = pLine->pNext;
// parse all lines after [EnsoniqFS]
while(pLine)
{
// next section found?
if('['==pLine->cLine[0]) break;
if(0==strncmp("image=", pLine->cLine, 6))
{
LOG("adding to list: "); LOG(pLine->cLine);
cLine = malloc(strlen(pLine->cLine)-5);
if(NULL==cLine)
{
LOG("Error allocating line buffer.\n"); LOG(pLine->cLine);
FreeIniLines(pIniFile);
return;
}
memset(cLine, 0, strlen(pLine->cLine)-5);
strncpy(cLine, pLine->cLine+6, strlen(pLine->cLine)-7);
SendMessage(GetDlgItem(hWnd, IDC_CBO_FILES),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)cLine);
free(cLine);
}
pLine = pLine->pNext;
}
// select first entry
SendMessage(GetDlgItem(hWnd, IDC_CBO_FILES),
(UINT)CB_SETCURSEL, (WPARAM)0, (LPARAM)0);
FreeIniLines(pIniFile);
}
//----------------------------------------------------------------------------
// OptionsDlg_MountImage
//
// Adds a new file to the image file list
//
// -> hWnd = window handle of options dialog
// <- --
//----------------------------------------------------------------------------
void OptionsDlg_MountImage(HWND hWnd)
{
char cFilter[] = "All supported image files (*.iso;*.bin;*.gkh;*.ed?)|"
"*.iso;*.bin;*.gkh;*.ed?;*.img|"
"ISO images (*.iso;*.img)|*.iso;*.img|"
"BIN images (*.bin)|*.bin|"
"Epsread/Epswrite images (*.gkh)|*.gkh|"
"Giebler images (*.ed?)|*.ed?|"
"All files (*.*)|*.*||",
cFN[512], cTitle[] = "Open image file";
OPENFILENAME ofn;
int i, iLen;
// replace the separators with zeroes
iLen = strlen(cFilter);
for(i=0; i<iLen; i++) if('|'==cFilter[i]) cFilter[i] = 0;
memset(cFN, 0, 512); memset(&ofn, 0, sizeof(OPENFILENAME));
// construct the open file dialog
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWnd;
ofn.hInstance = g_hInst;
ofn.lpstrFilter = cFilter;
ofn.nFilterIndex = 1;
ofn.lpstrFile = cFN;
ofn.nMaxFile = 512;
ofn.lpstrTitle = cTitle;
ofn.Flags = OFN_ENABLESIZING|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|
OFN_HIDEREADONLY;
if(GetOpenFileName(&ofn))
{
AddToImageList(ofn.lpstrFile);
OptionsDlg_ParseImageFiles(hWnd);
m_iDeviceListChanged = 1;
}
}
//----------------------------------------------------------------------------
// OptionsDlg_UnmountImage
//
// Removes the currently selected image file from the list and rescans devices
//
// -> hWnd = window handle of options dialog
// <- --
//----------------------------------------------------------------------------
void OptionsDlg_UnmountImage(HWND hWnd)
{
INI_LINE *pLine, *pIniFile;
int iLen, iSelectedItem;
LRESULT lResult;
char *cName;
// get selected entry
lResult = SendMessage(GetDlgItem(hWnd, IDC_CBO_FILES),
(UINT)CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
iSelectedItem = lResult;
if(CB_ERR==lResult)
{
MessageBoxA(TC_HWND, "Please select an image file first.",
"EnsoniqFS · Warning", MB_OK|MB_ICONEXCLAMATION);
return;
}
// get text length
lResult = SendMessage(GetDlgItem(hWnd, IDC_CBO_FILES),
(UINT)CB_GETLBTEXTLEN, (WPARAM)iSelectedItem, (LPARAM)0);
iLen = lResult + 7;
cName = malloc(iLen);
if(NULL==cName) return;
// get selected text
memset(cName, 0, iLen);
strcpy(cName, "image=");
lResult = SendMessage(GetDlgItem(hWnd, IDC_CBO_FILES),
(UINT)CB_GETLBTEXT, (WPARAM)iSelectedItem, (LPARAM)cName+6);
LOG("Unmounting image \""); LOG(cName); LOG("\"\n");
// open ini file, parse, remove image file from list
LOG("Reading INI file: ");
if(ERR_OK!=ReadIniFile(g_DefaultParams.DefaultIniName, &pIniFile))
{
LOG("failed.\n");
return;
}
LOG("OK.\nParsing: ");
// try to find section header
pLine = pIniFile;
while(pLine)
{
if(0==strncmp("[EnsoniqFS]", pLine->cLine, 11)) break;
pLine = pLine->pNext;
}
// section not found?
if(NULL==pLine)
{
LOG("[EnsoniqFS] section not found.\n");
free(cName);
FreeIniLines(pIniFile);
return;
}
// skip [EnsoniqFS] section name
pLine = pLine->pNext;
// parse all lines after [EnsoniqFS]
while(pLine)
{
// next section found?
if('['==pLine->cLine[0]) break;
if(0==strncmp(cName, pLine->cLine, strlen(cName)))
{
DeleteIniLine(pLine);
break;
}
pLine = pLine->pNext;
}
// write back INI file
WriteIniFile(g_DefaultParams.DefaultIniName, pIniFile);
FreeIniLines(pIniFile);
free(cName);
// reload image list
OptionsDlg_ParseImageFiles(hWnd);
m_iDeviceListChanged = 1;
}
//----------------------------------------------------------------------------
// WM_INITDIALOG
//
// reads settings from global variables, reads image file list from INI file
//
// -> hWnd = window handle of options dialog
// <- --
//----------------------------------------------------------------------------
void OptionsDlg_OnInitDialog(HWND hWnd)
{
LOG("OptionsDlg_OnInitDialog()\n");
// read and parse ini file for mounted image files
OptionsDlg_ParseImageFiles(hWnd);
m_iDeviceListChanged = 0;
// set checkboxes
SendMessage(GetDlgItem(hWnd, IDC_CHK_FLOPPY),
(UINT)BM_SETCHECK,
(WPARAM)(g_iOptionEnableFloppy?BST_CHECKED:BST_UNCHECKED),
(LPARAM)0);
SendMessage(GetDlgItem(hWnd, IDC_CHK_CDROM),
(UINT)BM_SETCHECK,
(WPARAM)(g_iOptionEnableCDROM?BST_CHECKED:BST_UNCHECKED),
(LPARAM)0);
SendMessage(GetDlgItem(hWnd, IDC_CHK_PHYSICAL),
(UINT)BM_SETCHECK,
(WPARAM)(g_iOptionEnablePhysicalDisks?BST_CHECKED:BST_UNCHECKED),
(LPARAM)0);
SendMessage(GetDlgItem(hWnd, IDC_CHK_IMAGE),
(UINT)BM_SETCHECK,
(WPARAM)(g_iOptionEnableImages?BST_CHECKED:BST_UNCHECKED),
(LPARAM)0);
SendMessage(GetDlgItem(hWnd, IDC_CHK_RESCAN),
(UINT)BM_SETCHECK,
(WPARAM)(g_iOptionAutomaticRescan?BST_CHECKED:BST_UNCHECKED),
(LPARAM)0);
SendMessage(GetDlgItem(hWnd, IDC_CHK_LOGGING),
(UINT)BM_SETCHECK,
(WPARAM)(g_iOptionEnableLogging?BST_CHECKED:BST_UNCHECKED),
(LPARAM)0);
SendMessage(GetDlgItem(hWnd, IDC_CHK_BANKADAPTION),
(UINT)BM_SETCHECK,
(WPARAM)(g_iOptionBankAdaption?BST_CHECKED:BST_UNCHECKED),
(LPARAM)0);
// clear and init "BankSourceDevice" ComboBox
// first entry is "convert all device ids"
// here we do not skip "SCSI 3", which is the Ensoniq itself
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKSOURCEDEVICE),
(UINT)CB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKSOURCEDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"all devices");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKSOURCEDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"only Floppy");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKSOURCEDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"only SCSI 0");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKSOURCEDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"only SCSI 1");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKSOURCEDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"only SCSI 2");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKSOURCEDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"only SCSI 3 (unusual)");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKSOURCEDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"only SCSI 4");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKSOURCEDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"only SCSI 5");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKSOURCEDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"only SCSI 6");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKSOURCEDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"only SCSI 7");
int bankSourceDeviceListIndex = g_iOptionBankSourceDevice + 1;
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKSOURCEDEVICE),
(UINT)CB_SETCURSEL, (WPARAM)bankSourceDeviceListIndex, (LPARAM)0);
// clear and init "BankTargetDevice" ComboBox
// skip "SCSI 3", this is the Ensoniq itself
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKTARGETDEVICE),
(UINT)CB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKTARGETDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"Floppy");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKTARGETDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"SCSI 0");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKTARGETDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"SCSI 1");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKTARGETDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"SCSI 2");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKTARGETDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"SCSI 4");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKTARGETDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"SCSI 5");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKTARGETDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"SCSI 6");
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKTARGETDEVICE),
(UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)"SCSI 7");
int bankTargetDeviceListIndex = g_iOptionBankTargetDevice < 4 ? g_iOptionBankTargetDevice : (g_iOptionBankTargetDevice-1);
SendMessage(GetDlgItem(hWnd, IDC_CBO_BANKTARGETDEVICE),
(UINT)CB_SETCURSEL, (WPARAM)bankTargetDeviceListIndex, (LPARAM)0);
}
//----------------------------------------------------------------------------
// OptionsDlgProc
//
// This is the message processing function for the options dialog thread
//
// -> --
// <- TRUE, if the message was processed
// FALSE, if not
//----------------------------------------------------------------------------
INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
int iRetVal = FALSE;
// process messages
switch(uMsg)
{
case WM_INITDIALOG:
OptionsDlg_OnInitDialog(hwndDlg);
iRetVal = TRUE;
break;
case WM_CLOSE:
EndDialog(hwndDlg, IDCANCEL);
iRetVal = TRUE;
break;
case WM_COMMAND:
switch(wParam)
{
case IDC_BTN_UNMOUNT:
OptionsDlg_UnmountImage(hwndDlg);
iRetVal = TRUE;
break;
case IDC_BTN_MOUNT:
OptionsDlg_MountImage(hwndDlg);
iRetVal = TRUE;
break;
case IDC_BTN_OK:
OptionsDlg_OnOK(hwndDlg);
iRetVal = TRUE;
break;
case IDC_BTN_CANCEL:
OptionsDlg_OnCancel(hwndDlg);
iRetVal = TRUE;
break;
}
break;
default:
break;
}
return iRetVal;
lParam=lParam; // just to satisfy "unused parameter lParam" warning
}
//----------------------------------------------------------------------------
// CreateOptionsDialogModal
//
// Create a modal options dialog
//
// -> --
// <- ERR_OK
// ERR_CREATE_DLG
//----------------------------------------------------------------------------
int CreateOptionsDialogModal(HWND hParent)
{
int iResult;
LOG("CreateOptionsDialog(): ");
// create dialog from template
HRSRC hrsrc = FindResource(g_hInst, MAKEINTRESOURCE(IDD_DLG_OPTIONS),
RT_DIALOG);
HGLOBAL hglobal = LoadResource(g_hInst, hrsrc);
iResult = DialogBoxIndirectParam(g_hInst, (LPCDLGTEMPLATE)hglobal, hParent,
OptionsDlgProc, 0);
if(0==iResult)
{
LOG("DialogBoxIndirectParam() failed.\n");
return ERR_CREATE_DLG;
}
else
{
LOG("Dialog closed, return value=%d.\n", iResult);
}
return ERR_OK;
}