About Browsing the directory(关于浏览文件对话框的实践)
2004-12-09 21:52
501 查看
在VC++编程中,有很多地方要用到文件夹浏览对话框,在version5.0版本(微软控件版本,一般在Windows2000之前)之前若想在文件夹浏览对话框上加一个新建文件夹按钮,需要自己编程来实现,现在在version5.0版本后,只需设置一个参数就可以了,而且有上下文菜单。如下图所示:(点此下载整个示例工程,本工程略加改动即可使用于自己的程序中。本工程亦可作为初学者的教程,一般教材很少讲文件夹浏览公用对话框的用法。)
示例工程中主要代码如下:
void CPathTestDlg::OnButtonBrowse()
{
CString str;
BROWSEINFO bi;
char name[MAX_PATH];
ZeroMemory(&bi,sizeof(BROWSEINFO));
bi.hwndOwner=GetSafeHwnd();
bi.pszDisplayName=name;
bi.lpszTitle="Select folder";
bi.ulFlags=80;
LPITEMIDLIST idl=SHBrowseForFolder(&bi);
if(idl==NULL)
return;
SHGetPathFromIDList(idl,str.GetBuffer(MAX_PATH));
str.ReleaseBuffer();
m_strSavePath=str;
if(str.GetAt(str.GetLength()-1)!='//')
m_strSavePath+="//";
UpdateData(FALSE);
}
其中bi.ulFlags 是对话框的格式,通过选定不同的参数来显示不同风格的对话框.
示例工程中主要代码如下:
void CPathTestDlg::OnButtonBrowse()
{
CString str;
BROWSEINFO bi;
char name[MAX_PATH];
ZeroMemory(&bi,sizeof(BROWSEINFO));
bi.hwndOwner=GetSafeHwnd();
bi.pszDisplayName=name;
bi.lpszTitle="Select folder";
bi.ulFlags=80;
LPITEMIDLIST idl=SHBrowseForFolder(&bi);
if(idl==NULL)
return;
SHGetPathFromIDList(idl,str.GetBuffer(MAX_PATH));
str.ReleaseBuffer();
m_strSavePath=str;
if(str.GetAt(str.GetLength()-1)!='//')
m_strSavePath+="//";
UpdateData(FALSE);
}
其中bi.ulFlags 是对话框的格式,通过选定不同的参数来显示不同风格的对话框.
相关文章推荐
- About Browsing the directory(关于浏览文件对话框的实践)
- window下打开文件选择对话框和浏览对话框的方式
- 关于STM32头文件包含出现No such file or directory和 invalid redeclaration of type name...的问题
- MFC实现打开、保存文件对话框和浏览文件夹对话框
- 第五十课、关于对话框(About)------------------狄泰软件学院
- 关于xml配置文件无元素提示和the root element of the document is not <xsd:schema>.错误
- About the First DataGridViewColumn Visible unexpected problem(关于第一列DataGridViewColumn意外可见的问题)
- 【VC编程技巧】文件☞2.7Windows上[浏览][打开][保存]对话框
- 《MFC实现打开、保存文件对话框和浏览文件夹对话框》
- vc 创建 浏览文件对话框
- All about sparse file in WINDOWS(关于WINDOWS稀疏文件)
- [翻译]跟我一起边译边学之Linux:关于作者 About the Authors
- MFC实现打开、保存文件对话框和浏览文件夹对话框(转)
- Data Structures and algorithm analysis—1.1 What's the book about? (数据结构1.1—关于本书)
- WPF中使用文件浏览对话框的几种方式
- WPF中的文件浏览对话框
- 关于页面浏览文件按钮的修改美化css
- (转)关于用文件系统TextStream对象实现网页访问浏览人数统计
- MFC 对话框 关于exe文件绝对路径的获取,截获。
- 关于fork进程的理解——Understanding about the fork process