在MFC中弹出选择目录的对话框是哪个类啊?? CFileDialog是选择文件,我要的是树状目录结构的对话框。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 要自己做。////////////////////////////////////////////////////////////////////////// DirDialog.h: interface for the CDirDialog class.////////////////////////////////////////////////////////////////////////#include"stdafx.h"#if !defined(AFX_DIRDIALOG_H__62FFAC92_1DEE_11D1_B87A_0060979CDF6D__INCLUDED_)#define AFX_DIRDIALOG_H__62FFAC92_1DEE_11D1_B87A_0060979CDF6D__INCLUDED_#if _MSC_VER >= 1000#pragma once#endif // _MSC_VER >= 1000class CDirDialog{public: CDirDialog(); virtual ~CDirDialog(); int DoBrowse (); CString m_strPath; CString m_strInitDir; CString m_strTitle; int m_iImageIndex;};#endif ////cpp//#ifndef AFX_DIRDIALOG_H__62FFAC92_1DEE_11D1_B87A_0060979CDF6D__INCLUDED_//#define AFX_DIRDIALOG_H__62FFAC92_1DEE_11D1_B87A_0060979CDF6D__INCLUDED_///////////////////////////////////////////////////////////////////////////// DirDialog.cpp: implementation of the CDirDialog class.////////////////////////////////////////////////////////////////////////#include "stdafx.h"#include "DirDialog.h"#include "shlobj.h"#ifdef _DEBUG#undef THIS_FILEstatic char THIS_FILE[]=__FILE__;#define new DEBUG_NEW#endif//////////////////////////////////////////////////////////////////////// Construction/Destruction//////////////////////////////////////////////////////////////////////CDirDialog::CDirDialog(){////////////////////////////////////////////}CDirDialog::~CDirDialog(){///////////////////////////////////////////}int CDirDialog::DoBrowse (){///////////////////////////////////////// LPMALLOC pMalloc; if (SHGetMalloc (&pMalloc)!= NOERROR) { return 0; } BROWSEINFO bInfo; LPITEMIDLIST pidl; ZeroMemory ( (PVOID) &bInfo,sizeof (BROWSEINFO)); if (!m_strInitDir.IsEmpty ()) { OLECHAR olePath[MAX_PATH]; ULONG chEaten; ULONG dwAttributes; HRESULT hr; LPSHELLFOLDER pDesktopFolder; // // Get a pointer to the Desktop's IShellFolder interface. // if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder))) { // // IShellFolder::ParseDisplayName requires the file name be in Unicode. // MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, m_strInitDir.GetBuffer (MAX_PATH), -1, olePath, MAX_PATH); m_strInitDir.ReleaseBuffer (-1); // // Convert the path to an ITEMIDLIST. // hr = pDesktopFolder->ParseDisplayName(NULL, NULL, olePath, &chEaten, &pidl, &dwAttributes); if (FAILED(hr)) { pMalloc ->Free (pidl); pMalloc ->Release (); return 0; } bInfo.pidlRoot = pidl; } } bInfo.hwndOwner = NULL; bInfo.pszDisplayName = m_strPath.GetBuffer (MAX_PATH); bInfo.lpszTitle = (m_strTitle.IsEmpty()) ? "Open":m_strTitle; bInfo.ulFlags = BIF_RETURNFSANCESTORS|BIF_RETURNONLYFSDIRS; if ((pidl = ::SHBrowseForFolder (&bInfo)) == NULL) { return 0; } m_strPath.ReleaseBuffer (); m_iImageIndex = bInfo.iImage; if (::SHGetPathFromIDList(pidl,m_strPath.GetBuffer (MAX_PATH)) == FALSE) { pMalloc ->Free (pidl); pMalloc ->Release (); return 0; } m_strPath.ReleaseBuffer (); pMalloc ->Free (pidl); pMalloc ->Release (); return 1;} http://softwaredev.earthweb.com/msnet/vc/article/0,,12081_629481,00.html DeleteService删除服务的小问题 一个简单的MFC图片打开问题 点击按钮弹出新对话框,在其上绘图出现问题,大家帮忙看一下 VC.NET2005 关于对文件名及属性进行操作的问题! 鼠标左键坐标和GetCursorPos的坐标为什么不一样? 散500分,求解析XML文档 怎么关闭线程阿? HELP HELP 一个指向控件问题! 请问哪里有DirectShow源代码? 询求翻译VC++ 使用GDI+能不能将BMP保存为JPEG(Exif) 好像大家都答不了isapi中读取session的问题
////////////////////////////////////////////////////////////////////////
// DirDialog.h: interface for the CDirDialog class.
//
//////////////////////////////////////////////////////////////////////
#include"stdafx.h"
#if !defined(AFX_DIRDIALOG_H__62FFAC92_1DEE_11D1_B87A_0060979CDF6D__INCLUDED_)
#define AFX_DIRDIALOG_H__62FFAC92_1DEE_11D1_B87A_0060979CDF6D__INCLUDED_#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000class CDirDialog
{
public:
CDirDialog();
virtual ~CDirDialog();
int DoBrowse ();
CString m_strPath;
CString m_strInitDir;
CString m_strTitle;
int m_iImageIndex;
};#endif ////cpp//#ifndef AFX_DIRDIALOG_H__62FFAC92_1DEE_11D1_B87A_0060979CDF6D__INCLUDED_
//#define AFX_DIRDIALOG_H__62FFAC92_1DEE_11D1_B87A_0060979CDF6D__INCLUDED_///////////////////////////////////////////////////////////////////////////
// DirDialog.cpp: implementation of the CDirDialog class.
//
//////////////////////////////////////////////////////////////////////#include "stdafx.h"
#include "DirDialog.h"
#include "shlobj.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////CDirDialog::CDirDialog()
{////////////////////////////////////////////}CDirDialog::~CDirDialog()
{///////////////////////////////////////////}int CDirDialog::DoBrowse ()
{///////////////////////////////////////// LPMALLOC pMalloc;
if (SHGetMalloc (&pMalloc)!= NOERROR)
{
return 0;
} BROWSEINFO bInfo;
LPITEMIDLIST pidl;
ZeroMemory ( (PVOID) &bInfo,sizeof (BROWSEINFO)); if (!m_strInitDir.IsEmpty ())
{
OLECHAR olePath[MAX_PATH];
ULONG chEaten;
ULONG dwAttributes;
HRESULT hr;
LPSHELLFOLDER pDesktopFolder;
// // Get a pointer to the Desktop's IShellFolder interface. //
if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder)))
{ //
// IShellFolder::ParseDisplayName requires the file name be in Unicode.
//
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, m_strInitDir.GetBuffer (MAX_PATH), -1,
olePath, MAX_PATH); m_strInitDir.ReleaseBuffer (-1);
//
// Convert the path to an ITEMIDLIST.
//
hr = pDesktopFolder->ParseDisplayName(NULL,
NULL,
olePath,
&chEaten,
&pidl,
&dwAttributes);
if (FAILED(hr))
{
pMalloc ->Free (pidl);
pMalloc ->Release ();
return 0;
}
bInfo.pidlRoot = pidl;
}
}
bInfo.hwndOwner = NULL;
bInfo.pszDisplayName = m_strPath.GetBuffer (MAX_PATH);
bInfo.lpszTitle = (m_strTitle.IsEmpty()) ? "Open":m_strTitle;
bInfo.ulFlags = BIF_RETURNFSANCESTORS|BIF_RETURNONLYFSDIRS;
if ((pidl = ::SHBrowseForFolder (&bInfo)) == NULL)
{
return 0;
}
m_strPath.ReleaseBuffer ();
m_iImageIndex = bInfo.iImage; if (::SHGetPathFromIDList(pidl,m_strPath.GetBuffer (MAX_PATH)) == FALSE)
{
pMalloc ->Free (pidl);
pMalloc ->Release ();
return 0;
} m_strPath.ReleaseBuffer (); pMalloc ->Free (pidl);
pMalloc ->Release ();
return 1;
}