DirDialog.cpp
资源名称:VC++视频传输.rar [点击查看]
上传用户:hxb_1234
上传日期:2010-03-30
资源大小:8328k
文件大小:2k
源码类别:
VC书籍
开发平台:
Visual C++
- #include "DirDialog.h"
- #include <shlobj.h>
- static int __stdcall BrowseCtrlCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
- {
- CDirDialog* pDirDialogObj = (CDirDialog*)lpData;
- if (uMsg == BFFM_INITIALIZED && !pDirDialogObj->m_strSelDir != NULL)
- {
- }
- else
- {
- }
- return 0;
- }
- CDirDialog::CDirDialog()
- {
- this->m_strPath = (char *) new char[32768];
- this->m_strInitDir = NULL;
- this->m_strSelDir = NULL;
- this->m_strTitle = NULL;
- }
- CDirDialog::~CDirDialog()
- {
- }
- int CDirDialog::DoBrowse()
- {
- BROWSEINFO bInfo;
- LPITEMIDLIST pidl;
- ZeroMemory ( (PVOID) &bInfo,sizeof (BROWSEINFO));
- if (m_strInitDir != NULL)
- {
- OLECHAR olePath[MAX_PATH];
- ULONG chEaten;
- ULONG dwAttributes;
- HRESULT hr;
- LPSHELLFOLDER pDesktopFolder;
- if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder)))
- {
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, m_strInitDir, -1,
- olePath, MAX_PATH);
- hr = pDesktopFolder->ParseDisplayName(NULL,
- NULL,
- olePath,
- &chEaten,
- &pidl,
- &dwAttributes);
- bInfo.pidlRoot = pidl;
- }
- }
- bInfo.hwndOwner = NULL;
- bInfo.pszDisplayName = m_strPath;
- bInfo.lpszTitle = "Select Directory";
- bInfo.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
- bInfo.lpfn = BrowseCtrlCallback;
- bInfo.lParam = (LPARAM)this;
- if ((pidl = SHBrowseForFolder(&bInfo)) == NULL)
- {
- return 0;
- }
- m_iImageIndex = bInfo.iImage;
- if (SHGetPathFromIDList(pidl, m_strPath) == FALSE)
- {
- return 0;
- }
- return 1;
- }