void CMainFrame::OnFileImport()
{
CString filter_str = "Picture files (*.jpg)|*.jpg|Picture files (*.gif)|*.gif|BMP files (*.bmp)|*.bmp|All Files (*.*)|*.*||";
CFileDialog dlg(TRUE, "", "", OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT, filter_str, this);
TCHAR pszBuf[2048];
memset(pszBuf, 0, sizeof(pszBuf));
dlg.m_ofn.nMaxFile = 2048;
dlg.m_ofn.lpstrFile = pszBuf;
if (IDOK == dlg.DoModal())
{
CString strFilePath = dlg.GetPathName();
CString strDir = strFilePath;
if ( !PathIsDirectory(strFilePath) )
{
int nIndex = strFilePath.ReverseFind(_T('\\'));
strDir = strFilePath.Left(nIndex);
}
if ( m_strCurrentDirPath.GetLength() == strDir.GetLength() && m_strCurrentDirPath == strDir )
{
CConfig::GetConfig()->HYWMessageBox(m_hWnd, "相同的文件夹不能导入!", MSGTITLE, MB_OK | MB_ICONINFORMATION);
return;
}
POSITION nPos = dlg.GetStartPosition();
CMediator *pMediator = CMediator::GetMediatorPtr();
while (nPos != NULL)
{
strFilePath = dlg.GetNextPathName(nPos);
int nIndex = strFilePath.ReverseFind(_T('\\'));
CString strFileName = strFilePath.Right(strFilePath.GetLength() - nIndex);
strFileName.Replace(_T("%"), _T(""));
CString strNewFilePath = m_strCurrentDirPath + strFileName;
CConfig::GetConfig()->GetUniqueFilePath(strNewFilePath);
if ( CopyFile(strFilePath, strNewFilePath, TRUE) )
{
pMediator->AddImage(strNewFilePath);
}
}
//pMediator->Invalidate();
::SendMessage( m_wndSplitter.GetPane(0, 1)->m_hWnd, WM_USER_SETSTATUS, (WPARAM)2, NULL);
}
}
阅读(4785) | 评论(1) | 转发(0) |