Fixed bug in XTA driver.

Fixed string-loading issue.
Fixes for handling file dialog, filters, etc.
Changed the return value of dlg_file so we can use its RO flag.
Removed the additional _WP statusbar menu items (no longer needed with new RO handling.)
This commit is contained in:
waltje
2018-05-11 21:31:30 -04:00
parent ef2772b629
commit d393e95f8f
12 changed files with 114 additions and 95 deletions

View File

@@ -8,7 +8,7 @@
*
* Main emulator module where most things are controlled.
*
* Version: @(#)pc.c 1.0.41 2018/05/09
* Version: @(#)pc.c 1.0.42 2018/05/11
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -356,11 +356,10 @@ pc_version(const char *platform)
void
pc_path(wchar_t *dst, int sz, const wchar_t *src)
{
const wchar_t *str = src;
wchar_t *ptr = dst;
int i = wcslen(usr_path);
if ((src != NULL) && !wcsncasecmp(src, usr_path, i))
src += i;
/*
* Fix all the slashes.
*
@@ -368,18 +367,21 @@ pc_path(wchar_t *dst, int sz, const wchar_t *src)
* now convert ALL paths to the latter format, so it
* is always the same.
*/
if (src == NULL)
src = dst;
while ((sz > 0) && (*src != L'\0')) {
if (*src == L'\\')
*dst = L'/';
if (str == NULL)
str = ptr;
while ((sz > 0) && (*str != L'\0')) {
if (*str == L'\\')
*ptr = L'/';
else
*dst = *src;
src++;
dst++;
*ptr = *str;
str++;
ptr++;
sz--;
}
*dst = L'\0';
*ptr = L'\0';
if ((src != NULL) && !wcsncasecmp(dst, usr_path, i))
wcscpy(dst, &dst[i]);
}

View File

@@ -8,7 +8,7 @@
*
* Define the various UI functions.
*
* Version: @(#)ui.h 1.0.8 2018/05/09
* Version: @(#)ui.h 1.0.9 2018/05/11
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -61,6 +61,11 @@
#define MBX_FATAL 0x20
#define MBX_ANSI 0x80
/* FileDialog flags. */
#define DLG_FILE_LOAD 0x00
#define DLG_FILE_SAVE 0x01
#define DLG_FILE_RO 0x80
/* Status Bar definitions. */
#define SB_ICON_WIDTH 24
#define SB_FLOPPY 0x00

View File

@@ -11,7 +11,7 @@
* This code is called by the UI frontend modules, and, also,
* depends on those same modules for lower-level functions.
*
* Version: @(#)ui_main.c 1.0.14 2018/05/09
* Version: @(#)ui_main.c 1.0.15 2018/05/11
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -497,17 +497,18 @@ ui_menu_command(int idm)
/* FIXME: need to fix these.. */
case IDM_LOAD: /* TOOLS menu */
plat_pause(1);
if (! dlg_file(get_string(IDS_2160), NULL, temp, 0) &&
(ui_msgbox(MBX_QUESTION, (wchar_t *)IDS_2051) == 0)) {
i = dlg_file(get_string(IDS_2160), NULL, temp, DLG_FILE_LOAD);
if (i && (ui_msgbox(MBX_QUESTION, (wchar_t *)IDS_2051) == 0)) {
pc_reload(temp);
ui_menu_reset_all();
config_ro = !!(i & DLG_FILE_RO);
}
plat_pause(0);
break;
case IDM_SAVE: /* TOOLS menu */
plat_pause(1);
if (! dlg_file(get_string(IDS_2160), NULL, temp, 1)) {
if (dlg_file(get_string(IDS_2160), NULL, temp, DLG_FILE_SAVE)) {
config_write(temp);
}
plat_pause(0);

View File

@@ -8,7 +8,7 @@
*
* Platform-independent resource identifiers.
*
* Version: @(#)ui_resource.h 1.0.7 2018/05/09
* Version: @(#)ui_resource.h 1.0.8 2018/05/11
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -167,9 +167,8 @@
#define IDM_FLOPPY_IMAGE_NEW (IDM_SBAR + 0x0000)
#define IDM_FLOPPY_IMAGE_EXISTING (IDM_SBAR + 0x0100)
#define IDM_FLOPPY_IMAGE_EXISTING_WP (IDM_SBAR + 0x0200)
#define IDM_FLOPPY_EXPORT_TO_86F (IDM_SBAR + 0x0300)
#define IDM_FLOPPY_EJECT (IDM_SBAR + 0x0400)
#define IDM_FLOPPY_EXPORT_TO_86F (IDM_SBAR + 0x0200)
#define IDM_FLOPPY_EJECT (IDM_SBAR + 0x0300)
#define IDM_CDROM_MUTE (IDM_SBAR + 0x0800)
#define IDM_CDROM_EMPTY (IDM_SBAR + 0x0900)
@@ -179,15 +178,13 @@
#define IDM_ZIP_IMAGE_NEW (IDM_SBAR + 0x1000)
#define IDM_ZIP_IMAGE_EXISTING (IDM_SBAR + 0x1100)
#define IDM_ZIP_IMAGE_EXISTING_WP (IDM_SBAR + 0x1200)
#define IDM_ZIP_EJECT (IDM_SBAR + 0x1300)
#define IDM_ZIP_RELOAD (IDM_SBAR + 0x1400)
#define IDM_ZIP_EJECT (IDM_SBAR + 0x1200)
#define IDM_ZIP_RELOAD (IDM_SBAR + 0x1300)
#define IDM_RDISK_EJECT (IDM_SBAR + 0x1800)
#define IDM_RDISK_RELOAD (IDM_SBAR + 0x1900)
#define IDM_RDISK_SEND_CHANGE (IDM_SBAR + 0x1a00)
#define IDM_RDISK_IMAGE (IDM_SBAR + 0x1b00)
#define IDM_RDISK_IMAGE_WP (IDM_SBAR + 0x1c00)
#define IDM_SOUND (IDM_SBAR + 8192)
@@ -304,13 +301,13 @@
#define IDS_2160 2160 // "Configuration files (*.CF.."
#define IDS_2161 2161 // "&New image..."
#define IDS_2162 2162 // "&Existing image..."
#define IDS_2163 2163 // "Existing image (&Write-pr..."
#define IDS_2163 2163 // "[WP]"
#define IDS_2164 2164 // "E&ject"
#define IDS_2165 2165 // "&Mute"
#define IDS_2166 2166 // "E&mpty"
#define IDS_2167 2167 // "&Reload previous image"
#define IDS_2168 2168 // "&Image..."
#define IDS_2169 2169 // "Image (&Write-protected)..."
/* IDS_2169 available */
#define IDS_2170 2170 // "Check BPB"
#define IDS_2171 2171 // "Unable to initialize Flui.."
#define IDS_2172 2172 // "E&xport to 86F..."

View File

@@ -8,7 +8,7 @@
*
* Common UI support functions for the Status Bar module.
*
* Version: @(#)ui_stbar.c 1.0.6 2018/05/09
* Version: @(#)ui_stbar.c 1.0.7 2018/05/11
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -215,6 +215,8 @@ ui_sb_tip_update(int tag)
str = get_string(IDS_2057); /*"empty"*/
swprintf(tip, sizeof_w(tip),
get_string(IDS_2158), drive+1, temp, str);
if (ui_writeprot[drive])
wcscat(tip, get_string(IDS_2163));
break;
case SB_CDROM:
@@ -252,6 +254,8 @@ ui_sb_tip_update(int tag)
str = get_string(IDS_2057); /*"empty"*/
swprintf(tip, sizeof_w(tip),
get_string(IDS_2177), drive+1, type, str);
if (zip_drives[drive].ui_writeprot)
wcscat(tip, get_string(IDS_2163));
break;
case SB_RDISK:
@@ -261,6 +265,8 @@ ui_sb_tip_update(int tag)
str = get_string(IDS_2057); /*"empty"*/
swprintf(tip, sizeof_w(tip),
get_string(IDS_4115), drive, str);
if (0)
wcscat(tip, get_string(IDS_2163));
break;
case SB_HDD:
@@ -269,6 +275,8 @@ ui_sb_tip_update(int tag)
str = get_string(id);
swprintf(tip, sizeof_w(tip),
get_string(IDS_4096), str);
if (0)
wcscat(tip, get_string(IDS_2163));
break;
case SB_NETWORK:
@@ -320,8 +328,6 @@ menu_floppy(int part, int drive)
sb_menu_add_item(part, -1, NULL);
sb_menu_add_item(part, IDM_FLOPPY_IMAGE_EXISTING | drive,
get_string(IDS_2162));
sb_menu_add_item(part, IDM_FLOPPY_IMAGE_EXISTING_WP | drive,
get_string(IDS_2163));
sb_menu_add_item(part, -1, NULL);
sb_menu_add_item(part, IDM_FLOPPY_EXPORT_TO_86F | drive,
get_string(IDS_2172));
@@ -405,8 +411,6 @@ menu_zip(int part, int drive)
sb_menu_add_item(part, -1, NULL);
sb_menu_add_item(part, IDM_ZIP_IMAGE_EXISTING | drive,
get_string(IDS_2162));
sb_menu_add_item(part, IDM_ZIP_IMAGE_EXISTING_WP | drive,
get_string(IDS_2163));
sb_menu_add_item(part, -1, NULL);
sb_menu_add_item(part, IDM_ZIP_EJECT | drive, get_string(IDS_2164));
sb_menu_add_item(part, IDM_ZIP_RELOAD | drive, get_string(IDS_2167));
@@ -435,8 +439,6 @@ menu_remov(int part, int drive)
sb_menu_add_item(part, -1, NULL);
sb_menu_add_item(part, IDM_RDISK_IMAGE | drive,
get_string(IDS_2168));
sb_menu_add_item(part, IDM_RDISK_IMAGE_WP | drive,
get_string(IDS_2169));
}
@@ -791,6 +793,7 @@ ui_sb_menu_command(int idm, int tag)
{
wchar_t temp[512];
int new_cdrom_drive;
wchar_t *str;
int drive;
int part;
int i;
@@ -805,15 +808,16 @@ ui_sb_menu_command(int idm, int tag)
break;
case IDM_FLOPPY_IMAGE_EXISTING:
case IDM_FLOPPY_IMAGE_EXISTING_WP:
drive = tag & 0x0003;
part = find_tag(SB_FLOPPY | drive);
if (part == -1) break;
i = (idm == IDM_FLOPPY_IMAGE_EXISTING_WP) ? 0x80 : 0;
if (! dlg_file(get_string(IDS_2159),
floppyfns[drive], temp, i))
ui_sb_mount_floppy(drive, part, i ? 1 : 0, temp);
str = floppyfns[drive];
i = dlg_file(get_string(IDS_2159), str, temp, DLG_FILE_LOAD);
if (i) {
ui_sb_mount_floppy(drive, part,
!!(i & DLG_FILE_RO), temp);
}
break;
case IDM_FLOPPY_EJECT:
@@ -834,7 +838,8 @@ ui_sb_menu_command(int idm, int tag)
part = find_tag(SB_FLOPPY | drive);
if (part == -1) break;
if (! dlg_file(get_string(IDS_2173), floppyfns[drive], temp, 1)) {
str = floppyfns[drive];
if (dlg_file(get_string(IDS_2173), str, temp, DLG_FILE_SAVE)) {
plat_pause(1);
if (! d86f_export(drive, temp))
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_4108);
@@ -869,13 +874,14 @@ ui_sb_menu_command(int idm, int tag)
part = find_tag(SB_CDROM | drive);
if (part == -1) break;
if (dlg_file(get_string(IDS_2075),
cdrom_image[drive].image_path, temp, 0x80)) break;
str = cdrom_image[drive].image_path;
if (! dlg_file(get_string(IDS_2075), str, temp,
DLG_FILE_LOAD|DLG_FILE_RO)) break;
cdrom_drives[drive].prev_host_drive = cdrom_drives[drive].host_drive;
if (! cdrom_image[drive].prev_image_path)
cdrom_image[drive].prev_image_path = (wchar_t *)malloc(1024);
wcscpy(cdrom_image[drive].prev_image_path, cdrom_image[drive].image_path);
wcscpy(cdrom_image[drive].prev_image_path, str);
cdrom_drives[drive].handler->exit(drive);
cdrom_close(drive);
image_open(drive, temp);
@@ -946,15 +952,16 @@ ui_sb_menu_command(int idm, int tag)
break;
case IDM_ZIP_IMAGE_EXISTING:
case IDM_ZIP_IMAGE_EXISTING_WP:
drive = tag & 0x0003;
part = find_tag(SB_ZIP | drive);
if (part == -1) break;
i = (idm == IDM_ZIP_IMAGE_EXISTING_WP) ? 0x80 : 0;
if (dlg_file(get_string(IDS_2175),
zip_drives[drive].image_path, temp, i)) break;
ui_sb_mount_zip(drive, part, i ? 1 : 0, temp);
str = zip_drives[drive].image_path;
i = dlg_file(get_string(IDS_2175), str, temp, DLG_FILE_LOAD);
if (i) {
ui_sb_mount_zip(drive, part,
!!(i & DLG_FILE_RO), temp);
}
break;
case IDM_ZIP_EJECT:
@@ -983,19 +990,18 @@ ui_sb_menu_command(int idm, int tag)
break;
case IDM_RDISK_IMAGE:
case IDM_RDISK_IMAGE_WP:
drive = tag & 0x001f;
part = find_tag(idm | drive);
i = (idm == IDM_RDISK_IMAGE_WP) ? 0x80 : 0;
if (dlg_file(get_string(IDS_4106),
hdd[drive].fn, temp, i)) break;
str = hdd[drive].fn;
i = dlg_file(get_string(IDS_4106), str, temp, DLG_FILE_LOAD);
if (! i) break;
removable_disk_unload(drive);
memset(hdd[drive].fn, 0x00, sizeof(hdd[drive].fn));
wcscpy(hdd[drive].fn, temp);
hdd[drive].wp = i ? 1 : 0;
hdd[drive].wp = !!(i & DLG_FILE_RO);
scsi_loadhd(hdd[drive].id.scsi.id, hdd[drive].id.scsi.lun, drive);
scsi_disk_insert(drive);

View File

@@ -8,7 +8,7 @@
*
* Application resource script for Windows.
*
* Version: @(#)VARCem.rc 1.0.27 2018/05/10
* Version: @(#)VARCem.rc 1.0.28 2018/05/11
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -954,7 +954,7 @@ BEGIN
IDS_2072 "Hard disks"
IDS_2073 "Floppy drives"
IDS_2074 "Other removable devices"
IDS_2075 "CD-ROM images (*.ISO;*.CUE)\0*.ISO;*.CUE\0All files (*.*)\0*.*\0"
IDS_2075 "CD-ROM images\0*.iso;*.cue\0All files (*.*)\0*.*\0"
IDS_2076 "Host CD/DVD Drive (%c:)"
IDS_2077 "Click to capture mouse"
IDS_2078 "Press F8+F12 to release mouse"
@@ -1032,24 +1032,24 @@ BEGIN
IDS_2156 "%" PRIu64
IDS_2157 "%" PRIu64 " MB (CHS: %u, %u, %u)"
IDS_2158 "Floppy %i (%s): %ls"
IDS_2159 "All images (*.0??;*.1??;*.360;*.720;*.86F;*.BIN;*.CQ?;*.DSK;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.XDF)\0*.0??;*.1??;*.360;*.720;*.86F;*.BIN;*.CQ?;*.DSK;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.XDF\0Advanced sector images (*.IMD;*.JSON;*.TD0)\0*.IMD;*.JSON;*.TD0\0Basic sector images (*.0??;*.1??;*.360;*.720;*.BIN;*.CQ?;*.DSK;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?)\0*.0??;*.1??;*.360;*.720;*.BIN;*.CQ?;*.DSK;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?\0Flux images (*.FDI)\0*.FDI\0Surface images (*.86F)\0*.86F\0All files (*.*)\0*.*\0"
IDS_2160 "Configuration files (*.VARC)\0*.VARC\0All files (*.*)\0*.*\0"
IDS_2159 "All images\0*.0??;*.1??;*.360;*.720;*.86f;*.bin;*.cq?;*.dsk;*.flp;*.hdm;*.ima;*.json;*.td0;*.*fd?;*.xdf\0Advanced sector images\0*.imd;*.json;*.td0\0Basic sector images\0*.0??;*.1??;*.360;*.720;*.bin;*.cq?;*.dsk;*.flp;*.hdm;*.im?;*.xdf;*.*fd?\0Flux images\0*.fdi\0Surface images\0*.86f\0All files\0*.*\0"
IDS_2160 "Configuration files\0*.varc\0All files\0*.*\0"
IDS_2161 "&New image..."
IDS_2162 "&Existing image..."
IDS_2163 "Existing image (&Write-protected)..."
IDS_2163 " [Write Protected]"
IDS_2164 "E&ject"
IDS_2165 "&Mute"
IDS_2166 "E&mpty"
IDS_2167 "&Reload previous image"
IDS_2168 "&Image..."
IDS_2169 "Image (&Write-protected)..."
/* 2169 available */
IDS_2170 "Check BPB"
IDS_2171 "Unable to initialize FluidSynth, make sure you have the following library\nin your program folder:\n\nlibfluidsynth.dll"
IDS_2172 "E&xport to 86F..."
IDS_2173 "Surface images (*.86F)\0*.86F\0"
IDS_2174 "All images (*.86F;*.DSK;*.FLP;*.IM?;*.*FD?)\0*.86F;*.DSK;*.FLP;*.IM?;*.*FD?\0Basic sector images (*.DSK;*.FLP;*.IM?;*.*FD?)\0*.DSK;*.FLP;*.IM?;*.IMG;*.*FD?\0Surface images (*.86F)\0*.86F\0"
IDS_2175 "ZIP images (*.IM?;*.ZDI)\0*.IM?;*.ZDI\0All files (*.*)\0*.*\0"
IDS_2176 "ZIP images (*.IM?;*.ZDI)\0*.IM?;*.ZDI\0"
IDS_2173 "Surface images\0*.86f\0"
IDS_2174 "All images\0*.86f;*.dsk;*.flp;*.im?;*.*fd?\0Basic sector images\0*.dsk;*.flp;*.im?;*.img;*.*fd?\0Surface images\0*.86f\0"
IDS_2175 "ZIP images\0*.im?;*.zdi\0All files\0*.*\0"
IDS_2176 "ZIP images\0*.im?;*.zdi\0"
IDS_2177 "ZIP %i (%03i): %ls"
IDS_2178 "Unable to initialize OpenAL, make sure you have the following library\nin your program folder:\n\nlibopenal-1.dll"
IDS_2179 "Speed:"
@@ -1067,7 +1067,7 @@ BEGIN
IDS_4103 "Add Existing Hard Disk"
IDS_4104 "Attempting to create a HDI image larger than 4 GB"
IDS_4105 "Attempting to create a spuriously large hard disk image"
IDS_4106 "Hard disk images (*.HD?;*.IM?;*.VHD)\0*.HD?;*.IM?;*.VHD\0All files (*.*)\0*.*\0"
IDS_4106 "Hard disk images\0*.hd?;*.im?;*.vhd\0All files\0*.*\0"
IDS_4107 "Unable to open the file for read"
IDS_4108 "Unable to open the file for write"
IDS_4109 "HDI or HDX image with a sector size that is not 512 are not supported"

View File

@@ -253,7 +253,7 @@ OPTS := $(EXTRAS) $(STUFF) $(VCOPTS) \
-D_CRT_SECURE_NO_WARNINGS \
$(WPCAPINC) $(SYSINC)
AFLAGS := /arch:SSE2
RFLAGS :=
RFLAGS := /n
COPTS := -W3
CXXOPTS := -EHsc
DOPTS :=

View File

@@ -8,7 +8,7 @@
*
* Platform main support module for Windows.
*
* Version: @(#)win.c 1.0.12 2018/05/10
* Version: @(#)win.c 1.0.13 2018/05/11
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -139,7 +139,8 @@ LoadCommonStrings(void)
tbl->id = i;
str = (wchar_t *)malloc((c + 1) * sizeof(wchar_t));
wcscpy(str, temp);
memset(str, 0x00, (c + 1) * sizeof(wchar_t));
memcpy(str, temp, c * sizeof(wchar_t));
tbl->str = str;
tbl++;

View File

@@ -12,7 +12,7 @@
* and builds a complete Win32 DIALOG resource block in a
* buffer in memory, and then passes that to the API handler.
*
* Version: @(#)win_devconf.c 1.0.16 2018/05/04
* Version: @(#)win_devconf.c 1.0.17 2018/05/11
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -425,7 +425,7 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
if (ws[c] == L'|')
ws[c] = 0;
if (! dlg_file_ex(hdlg, ws, NULL, temp, 0))
if (dlg_file_ex(hdlg, ws, NULL, temp, DLG_FILE_LOAD))
SendMessage(h, WM_SETTEXT, 0, (LPARAM)temp);
}
break;

View File

@@ -191,12 +191,13 @@ dlg_file_hook(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
/* Implement the main GetFileName dialog. */
int
dlg_file_ex(HWND hwnd, const wchar_t *filt, const wchar_t *ifn, wchar_t *fn, int save)
dlg_file_ex(HWND h, const wchar_t *f, const wchar_t *ifn, wchar_t *fn, int fl)
{
wchar_t temp[512];
OPENFILENAME ofn;
BOOL r;
DWORD err;
BOOL r;
int ret;
/* Clear the temp path. */
memset(temp, 0x00, sizeof(temp));
@@ -204,7 +205,7 @@ dlg_file_ex(HWND hwnd, const wchar_t *filt, const wchar_t *ifn, wchar_t *fn, int
/* Initialize OPENFILENAME. */
memset(&ofn, 0x00, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.hwndOwner = h;
ofn.lpfnHook = dlg_file_hook;
/* This is the buffer in which to place the resulting filename. */
@@ -212,7 +213,7 @@ dlg_file_ex(HWND hwnd, const wchar_t *filt, const wchar_t *ifn, wchar_t *fn, int
ofn.nMaxFile = sizeof_w(temp);
/* Set up the "file types" filter. */
ofn.lpstrFilter = filt;
ofn.lpstrFilter = f;
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
@@ -221,20 +222,20 @@ dlg_file_ex(HWND hwnd, const wchar_t *filt, const wchar_t *ifn, wchar_t *fn, int
if (ifn == NULL)
ifn = usr_path;
ofn.lpstrInitialDir = ifn;
wcscpy(fn, ifn);
/* Set up the flags for this dialog. */
r = (save & 0x80) ? TRUE : FALSE;
save &= 0x7f;
r = (fl & DLG_FILE_RO) ? TRUE : FALSE;
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER | OFN_PATHMUSTEXIST;
if (! save) {
if (! (fl & DLG_FILE_SAVE)) {
ofn.Flags |= OFN_FILEMUSTEXIST;
if (r == TRUE)
ofn.Flags |= OFN_READONLY;
}
/* Display the Open dialog box. */
if (save)
if (fl & DLG_FILE_SAVE)
r = GetSaveFileName(&ofn);
else
r = GetOpenFileName(&ofn);
@@ -249,23 +250,28 @@ dlg_file_ex(HWND hwnd, const wchar_t *filt, const wchar_t *ifn, wchar_t *fn, int
/* Remember the file type for next time. */
filterindex = ofn.nFilterIndex;
return(0);
ret = 1;
if (ofn.Flags & OFN_READONLY)
ret |= DLG_FILE_RO;
} else {
/* If an error occurred, log this. */
if ((err = CommDlgExtendedError()) != NO_ERROR) {
sprintf((char *)temp,
"%sFile(%ls, %02x):\n\n error 0x%08lx",
(fl & DLG_FILE_SAVE)?"Save":"Open", ifn, fl, err);
pclog("%s\n", (char *)temp);
(void)ui_msgbox(MBX_ERROR|MBX_ANSI, (char *)temp);
}
ret = 0;
}
/* If an error occurred, log this. */
if ((err = CommDlgExtendedError()) != NO_ERROR) {
sprintf((char *)temp,
"OpenFile(%ls, %d):\n\n error 0x%08lx", ifn, save, err);
pclog("%s\n", (char *)temp);
(void)ui_msgbox(MBX_ERROR|MBX_ANSI, (char *)temp);
}
return(1);
return(ret);
}
int
dlg_file(const wchar_t *filt, const wchar_t *ifn, wchar_t *ofn, int save)
dlg_file(const wchar_t *filt, const wchar_t *ifn, wchar_t *ofn, int flags)
{
return(dlg_file_ex(hwndMain, filt, ifn, ofn, save));
return(dlg_file_ex(hwndMain, filt, ifn, ofn, flags));
}

View File

@@ -8,7 +8,7 @@
*
* Implementation of the New Floppy Image dialog.
*
* Version: @(#)win_new_floppy.c 1.0.14 2018/05/09
* Version: @(#)win_new_floppy.c 1.0.15 2018/05/11
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -181,7 +181,7 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
return TRUE;
case IDC_CFILE:
if (! dlg_file_ex(hdlg, get_string(is_zip ? IDS_2176 : IDS_2174), NULL, temp_path, 1)) {
if (dlg_file_ex(hdlg, get_string(is_zip ? IDS_2176 : IDS_2174), NULL, temp_path, DLG_FILE_SAVE)) {
if (! wcschr(temp_path, L'.')) {
if (wcslen(temp_path) && (wcslen(temp_path) <= 256)) {
twcs = &temp_path[wcslen(temp_path)];

View File

@@ -8,7 +8,7 @@
*
* Implementation of the Settings dialog.
*
* Version: @(#)win_settings_disk.h 1.0.8 2018/05/09
* Version: @(#)win_settings_disk.h 1.0.9 2018/05/11
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -1065,7 +1065,8 @@ hd_add_ok_common:
return TRUE;
case IDC_CFILE:
if (! dlg_file_ex(hdlg, get_string(IDS_4106), NULL, temp_path, !(existing & 1))) {
b = (existing&1)?DLG_FILE_LOAD:DLG_FILE_SAVE;
if (dlg_file_ex(hdlg, get_string(IDS_4106), NULL, temp_path, b)) {
if (! wcschr(temp_path, L'.')) {
if (wcslen(temp_path) && (wcslen(temp_path) <= 256)) {
twcs = &temp_path[wcslen(temp_path)];
@@ -1076,7 +1077,7 @@ hd_add_ok_common:
}
}
if (!(existing & 1)) {
if (! (existing & 1)) {
f = _wfopen(temp_path, L"rb");
if (f != NULL) {
fclose(f);