VC通用对话框

1.选择文件对话框

   CFileDialog FileDialog(TRUE,NULL, NULL, OFN_READONLY|OFN_CREATEPROMPT,_T("Region File(*.reg)|*.reg||"),this);
CString strPath = m_pObj->GetProjectDir()+_T("Region");
FileDialog.m_ofn.lpstrInitialDir = strPath;

        if(IDOK == FileDialog.DoModal())


2.另存为对话框

  1. CFileDialog saveFile = CFileDialog(FALSE, ".reg""", OFN_CREATEPROMPT | OFN_PATHMUSTEXIST , "Reg(*.Reg)|*.reg|All files (*.*)|*.*||");  
  2. CString defaultFileName = caseName;  
  3. saveFile.m_ofn.lpstrFile = defaultFileName.GetBuffer(MAX_PATH);  
  4. saveFile.m_ofn.nMaxFile = MAX_PATH;  
  5. if(IDOK == saveFile.DoModal()){  
  6. //  

3,.选择文件夹

    char szPath[MAX_PATH];     //存放选择的目录路径 
    CString str;
    ZeroMemory(szPath, sizeof(szPath));  
    BROWSEINFO bi;   
    bi.hwndOwner = m_hWnd;   
    bi.pidlRoot = NULL;   
    bi.pszDisplayName = szPath;   
    bi.lpszTitle = "请选择需要打包的目录:";   
    bi.ulFlags = 0;   
    bi.lpfn = NULL;   
    bi.lParam = 0;   
    bi.iImage = 0;   
    //弹出选择目录对话框
    LPITEMIDLIST lp = SHBrowseForFolder(&bi);  
    if(lp && SHGetPathFromIDList(lp, szPath))   
    {
        str.Format("选择的目录为 %s", szPath);
        AfxMessageBox(str);
        
    }
 
  


你可能感兴趣的:(MFC/VC)