Click here to Skip to main content
15,911,142 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Overriding Tab Key Pin
Brian Shifrin4-Mar-03 7:15
Brian Shifrin4-Mar-03 7:15 
GeneralRe: Overriding Tab Key Pin
brianwelsch4-Mar-03 7:23
brianwelsch4-Mar-03 7:23 
GeneralRe: Overriding Tab Key Pin
Chris Richardson4-Mar-03 8:06
Chris Richardson4-Mar-03 8:06 
GeneralRe: Overriding Tab Key - DONE Pin
brianwelsch4-Mar-03 8:27
brianwelsch4-Mar-03 8:27 
GeneralRe: Overriding Tab Key - DONE Pin
Chris Richardson4-Mar-03 8:41
Chris Richardson4-Mar-03 8:41 
QuestionHow to reload a modified CDocument Pin
luedi4-Mar-03 4:57
luedi4-Mar-03 4:57 
AnswerRe: How to reload a modified CDocument Pin
Alvaro Mendez4-Mar-03 9:08
Alvaro Mendez4-Mar-03 9:08 
GeneralRe: How to reload a modified CDocument Pin
luedi4-Mar-03 12:08
luedi4-Mar-03 12:08 
Thanks Alvaro,

I hoped there was a simpler solution. Perhaps only setting a flag or something Wink | ;-)

I realized it now, not overriding the OpenDocumentFile member function, but the MatchDocType function. This results in a much cleaner solution, since I don't have to copy code from the CSingleDocTemplate implementation Smile | :)

class CSingleReloadDocTemplate : public CSingleDocTemplate
{
DECLARE_DYNAMIC(CSingleReloadDocTemplate)
public:
CSingleReloadDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass,
CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass)
: CSingleDocTemplate (nIDResource, pDocClass, pFrameClass, pViewClass)
{
}

virtual Confidence MatchDocType(LPCTSTR lpszPathName, CDocument*& rpDocMatch)
{
Confidence confidence = CSingleDocTemplate::MatchDocType (lpszPathName, rpDocMatch);
if (yesAlreadyOpen == confidence && rpDocMatch->IsModified())
{
int answer = AfxMessageBox ("Do you want to reload the document", MB_YESNO);
if (answer == IDYES)
{
// set the document modification state to "not modified" so the document template
// will not complain during OpenDocumentFile ()
rpDocMatch->SetModifiedFlag(FALSE);

// tell the DocumentManager, that no document with this title is already opened
rpDocMatch = NULL;
confidence = yesAttemptNative;
}
}
return confidence;
}
};

IMPLEMENT_DYNAMIC (CSingleReloadDocTemplate, CSingleDocTemplate);


For a MultiDocTemplate one should perhaps close the found document in some way (perhaps via CDocument::OnCloseDocument) since the CMultiDocTemplate::OpenDocumentFile() function will not reuse an existing open document like the CSingleDocTemplate. I'm not sure wether there is a combined method for this task that can be used for a SingleDocTemplate and a MultiDocTemplate (perhaps one can use CDocument::OnCloseDocument() already)

Regards,
Dirk
GeneralSTL set question Pin
ns4-Mar-03 4:38
ns4-Mar-03 4:38 
GeneralRe: STL set question Pin
Joaquín M López Muñoz4-Mar-03 5:18
Joaquín M López Muñoz4-Mar-03 5:18 
GeneralRe: STL set question Pin
ns4-Mar-03 5:31
ns4-Mar-03 5:31 
GeneralRe: STL set question Pin
Joaquín M López Muñoz4-Mar-03 6:30
Joaquín M López Muñoz4-Mar-03 6:30 
GeneralRe: STL set question Pin
ns4-Mar-03 7:14
ns4-Mar-03 7:14 
GeneralRe: STL set question Pin
ns4-Mar-03 7:40
ns4-Mar-03 7:40 
GeneralRe: STL set question Pin
Chris Losinger4-Mar-03 14:44
professionalChris Losinger4-Mar-03 14:44 
Generalyup Pin
ns5-Mar-03 4:44
ns5-Mar-03 4:44 
GeneralCRichEditCtrl - Changing of colors of selected text Pin
Member 2886124-Mar-03 4:26
Member 2886124-Mar-03 4:26 
GeneralRe: CRichEditCtrl - Changing of colors of selected text Pin
Big Art4-Mar-03 7:07
Big Art4-Mar-03 7:07 
GeneralPop-up menu Pin
Cedric Moonen4-Mar-03 4:06
Cedric Moonen4-Mar-03 4:06 
Generalcreate a view in dialog Pin
Ivan Polak4-Mar-03 3:58
Ivan Polak4-Mar-03 3:58 
GeneralWelcoming window Pin
RalfPeter4-Mar-03 3:50
RalfPeter4-Mar-03 3:50 
GeneralRe: Welcoming window Pin
Anonymous4-Mar-03 4:57
Anonymous4-Mar-03 4:57 
GeneralRe: Welcoming window Pin
Joan M4-Mar-03 6:27
professionalJoan M4-Mar-03 6:27 
GeneralRe: Welcoming window Pin
ColinDavies4-Mar-03 14:20
ColinDavies4-Mar-03 14:20 
QuestionHow to show a PNG image in my dialog ? Pin
adara4-Mar-03 3:43
adara4-Mar-03 3:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.