怎样才能选择一个文件夹?请哪为大哥帮忙啊!!如果是控件,请发到下面这个邮箱:
[email protected]不晓得除了控件,还有什么其他方法没有???AnsiString Dir = "c:"; if (SelectDirectory("添加播放目录","C:",Dir))//, TSelectDirOpts() << sdAllowCreate << sdPerformCreate << sdPrompt,NULL)){...}SelectDirectory用SelectDirectory函数吧:#include <FileCtrl.hpp>AnsiString sap="";SelectDirectory("请选择路径:","",sap);AnsiString Select_Directory(){BROWSEINFO info;LPCITEMIDLIST itemid;//char dir[50];AnsiString dir;info.hwndOwner=Application->Handle;info.pidlRoot=NULL;info.pszDisplayName=NULL;info.lpszTitle="select directory";info.ulFlags=0;info.lpfn=NULL;info.lParam=0;info.iImage=0;itemid=SHBrowseForFolder(&info); if(itemid!=NULL) { SHGetPathFromIDList(itemid,dir.c_str()); return dir.c_str(); } else return NULL;}AnsiString SelectDirectory(HWND hWnd){ // Use Windows 95 Directory box to get dir BROWSEINFO bi; char WDir[MAX_PATH]; char FolderName[MAX_PATH]; LPITEMIDLIST ItemID; memset(&bi, 0, sizeof(BROWSEINFO)); memset(WDir, 0, MAX_PATH); bi.hwndOwner = hWnd; bi.pszDisplayName = FolderName; bi.lpszTitle = "请选择目录:"; bi.ulFlags=BIF_RETURNONLYFSDIRS; ItemID = SHBrowseForFolder(&bi); AnsiString Ret=WDir; if(ItemID!=NULL) { SHGetPathFromIDList(ItemID, WDir); //GlobalFreePtr(ItemID); Ret=WDir; } return Ret;}这样也都可以,SelectDirectory,有两种方式,参数是不一样的,具体可以看帮助#include "FileCtrl.hpp" //第一个函数需要#define NO_WIN32_LEAN_AND_MEAN#include <vcl.h>#pragma hdrstop#include "shlobj.h"//用我上面第二个函数就要这样了我写的函数:#include "shlobj.h"AnsiString SelectSystemDirDlg(){ char SelectedDir[MAX_PATH]; // 最终结果 BROWSEINFO bi; // 入参 char FolderName[MAX_PATH]; // 所选目录名称,例如选择C:\Windows\Font,则为Font LPITEMIDLIST ItemID; // 所选目录的系统标志指针 memset(SelectedDir, 0, MAX_PATH); // 初始化最终结果 memset(&bi, 0, sizeof(BROWSEINFO)); // 初始化入参所有数据 bi.hwndOwner = Application->Handle; bi.pszDisplayName = FolderName; bi.lpszTitle = "Export to"; bi.ulFlags= BIF_RETURNONLYFSDIRS | BIF_RETURNFSANCESTORS; ItemID = SHBrowseForFolder(&bi); // 调用函数,打开目录选择对话框 if( ItemID ) { SHGetPathFromIDList(ItemID, SelectedDir); // 获取所选目录的全名 GlobalFree(ItemID); //释放 return AnsiString(SelectedDir) "\\"; } return "";}//-----------------------------------------------------------------------------学习这个多人答了,俺就不献丑了其实也有控件直接支持学习学习