Hi Takaki KAMEYAMA,
I suggest you still use CFileDialog
, it's not obsolete.
Although it cannot be dragged out directly in Toolbox, you could still create it using code.
Sample Code:
void CMFCApplication1Dlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
TCHAR szFilters[] = _T("MyType Files (*.my)|*.my|All Files (*.*)|*.*||");
// Create an Open dialog; the default file name extension is ".my".
CFileDialog fileDlg(FALSE, _T("my"), _T("*.my"),
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilters);
// Display the file dialog. When user clicks OK, fileDlg.DoModal()
// returns IDOK.
if (fileDlg.DoModal() == IDOK)
{
CString pathName = fileDlg.GetPathName();
// Implement opening and reading file in here.
//Change the window's title to the opened file's title.
CString fileName = fileDlg.GetFileTitle();
SetWindowText(fileName);
}
}
Result:
Regarding CMFCEditBrowseCtrl
this documentation states that when the user clicks the browse button, the control performs a custom action or displays a standard dialog box that contains a file browser or a folder browser.
In most cases it is only used for browsing files.
Best regards,
Elya
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.