MDarling
asked on
DOC/View show modified and full path
I have an MDI application which is a text editor. I wish to show the full path to the file being edited in the title bar. I also want to append an asterisk to the title if the file in the editor is different from the file on disk.
What's the right way to do this?
Thanks in advance,
Mike.
What's the right way to do this?
Thanks in advance,
Mike.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
use SetTitle(...) to put your file name up in the title bar
ASKER
Ok thanks again, but i'm having a little trouble. When i modify the doc the title changes correctly.
However, when I save the title reverts back to just the filename without the path - the framework is doing this and I can't figure out how. This is the code for SaveModified
BOOL bRet=CDocument::SaveModifi ed();
SetModifiedFlag(FALSE);
return bRet;
which is being called.
Any ideas?
regards,
Mike.
I have also modified SetModifiedFlag to...
void CMaceEditDoc::SetModifiedF lag( BOOL bModified /*= TRUE */ )
{
CDocument::SetModifiedFlag (bModified );
CString title = GetFullTitle();
int asterisk = title.GetLength()-1;
if (asterisk >=0 && title.GetAt(asterisk)=='*' )
{
if (!bModified)
{
title.SetAt(asterisk,0);
}
}
else if (bModified)
{
title += '*';
}
SetTitle(title);
}
CString CMaceEditDoc::GetFullTitle ()
{
CString strTitle=GetPathName();
if(strTitle.IsEmpty()) strTitle=_T("New Document");
return strTitle;
}
However, when I save the title reverts back to just the filename without the path - the framework is doing this and I can't figure out how. This is the code for SaveModified
BOOL bRet=CDocument::SaveModifi
SetModifiedFlag(FALSE);
return bRet;
which is being called.
Any ideas?
regards,
Mike.
I have also modified SetModifiedFlag to...
void CMaceEditDoc::SetModifiedF
{
CDocument::SetModifiedFlag
CString title = GetFullTitle();
int asterisk = title.GetLength()-1;
if (asterisk >=0 && title.GetAt(asterisk)=='*'
{
if (!bModified)
{
title.SetAt(asterisk,0);
}
}
else if (bModified)
{
title += '*';
}
SetTitle(title);
}
CString CMaceEditDoc::GetFullTitle
{
CString strTitle=GetPathName();
if(strTitle.IsEmpty()) strTitle=_T("New Document");
return strTitle;
}
ASKER
it's being called from DoSave from in OnFileSave
looking further...
looking further...
ASKER
same goes from OnOpenDocument
I suspect it is being set from SetPathName in the MFC - this is a virtal function and you can override it if you wish - have a look at the MFC implementation in DOCCORE.CPP
CYourDoc::SetPathName(...)
{
CDocument::SetPathName(... ); // use correct base class here
SetTitle(...); // set your title back again
}
CYourDoc::SetPathName(...)
{
CDocument::SetPathName(...
SetTitle(...); // set your title back again
}
ASKER
Yes!
Thanks.
Regards,
Mike.
Thanks.
Regards,
Mike.
ASKER
what about the first part of the question though?
regards,
Mike.