-
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?
-
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/
-
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.