CFileDialog Open(true,0,0,2,"C++ source|*.cpp|All files|*.*||",this,0);
我用的是VC2005我看了很多的参考 关于选择文件类型的
,"C++ source|*.cpp|All files|*.*||",这里我通不过
谁能告诉我怎么做

解决方案 »

  1.   

    msnd 上的demo 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);
       
       // 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 fileDlg(TRUE);
    fileDlg.m_ofn.lpstrTitle="打开对话框";
    fileDlg.m_ofn.lpstrFilter="C++ source (*.cpp)\0*.cpp\0All Files(*.*)\0*.*\0\0";
            if(IDOK==fileDlg.DoModal())
    {
                 ......
            }这样就可以了.
      

  3.   

    CFileDialog Open(true,0,0,2,L"C++ source ¦*.cpp ¦All files ¦*.* ¦ ¦",this,0); 
    Open.DoModal();