如何做选择路径的对话框??

paio 2005-07-14 04:43:56
想做一个类似安装软件的对话框,可以输入安装路径,还可以浏览。
主要是那个浏览按钮应该怎么做,单击浏览按钮应该弹出一个可以选择路径的对话框。
请大家帮帮忙,谢谢大家!!
...全文
82 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
CrazyAzreal 2005-07-15
  • 打赏
  • 举报
回复
哈哈``我正在为这个问题烦``原来有二楼那种方法```学习+谢谢!!
laolaoliu2002 2005-07-14
  • 打赏
  • 举报
回复
The CFileDialog class encapsulates the Windows common file dialog box. Common file dialog boxes provide an easy way to implement File Open and File Save As dialog boxes (as well as other file-selection dialog boxes) in a manner consistent with Windows standards.

You can use CFileDialog "as is" with the constructor provided, or you can derive your own dialog class from CFileDialog and write a constructor to suit your needs. In either case, these dialog boxes will behave like standard Microsoft Foundation class dialog boxes because they are derived from the CCommonDialog class.

laolaoliu2002 2005-07-14
  • 打赏
  • 举报
回复
CFileDialog
dasiu 2005-07-14
  • 打赏
  • 举报
回复
通过以下代码,找到合适的路径

//***************************************************************
//函数功能:得到用户选择的文件夹路径
// 1) 返回NULL时候,用户取消
// 2) 返回非NULL时候,用户确认了路径
//说明:
//***************************************************************
CString CBTMSApp::SelectFolder(HWND hWnd)
{
CString strPath =_T("");
BROWSEINFO bInfo;
ZeroMemory(&bInfo, sizeof(bInfo));
bInfo.hwndOwner =hWnd;
bInfo.lpszTitle = _T("请选择文件路径: ");
bInfo.ulFlags = BIF_RETURNONLYFSDIRS;

LPITEMIDLIST lpDlist; //用来保存返回信息的IDList
lpDlist = SHBrowseForFolder(&bInfo) ; //显示选择对话框
if(lpDlist != NULL) //用户按了确定按钮
{
TCHAR chPath[MAX_PATH]; //用来存储路径的字符串
SHGetPathFromIDList(lpDlist, chPath);//把项目标识列表转化成字符串
strPath = chPath; //将TCHAR类型的字符串转换为CString类型的字符串
}
return strPath;
}

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧