Solved

DOC/View show modified and full path

Posted on 2000-04-14
8
288 Views
Last Modified: 2013-11-20
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.

0
Comment
Question by:MDarling
  • 5
  • 3
8 Comments
 
LVL 9

Accepted Solution

by:
ShaunWilde earned 100 total points
ID: 2716836
use SetTitle for both

if you tell your document it has been modifed using the SetModifiedFlag you van override the implementation of SetModifedFlag thus

void CYourDoc::SetModifiedFlag(BOOL bModified)
{
   if (IsModified() != bModified) {
      CDocument::SetModifiedFlag(bModified);
      CString title = GetTitle();
      int asterisk = title.GetLength()-1;
      if (asterisk >=0 && title.GetAt(asterisk)=='*') {
         if (!bModified)
            title.SetAt(asterisk,0);
      } else if (bModified)
         title += '*';
      SetTitle(title);
   }
}
0
 
LVL 3

Author Comment

by:MDarling
ID: 2721974
hi Shaun, thanks for your answer.

what about the first part of the question though?

regards,
Mike.
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2722027
use SetTitle(...) to put your file name up in the title bar
0
 
LVL 3

Author Comment

by:MDarling
ID: 2722115
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::SaveModified();
    SetModifiedFlag(FALSE);
    return bRet;

which is being called.

Any ideas?

regards,
Mike.

I have also modified SetModifiedFlag to...

void CMaceEditDoc::SetModifiedFlag( 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;
}
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Author Comment

by:MDarling
ID: 2722147
it's being called from DoSave from in OnFileSave

looking further...
0
 
LVL 3

Author Comment

by:MDarling
ID: 2722148
same goes from OnOpenDocument
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2722165
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
}
0
 
LVL 3

Author Comment

by:MDarling
ID: 2722186
Yes!

Thanks.

Regards,
Mike.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
if loop in java 3 130
difference between String.subString() and String.subSequence() 6 180
fizzArray  challenge 1 64
Not needed 13 95
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now