Chinaunix首页 | 论坛 | 博客
  • 博客访问: 566198
  • 博文数量: 97
  • 博客积分: 5090
  • 博客等级: 大校
  • 技术积分: 969
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-01 14:56
文章分类

全部博文(97)

文章存档

2011年(1)

2009年(1)

2008年(14)

2007年(37)

2006年(44)

我的朋友

分类: WINDOWS

2008-04-18 11:54:24


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);
    }
}

阅读(4763) | 评论(1) | 转发(0) |
0

上一篇:VC保存文件对话框

下一篇:VC遍历文件夹

给主人留下些什么吧!~~

chinaunix网友2009-04-28 17:14:28

PathIsDirectory': identifier not found