void Cserverdlg::onbnclickedbuttonsavepath ()
{
CString str;
Browseinfo bi;
ZeroMemory (&bi, sizeof (Browseinfo)); function to set all parameters to 0, or null
Bi.hwndowner = GetSafeHwnd (); Bi.hwndowner = m_hwnd;
Bi.pidlroot = NULL; Set start search location, null default starts from the Desktop folder
Bi.pszdisplayname = szpath; The folder buffer address is selected
Bi.lpsztitle = _t ("Please select data file storage directory:"); The display text of the Browse Folder dialog box, which is used to prompt the function, function, and purpose of the Browse Folder dialog box.
Bi.ulflags = Bif_browseincludefiles; Files can also be selected
BI.LPFN = NULL;
Bi.lparam = 0;
bi.iimage = 0;
Pop-up Select Directory dialog box
Lpitemidlist LP = SHBrowseForFolder (&BI); The SHBrowseForFolder is used to display a dialog box that allows the user to select a folder, and the return value is a pointer to the path identifier of the selected folder relative to the selected root address.
if (LP && SHGetPathFromIDList (LP, szpath))
{
Str. Format (L "The directory you selected is%s", szpath);
MessageBox (str, L "Storage directory selection succeeded");
GetDlgItem (Idc_edit_save_path)->setwindowtext (szpath);
/* CString temp = L "\ \";
temp + = FILENAME;
FileName = szpath + temp;*/
/*cedit *edit = (CEdit *) GetDlgItem (Idc_edit_save_path);
Edit->setreadonly (TRUE); */
}
Else
{
MessageBox (l "Invalid directory, please re-select, or do not choose to store the directory, the data file is stored in the current path", "L" Operation Error ");
}
}
VC Click the button pop-up File path selection dialog box