Reputation: 3124
I am used to, when I change a document for instance in Microsoft Word, it gets a *
near the filename and the application automatically knows I should save the document.
How can I replicate this behaviour in MFC and notify my Document class of these changes, so that the app automatically knows the doc needs saving?
Upvotes: 1
Views: 2151
Reputation: 33
A bit late, but I just had to do the same thing.
Once you set the document's modified flag, change the title. Here's an example: m_pDoc->SetModifiedFlag(bChanged);
CString stTitle = m_pDoc->GetTitle();
if (stTitle.Left(2) == _T(" *"))) {
stTitle = stTitle.Left(stTitle.GetLength() - 2);
}
if (bChanged) {
stTitle += _T(" *");
m_pDoc->SetTitle(stTitle);
}
else {
m_pDoc->SetTitle(stTitle);
}
Upvotes: 2
Reputation: 76366
To notify the document that it is modified, you should use the CDocument::SetModified
method, and to query whether it is modified, you can use the CDocument::IsModified
. For the view, CView::OnUpdate
is called when the document is updated.
Upvotes: 5