ciderpress/app/CreateSubdirDialog.cpp

64 lines
1.6 KiB
C++
Raw Normal View History

2007-03-27 17:47:10 +00:00
/*
* CiderPress
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
/*
* Implementation of CreateSubdirDialog.
*
* Gets the name from the user, validates it against the supplied
* GenericArchive, and returns.
*/
#include "stdafx.h"
#include "CreateSubdirDialog.h"
BEGIN_MESSAGE_MAP(CreateSubdirDialog, CDialog)
ON_WM_HELPINFO()
2007-03-27 17:47:10 +00:00
END_MESSAGE_MAP()
BOOL CreateSubdirDialog::OnInitDialog(void)
2007-03-27 17:47:10 +00:00
{
/* do the DoDataExchange stuff */
CDialog::OnInitDialog();
2007-03-27 17:47:10 +00:00
/* select the default text and set the focus */
CEdit* pEdit = (CEdit*) GetDlgItem(IDC_CREATESUBDIR_NEW);
2014-11-18 05:13:13 +00:00
ASSERT(pEdit != NULL);
pEdit->SetSel(0, -1);
pEdit->SetFocus();
2007-03-27 17:47:10 +00:00
return FALSE; // we set the focus
2007-03-27 17:47:10 +00:00
}
void CreateSubdirDialog::DoDataExchange(CDataExchange* pDX)
2007-03-27 17:47:10 +00:00
{
CString msg, failed;
2007-03-27 17:47:10 +00:00
CheckedLoadString(&failed, IDS_MB_APP_NAME);
2007-03-27 17:47:10 +00:00
/* put fNewName last so it gets the focus after failure */
DDX_Text(pDX, IDC_CREATESUBDIR_BASE, fBasePath);
DDX_Text(pDX, IDC_CREATESUBDIR_NEW, fNewName);
2007-03-27 17:47:10 +00:00
/* validate the path field */
if (pDX->m_bSaveAndValidate) {
if (fNewName.IsEmpty()) {
msg = L"You must specify a new name.";
goto fail;
}
2007-03-27 17:47:10 +00:00
msg = fpArchive->TestPathName(fpParentEntry, fBasePath, fNewName,
'\0');
if (!msg.IsEmpty())
goto fail;
}
2007-03-27 17:47:10 +00:00
return;
2007-03-27 17:47:10 +00:00
fail:
ASSERT(!msg.IsEmpty());
MessageBox(msg, failed, MB_OK);
pDX->Fail();
return;
2007-03-27 17:47:10 +00:00
}