怎样实现以下功能:
单击按钮时打开“打开/另存为”对话框,选择好文件后,单击确定时,文件名及其路径出现在指定的文本框中????

解决方案 »

  1.   

    CFileDialog查一下这个类的用法~~
      

  2.   

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