标签:CFileDialog
CFileDialog dlg(TRUE, _T("*.bmp"), NULL, OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, _T("图片文件(*.bmp;*.png)|*.png;*.bmp| All Files (*.*) |*.*||"), NULL); // 打开文件对话框的标题名 dlg.m_ofn.lpstrTitle = _T("选择图片"); if (dlg.DoModal() == IDOK) { CString FilePathName = dlg.GetPathName(); //路径名+文件名 CString FileName = dlg.GetFileName(); //文件名 int Which = FileName.Find('.'); CString OnlyFileName = FileName.Left(Which); //无扩展的文件名 // 获取扩展名 int nPos = FileName.ReverseFind('.'); CString csFileExtName = FileName.Right(FileName.GetLength() - nPos - 1); m_strUserPicName = strUserName + _T(".") + csFileExtName; m_strUserPicPath = GetAppllicationPath() +_T("User\\")+ m_strUserPicName; BOOL ret = CopyFile(FilePathName, m_strUserPicPath,TRUE); CRect rt; m_picUserIcon.GetClientRect(&rt); this->InvalidateRect(rt); } else { return; }标签:CFileDialog
原文地址:http://blog.51cto.com/9233403/2094577