如何在运行时在mfc中显示编辑控件中文件的路径 [英] How to display the path of the file in the edit control at runtime in mfc

查看:68
本文介绍了如何在运行时在mfc中显示编辑控件中文件的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮我解决这个问题

其实这个场景是我们只需要点击编辑按钮就可以显示文件的路径。

can any one help me to solve this
Actually the scenario is when we just have a click in the edit ctrl the path of the file has to be displayed.

推荐答案

void CRFileDlg :: OnBnClickedButton1()

{

/ /只需一个编辑控件和按钮,添加EventHandler按钮。



BROWSEINFO bi = {0};

bi.lpszTitle = _T (浏览文件夹);

LPITEMIDLIST pidl = SHBrowseForFolder(& bi);

if(pidl!= NULL)

{

TCHAR tszPath [MAX_PATH] = _T(\ 0);

if(SHGetPathFromIDList(pidl,tszPath)== TRUE)

{

SetDlgItemText(IDC_EDIT1,tszPath);

}



}

}
void CRFileDlg::OnBnClickedButton1()
{
//Just take One Edit Control and Button , Add EventHandler for button.

BROWSEINFO bi = {0};
bi.lpszTitle = _T("Browse for Folder");
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
if ( pidl != NULL )
{
TCHAR tszPath[MAX_PATH] = _T("\0");
if ( SHGetPathFromIDList(pidl, tszPath) == TRUE )
{
SetDlgItemText( IDC_EDIT1, tszPath );
}

}
}


这篇关于如何在运行时在mfc中显示编辑控件中文件的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆