现在建了一个document/view的工程,当我点保存的时候,它就直接保存了。我现在希望它能弹出一个文件保存的对话框,让我选择保存文件的文件名和扩展名。应该怎样做,谢谢!

解决方案 »

  1.   

    CFileDialog dlg(FALSE);
    dlg.DoModal();
      

  2.   

    注销掉保存按钮下那个CDialog::Save();
    改CDialog::SaveAs();
      

  3.   

    截获 CDN_FILEOK
    The CDN_FILEOK notification message is sent by an Explorer-style Open or Save As dialog box when the user specifies a file name and clicks the OK button. 
      

  4.   

    仿 PRB: GetSaveFileName Allows You to Select Invalid Folder Q245718 UINT_PTR WINAPI SaveAs_OnNotify (HWND hWnd, NMHDR *phdr)
    {
        switch (phdr->code)
        {
            case CDN_FILEOK:
                return SaveAs_OnFileOK (hWnd, (OFNOTIFY *) phdr);
        }
        return 0;
    }函数 SaveAs_OnFileOK 中
            MessageBox (hWnd, 
                        TEXT("You cannot save in the folder you specified. Please choose another location."),
                        TEXT("Save As"), MB_OK | MB_ICONINFORMATION);
            nResult = nReturn = 1;可改为OKCancel
      

  5.   

    CFileDialog,在msdn上看看它的说明吧
      

  6.   

    和CFileDialog无关,SetPathName空即可
      

  7.   

    通用对话框类:CFileDialog就可以实现
      

  8.   

    用CFileDialog  打开和保存就一个第一个参数不同而已,一个是TRUE,另一个是FALSE
      

  9.   

    CFileDialog dlg(FALSE);
    dlg.DoModal();
    说得没错
      

  10.   

    谢谢各位的回答,不过,我主要的问题是不知道那个CFileDialog 加在啥地方。那个文件名在Serialize之前的就被确定了。我在CMyDoc中的Serialize函数中修改CArchive中名字就可以了吗?还是说override中的哪个函数,在serialize之前制定存档的名字。谢谢!call stack as below:CMyDoc::Serialize(CArchive & {...}) line 61
    CDocument::OnSaveDocument(const char * 0x00f1b524) line 759
    CDocument::DoSave(const char * 0x013672f4, int 1) line 319 + 23 bytes
    CDocument::DoFileSave() line 269 + 28 bytes
    CDocument::OnFileSave() line 247