VC Click the button pop-up File path selection dialog box

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.