我是想在我的对话框程序里面的一个按钮被单击的时候弹出如图的对话框有什么方法吗、??

解决方案 »

  1.   

    void CChildFrame::OnFileOpen() 
    {
       // szFilters is a text string that includes two file name filters:
       // "*.my" for "MyType Files" and "*.*' for "All Files."
       char CChildFrame::szFilters[]=
          "MyType Files (*.my)|*.my|All Files (*.*)|*.*||";   // Create an Open dialog; the default file name extension is ".my".
       CFileDialog fileDlg (TRUE, "my", "*.my",
          OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this);
       fileDlg .m_ofn.Flags=OFN_EXPLORER;
       // Display the file dialog. When user clicks OK, fileDlg.DoModal() 
       // returns IDOK.
       if( fileDlg.DoModal ()==IDOK )
       {
          CString pathName = fileDlg.GetPathName();
       
          // Implement opening and reading file in here.
          ...
          //Change the window's title to the opened file's title.
          CString fileName = fileDlg.GetFileTitle ();
       
          SetWindowText(fileName);
       }}
      

  2.   

    CFileDialog类或
    GetOpenFileName()函数
      

  3.   

    按你的图应该是:void CMyFileOpenDlg::OnButtonNew() 
    {
    // TODO: Add your control notification handler code here
    char fileName[MAX_PATH]="";
    CExpFileOpen dlgFile(TRUE); 
    //if use new style!
    OSVERSIONINFO VersionInformation;   
    GetVersionEx(&VersionInformation);
    if(VersionInformation.dwMajorVersion >= 5)
    dlgFile.m_ofn.lStructSize=88;// new =88
    else
    dlgFile.m_ofn.lStructSize=76;// old =76
    //do not use it ! dlgFile.m_ofn.Flags |= OFN_ENABLETEMPLATEHANDLE; 
    dlgFile.m_ofn.Flags |= OFN_ENABLETEMPLATE;// add our temp !
    dlgFile.m_ofn.lpstrTitle = "Explorer Style Open File"; 
    dlgFile.m_ofn.lpstrFile = fileName; 
    dlgFile.m_ofn.Flags |= OFN_EXPLORER;
    //'Clip siblings' 'Child' 'None' '3Dlook' 'Control' 'Visible'
    dlgFile.m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_EX_OPEN); //=1547!
    dlgFile.m_ofn.hInstance=AfxGetInstanceHandle(); 
    dlgFile.m_ofn.lpstrFilter="Any file(*.*)\0*.*\0";
    dlgFile.m_ofn.lpstrDefExt = "txt"; 
    // show 
    dlgFile.DoModal();
    #ifdef _DEBUG
    afxDump << fileName << " \n";
    #endif
    }注意:
    dlgFile.m_ofn.lStructSize=88;// new =88
    就是你要的格式
      

  4.   

    CExpFileOpen dlgFile(TRUE); 这是什么类,MSDN没有
    哪个类里面的,是未公开API吗
      

  5.   

    sorry,用CFileDialog代替CExpFileOpen(自定义的) 就可以了。
      

  6.   

    另外去除:
    // dlgFile.m_ofn.Flags |= OFN_ENABLETEMPLATE;// add our temp !
    // dlgFile.m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_EX_OPEN); //=1547!
    // dlgFile.m_ofn.hInstance=AfxGetInstanceHandle();