VC中选择目录对话框

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);
}

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/sfcyyc/archive/2008/11/14/3297018.aspx

你可能感兴趣的:(null,BI,dialog)