From 7b70767a1fab99ce4a857a2fff0ec2647544850b Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 17 Dec 2014 13:31:50 -0800 Subject: [PATCH] Better error message when extracting files The file extraction dialog allows you to select file parts, so you can choose to exclude resource forks or just extract disk images. If you don't choose any parts, nothing will extract, and you get a confusingly generic message about nothing matching the criteria. This adds a specific error message for the case where no parts are selected. --- app/ChooseAddTargetDialog.cpp | 4 ++-- app/CiderPress.rc | 1 + app/ExtractOptionsDialog.cpp | 20 ++++++++++++++++---- app/resource.h | 3 ++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/ChooseAddTargetDialog.cpp b/app/ChooseAddTargetDialog.cpp index 614fd30..9ec1025 100644 --- a/app/ChooseAddTargetDialog.cpp +++ b/app/ChooseAddTargetDialog.cpp @@ -64,7 +64,7 @@ void ChooseAddTargetDialog::DoDataExchange(CDataExchange* pDX) HTREEITEM selected; selected = pTree->GetSelectedItem(); if (selected == NULL) { - errMsg = "Please select a disk or subdirectory to add files to."; + errMsg = L"Please select a disk or subdirectory to add files to."; MessageBox(errMsg, appName, MB_OK); pDX->Fail(); return; @@ -73,7 +73,7 @@ void ChooseAddTargetDialog::DoDataExchange(CDataExchange* pDX) DiskFSTree::TargetData* pTargetData; pTargetData = (DiskFSTree::TargetData*) pTree->GetItemData(selected); if (!pTargetData->selectable) { - errMsg = "You can't add files there."; + errMsg = L"You can't add files there."; MessageBox(errMsg, appName, MB_OK); pDX->Fail(); return; diff --git a/app/CiderPress.rc b/app/CiderPress.rc index 0fccf72..51110fb 100644 --- a/app/CiderPress.rc +++ b/app/CiderPress.rc @@ -2110,6 +2110,7 @@ BEGIN IDS_VALID_VOLNAME_HFS "Valid HFS volume names are 1-27 characters long, and may not contain a colon (:)." IDS_VALID_FILENAME_HFS "Valid HFS filenames are 1-31 characters long, and do not contain colons (':')." IDS_PASTE_SPECIAL_COUNT "%d files in clipboard" + IDS_NO_FORKS_SPECIFIED "You must select at least one item in ""Parts to extract""." END STRINGTABLE diff --git a/app/ExtractOptionsDialog.cpp b/app/ExtractOptionsDialog.cpp index 417f110..3ecf95d 100644 --- a/app/ExtractOptionsDialog.cpp +++ b/app/ExtractOptionsDialog.cpp @@ -45,6 +45,7 @@ BOOL ExtractOptionsDialog::OnInitDialog(void) selStr.Format((LPCWSTR) countFmt, fSelectedCount); pWnd->SetWindowText(selStr); + // disable "extract selection" when nothing is selected if (fSelectedCount == 0) pWnd->EnableWindow(FALSE); } @@ -65,10 +66,8 @@ BOOL ExtractOptionsDialog::OnInitDialog(void) void ExtractOptionsDialog::DoDataExchange(CDataExchange* pDX) { - /* - * Should probably verify that fFilesToExtract is not set to kExtractSelection - * when fSelectedCount is zero. - */ + CDialog::DoDataExchange(pDX); + DDX_Text(pDX, IDC_EXT_PATH, fExtractPath); DDX_Radio(pDX, IDC_EXT_SELECTED, fFilesToExtract); @@ -88,6 +87,19 @@ void ExtractOptionsDialog::DoDataExchange(CDataExchange* pDX) DDX_Check(pDX, IDC_EXT_CONVHIGHASCII, fConvHighASCII); DDX_Check(pDX, IDC_EXT_OVERWRITE_EXIST, fOverwriteExisting); + + if (pDX->m_bSaveAndValidate) { + if (!fIncludeDataForks && !fIncludeRsrcForks && !fIncludeDiskImages) { + CString appName, errMsg; + + CheckedLoadString(&appName, IDS_MB_APP_NAME); + + CheckedLoadString(&errMsg, IDS_NO_FORKS_SPECIFIED); + MessageBox(errMsg, appName, MB_OK); + pDX->Fail(); + return; + } + } } void ExtractOptionsDialog::OnConfigPreserve(void) diff --git a/app/resource.h b/app/resource.h index 02ad768..47124cb 100644 --- a/app/resource.h +++ b/app/resource.h @@ -1,5 +1,5 @@ //{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. +// Microsoft Visual C++ generated include file. // Used by CiderPress.rc // #define IDR_MAINFRAME 102 @@ -498,6 +498,7 @@ #define IDS_VALID_VOLNAME_HFS 2152 #define IDS_VALID_FILENAME_HFS 2153 #define IDS_PASTE_SPECIAL_COUNT 2154 +#define IDS_NO_FORKS_SPECIFIED 2155 #define IDM_FILE_NEW_ARCHIVE 40001 #define IDM_FILE_OPEN 40002 #define IDM_FILE_CLOSE 40003