1. The MFC Midpoint dialog box displays a path and file saved as:
void Cpatchdlg::onbnclickedbtnpath () {//once to select Save As a path M_strsavepath = ""; Browseinfo bi; ZeroMemory (&bi, sizeof (Browseinfo)); Bi.hwndowner = M_hwnd;bi.ulflags = bif_returnonlyfsdirs; Lpitemidlist pidl = SHBrowseForFolder (&BI); BOOL bRet = FALSE; TCHAR szfolder[max_path*2];szfolder[0] = _t (' n '), if (pidl) {if (SHGetPathFromIDList (Pidl, szfolder)) BRet = True;i Malloc *pmalloc = null;if (SUCCEEDED (Shgetmalloc (&pmalloc)) && pmalloc) {pmalloc->free (pidl);p malloc- >release ();}} M_strsavepath = szfolder;//The directory path selected UpdateData (FALSE);
The following four lines indicate that the file name and path are returned by selecting a file;//cfiledialog dlg (TRUE);///true is the Open dialog box, False is the Save As dialog box//if (dlg. DoModal () ==idok)//m_strsavepath=dlg. GetPathName ();//updatedata (FALSE);}
C + + code snippets (accumulation)