设置图片保存路径
CString cPicPath;
LPITEMIDLIST pidlRoot=NULL;
SHGetSpecialFolderLocation(m_hWnd,CSIDL_DRIVES,&pidlRoot);
BROWSEINFO bi; //the input parameters needed
CString strDisplayName;
bi.hwndOwner=GetSafeHwnd(); //get handle value of parent window
bi.pidlRoot=pidlRoot;
bi.pszDisplayName=strDisplayName.GetBuffer(MAX_PATH+1); //get buffer pointer
char szLan[32] = {0};
sprintf_s(szLan, "文件夹");
bi.lpszTitle=szLan; //set title
bi.ulFlags=BIF_RETURNONLYFSDIRS; //set flag
bi.lpfn=NULL;
bi.lParam=0;
bi.iImage=0; //The above parameters are not related to the settings, better set up,
LPITEMIDLIST lpIDList= SHBrowseForFolder(&bi); //open dialog
strDisplayName.ReleaseBuffer(); //correspond to GetBuffer()
char pPath[MAX_PATH];
CString Str;
if (lpIDList)
{
SHGetPathFromIDList (lpIDList, pPath);
Str=pPath;
}
if (Str != "")
{
cPicPath = Str;
SetDlgItemText(IDC_EDIT_PICPATH,cPicPath);
}
打开图片文件路径
CFileDialog mFileDlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,"JPG(*.jpg)|*.jpg|位图文件(*.bmp)|*.bmp|所有文件(*.*)|*.*", NULL);
if (mFileDlg.DoModal() == IDOK)
{
CString cFilePath = mFileDlg.GetPathName();
GetDlgItem(IDC_EDIT_PICPATH)->SetWindowText(cFilePath);
CString cFileName = mFileDlg.GetFileName();
}
打开->选择文件对话框
最新推荐文章于 2024-05-13 14:26:22 发布