如标题,想显示一个可以选择路径的对话框。以前用C++Builder,有个函数是SelectDirectoy,但不是Win32 API函数。
解决方案 »
- 在DLL中,如何FreeLibrary当前DLL,那个ModuleHandle怎么获得呢?
- 怎么捕获非标准usb设备插入或拔出消息?
- 似乎是头文件出问题了?
- 奇怪问题,要求置顶,win32 Dynamic-link library 连接 sybase 数据库的问题,详细请进http://community.csdn.net/Expert/TopicView3.asp
- 我在用ATL封装一个ADO时,client 和server都 出现了下面的warning!
- 关于单色位图的问题,求求大家,帮个忙吧!我都弄了一个星期了!
- 请教<<c++primer>>的问题》(潘爱民版)
- 快速格式化C盘的批命令怎么写?不回显确认提示,在要求确认时自动输入Y .
- /yu 是什么意思?
- QTableView 如何修改某一列数据的对齐方式
- 求助!! 在浏览IE 时如何得到下载下来的图片!
- 如何定位动态内存中变量的地址
SHBrowseForFolder涉及内容太多
LPMALLOC pMalloc;
SHGetMalloc(&pMalloc);BROWSEINFO bi;
int i = 0;
LPITEMIDLIST pidlBrowse; // PIDL selected by user memset(lpBuffer, 0, sizeof(lpBuffer));
memset(buf, 0, sizeof(buf));
// Fill in the BROWSEINFO structure.
bi.hwndOwner = m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = lpBuffer;
bi.lpszTitle = "选择HTML文件存放的目录";
bi.ulFlags = 0;
bi.lpfn = NULL;
bi.lParam = 0;
// Browse for a folder and return its PIDL.
pidlBrowse = SHBrowseForFolder(&bi);
if (pidlBrowse != NULL)
{
// Show the display name, title, and file system path.
if (SHGetPathFromIDList(pidlBrowse, lpBuffer))
//you got the path here // Free the PIDL returned by SHBrowseForFolder.
pMalloc->Free(pidlBrowse);}
LPARAM lParam, LPARAM lpData)
{
_TCHAR szDir[_MAX_PATH]; switch(uMsg)
{
case BFFM_INITIALIZED: // 初始化
break; case BFFM_SELCHANGED: // 路径改变
if( SHGetPathFromIDList( (LPITEMIDLIST)lParam, szDir ) )
SendMessage( hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szDir );
break;
default:
break;
}
return 0;
}void CDlgOptionCapture::OnPathOpen()
{
// TODO: Add your control notification handler code here
_TCHAR pszDisplayName[MAX_PATH];
BROWSEINFO bi;
LPITEMIDLIST lpID; // 设置参数
bi.hwndOwner = GetSafeHwnd(); // Handle to the owner window
bi.pidlRoot = NULL; // Location of root folder
bi.pszDisplayName = pszDisplayName; // Folder name selected
bi.lpszTitle = _T("选择路径"); // Title name
bi.ulFlags = BIF_RETURNONLYFSDIRS |
BIF_STATUSTEXT; // Option flags
bi.lpfn = BrowseCallbackProc; // Callback function
bi.lParam = 0; // LPARAM
bi.iImage = NULL; // Image selected lpID = SHBrowseForFolder( &bi );
if( lpID != NULL )
{
if( SHGetPathFromIDList( lpID, pszDisplayName ) )
{
m_strPath = pszDisplayName;
if( m_strPath[m_strPath.GetLength() - 1] != '\\' )
m_strPath += _T('\\');
UpdateData( FALSE );
}
}
}