Overriding FileSaveAs
LeRoy Baxter -- lbaxter@cinfo.com
Monday, April 08, 1996
I would think this should be simple, but it is not. Instead of saving a "file" I need
to save a 'Project' - the logic is exactly the same, but I need to get more
information and derive the filename from the Project ID.
If I have the project information (ie filename), 'Save' just calls my
pDoc->OnSaveDocument(). If I don't have a project ID (filename), the
Common Dialogs' SaveAs gets called - Save and SaveAs call a common
routine: DoPromptFileName(). This routine appears to be defined in
CWinApp, and possibly elsewhere (the CWinApp calls
pDocManager->DoPromptFileName();
The CDocmanager::DoPromptFileName() is the exact routine I need to
override - but I haven't figured out how to do so (yet). I pass this on in
the event that I can't figure it out AND because it looks like something that a
lot of people might like to do more easily.
Mike Blaszczak -- mikeblas@msn.com
Wednesday, April 10, 1996
[Mini-digest: 3 responses]
----------
From: owner-mfc-l@netcom.com on behalf of LeRoy J. Baxter
Sent: Monday, April 08, 1996 15:42 PM
> The CDocmanager::DoPromptFileName() is the exact routine I need to
> override - but I haven't figured out how to do so (yet).
No, it isn't. It sounds like you just need to override
CWinApp::DoPromptFileName().
.B ekiM
TCHAR szAdvice[] = _T("Check twice, save a life: motorcycles are
everywhere!");
-----From: "Dan McNerthney"
the FileSaveAs is handled by the CDocument. It can be overriden by adding a
ID_FILE_SAVE_AS message map handler in your document.
-----From: Chet Murphy
LeRoy,
I'm doing something similar. To manage project data I create a new "project" document template together with
a "project" document. To override DoPromptFileName I create a subclass of CDocManager.
My solution lets the user create or open a "project" using the normal new or open commands, but since my
"project" document does not own a MDI window I have a separate menu commands to save and close the "project"
document.
BTW: My document template is somewhat like CSingleDocTemplate. It allows only one project to be open at a
time.
Hope this helps,
--Chet Murphy
ModelWorks Software
cmurphy@modelworks.com
http://www.modelworks.com/express
LeRoy Baxter -- lbaxter@cinfo.com
Saturday, April 13, 1996
Well Iooked at that -- All the CWinApp::DoPromptFileName() does is to call
the m_pDocManager->DoPromptFileName(). The catch is that
CWinApp::DoPromptFileName() is called deep within the Framework, and
the CMyWinApp::DoPromptFileName() does not get called (i.e. the MFC
Framework calls the base class and not my derived class)
oh yes (I forgot) - this is VC++ 4.1, Windows 95
----------
From: Mike Blaszczak[SMTP:mikeblas@msn.com]
Sent: Wednesday, April 10, 1996 10:59 AM
To: mfc-l@netcom.com
Subject: RE: Overriding FileSaveAs
[Mini-digest: 3 responses]
----------
From: owner-mfc-l@netcom.com on behalf of LeRoy J. Baxter
Sent: Monday, April 08, 1996 15:42 PM
> The CDocmanager::DoPromptFileName() is the exact routine I need to
> override - but I haven't figured out how to do so (yet).
No, it isn't. It sounds like you just need to override
CWinApp::DoPromptFileName().
.B ekiM
TCHAR szAdvice[] = _T("Check twice, save a life: motorcycles are
everywhere!");
David W. Gillett -- DGILLETT@expertedge.com
Wednesday, April 17, 1996
[Mini-digest: 2 responses]
> Well Iooked at that -- All the CWinApp::DoPromptFileName() does is to call
> the m_pDocManager->DoPromptFileName(). The catch is that
> CWinApp::DoPromptFileName() is called deep within the Framework, and
> the CMyWinApp::DoPromptFileName() does not get called (i.e. the MFC
> Framework calls the base class and not my derived class)
>
> oh yes (I forgot) - this is VC++ 4.1, Windows 95
I too have encountered a case (details escape me at the moment)
where the framework surprised me by calling CWinApp::something() and
NOT CMyApp::something() where I had attempted to override it.
("something()" may have been "OnFileNew()", but I can't be certain at
the moment.)
I have the impression that this might have been a change in going
from MFC 2.5 to 4.0, but it might have been something I tripped over
in trying to get around some other code that had broken in the
upgrade.
Dave
-----From: Christophe Nasarre
Here is a problem about DoPromptFileName
> Well Iooked at that -- All the CWinApp::DoPromptFileName() does is to call
> the m_pDocManager->DoPromptFileName(). The catch is that
> CWinApp::DoPromptFileName() is called deep within the Framework, and
> the CMyWinApp::DoPromptFileName() does not get called (i.e. the MFC
> Framework calls the base class and not my derived class)
>
> oh yes (I forgot) - this is VC++ 4.1, Windows 95
>>> The CDocmanager::DoPromptFileName() is the exact routine I need to
>>> override - but I haven't figured out how to do so (yet).
>> No, it isn't. It sounds like you just need to override
>> CWinApp::DoPromptFileName().
In fact, it is possible to override CWinApp::DoPromptFileName()
but your own version won't get called because this method is not
virtual for CWinAPP and it is called like : AfxGetApp()->DoPromptFileName(...)
in DOCCORE.CPP.
But CDocManager::DoPromptFileName() is virtual. But it is a little bit
difficult to change the default m_pDocManager to be of your class...
Good luck
-- a poor lonely frenchie --
| Вернуться в корень Архива
|