您的位置:首页 > 其它

VC中选择目录对话框

2008-11-14 10:21 435 查看
void SelectDirDlg(char Dir[])
{
    BROWSEINFO bi;
    ITEMIDLIST *pidl;
    
    bi.hwndOwner = NULL;
    bi.pidlRoot = NULL;
    bi.pszDisplayName = Dir;
    bi.lpszTitle = "选择一个目录";
    bi.ulFlags = BIF_RETURNONLYFSDIRS;
    bi.lpfn = NULL;
    bi.lParam = 0;
    bi.iImage = 0;
    
    pidl = SHBrowseForFolder( &bi );             /* Display "Select Folde
                                                 r" dialog box, Get the  
                                                 folder name and co
                                                 nvert it into a ITEMLIST  data structure. */
    
    
    if ( pidl == NULL )
        Dir[0] = 0;
    
    if (!SHGetPathFromIDList( pidl, Dir ))       /* Retrieve folder name from ITEMLIST structure. */
        Dir[0] = 0;
}
void CRestoreTZDlg::OnButtonBrowseSrc()
{
    // TODO: Add your control notification handler code here
    char dir[256]="";
    SelectDirDlg(dir);
    //CString sSrcDir(dir);
    this->m_sSrcDir.Format("%s",dir);
    UpdateData(FALSE);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  null dialog bi