MFC OnFileSave()?

This is a discussion on MFC OnFileSave()? within the Windows Programming forums, part of the Platform Specific Boards category; I'm attempting to save my document to disk but I have one problem. Using the default CDocument OnFileSave() and Serialize() ...

  1. #1
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596

    MFC OnFileSave()?

    I'm attempting to save my document to disk but I have one problem. Using the default CDocument OnFileSave() and Serialize() does not allow me to edit the properties of the Windows File Save/Save As common dialog box. Normally I would instantiate an object of type CFileDialog and set the params there. However, I cannot find where the framework is actually calling a function to handle the ID_FILE_SAVE and ID_FILE_SAVEAS messages. I've put Message Boxes in every OnFileSave() I can think of - in the view, in the app, in the frame window, and in the document. None of these causes the message box to pop up.

    So my question is how do I override the default ID_FILE_SAVE/SAVE AS behavior in MFC inside the doc/view architecture?

  2. #2
    Registered User
    Join Date
    Dec 2004
    Posts
    205
    Catch the message ID_FILE_SAVE_AS
    Code:
    ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
    Overwrite OnFileSaveAs()

    Overwrite DoSave()
    Code:
    BOOL DoSave(LPCTSTR lpszPathName, BOOL bReplace)
    {
    ...
    }
    These should be done in the doc files of your program.

    Also take a look at this article:
    http://www.codeguru.com/Cpp/W-D/disl...cle.php/c1967/

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Thanks I've got it working now. Seems I did not put a handler in the document class - not sure why I didn't but that was the problem. I'm not going to use that code from code-guru because I can override the default behavior by just calling my own OnFileSave and OnFileSaveAs - I also probably won't call serialize from my function.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OnFileSave in MFC
    By Selkie in forum Windows Programming
    Replies: 0
    Last Post: 10-18-2004, 05:47 AM
  2. WIndows programming?
    By hostensteffa in forum Windows Programming
    Replies: 7
    Last Post: 06-07-2002, 08:52 PM
  3. Release MFC Programs & Dynamic MFC DLL :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-18-2002, 06:42 PM
  4. Beginning MFC (Prosise) Part III - Now What? :: C++
    By kuphryn in forum C++ Programming
    Replies: 5
    Last Post: 03-03-2002, 05:58 PM
  5. MFC is Challenging :: C++
    By kuphryn in forum C++ Programming
    Replies: 8
    Last Post: 02-05-2002, 12:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21