选择directory的控件 请问在MFC中如何实现类似VB中的CDirList控件的功能,即能选择某一个目录 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 刚好有这么一个类,告诉我你的email,发一份给你 char Dir[128] = "abcdefg"; BROWSEINFO bi; ITEMIDLIST *pidl; bi.hwndOwner = NULL; bi.pidlRoot = NULL; bi.pszDisplayName = Dir; bi.lpszTitle = "Select a directory"; bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_DONTGOBELOWDOMAIN; bi.lpfn = NULL; bi.lParam = 0; bi.iImage = 0; pidl = SHBrowseForFolder( &bi ); /* Display "Select Folder" dialog box, Get the folder name and convert it into a ITEMLIST data structure. */ if ( pidl == NULL ) Dir[0] = 0; /* Retrieve foldernam e from ITEMLIST structure. */ if (!SHGetPathFromIDList( pidl, Dir )) Dir[0] = 0; #include <Shlobj.h>Shell32.lib LPMALLOC pMalloc; /* Gets the Shell's default allocator */ if (::SHGetMalloc(&pMalloc) == NOERROR) { BROWSEINFO bi; char pszBuffer[MAX_PATH]; LPITEMIDLIST pidl; // Get help on BROWSEINFO struct - it's got all the bit settings. bi.hwndOwner = GetSafeHwnd(); bi.pidlRoot = NULL; bi.pszDisplayName = pszBuffer; bi.lpszTitle = /*_T("Select a Starting Directory");*/NULL; bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS |BIF_STATUSTEXT ; bi.lpfn = NULL; bi.lParam = 0; // This next call issues the dialog box. if ((pidl = ::SHBrowseForFolder(&bi)) != NULL) { if (::SHGetPathFromIDList(pidl, pszBuffer)) { AfxMessageBox(pszBuffer, MB_OK); // At this point pszBuffer contains the selected path */.// DoingSomethingUseful(pszBuffer); } // Free the PIDL allocated by SHBrowseForFolder. pMalloc->Free(pidl); } // Release the shell's allocator. pMalloc->Release(); } 急:~CPaintDC如何设置文字字体和大小的? SDK写的小游戏,欢迎测试 Jmail 用过的朋友进来帮下忙 怎么显示位图? 怎么写类 【请教】List Control 不同列插入的数值行数不一样的问题 如何用OPENGL生成三维地形? 谁有自画CEDIT的源代码,能提示一下怎么做也行 急,急,急 vc6升级到vc8的问题 大侠救命,我要疯了,_ConnectionPtr不能创建实例!!!!!!你大恩大德,我将铭记的 高分求解,我还可以继续加分!有关发package的问题 各位老大帮帮忙,请问哪里有installer shield下载呀,请给出下载地址,在线等待中!
BROWSEINFO bi;
ITEMIDLIST *pidl;
bi.hwndOwner = NULL;
bi.pidlRoot = NULL;
bi.pszDisplayName = Dir;
bi.lpszTitle = "Select a directory";
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_DONTGOBELOWDOMAIN;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
pidl = SHBrowseForFolder( &bi );
/* Display "Select Folder" dialog box, Get the folder name and convert it into a ITEMLIST data structure. */
if ( pidl == NULL )
Dir[0] = 0;
/* Retrieve foldernam e from ITEMLIST structure. */
if (!SHGetPathFromIDList( pidl, Dir ))
Dir[0] = 0;
/* Gets the Shell's default allocator */
if (::SHGetMalloc(&pMalloc) == NOERROR)
{
BROWSEINFO bi;
char pszBuffer[MAX_PATH];
LPITEMIDLIST pidl;
// Get help on BROWSEINFO struct - it's got all the bit settings.
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = pszBuffer;
bi.lpszTitle = /*_T("Select a Starting Directory");*/NULL;
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS |BIF_STATUSTEXT ;
bi.lpfn = NULL;
bi.lParam = 0;
// This next call issues the dialog box.
if ((pidl = ::SHBrowseForFolder(&bi)) != NULL)
{
if (::SHGetPathFromIDList(pidl, pszBuffer))
{
AfxMessageBox(pszBuffer, MB_OK);
// At this point pszBuffer contains the selected path */.
// DoingSomethingUseful(pszBuffer);
}
// Free the PIDL allocated by SHBrowseForFolder.
pMalloc->Free(pidl);
}
// Release the shell's allocator.
pMalloc->Release();
}