void CTest2Doc::SetModifiedFlag(BOOL bModified)

    {

    CString strTitle = GetTitle();

    CString strDirtyFlag = " *"; // note space before the '*' 

    // so we don't break Save As dialog

    if (!IsModified() && bModified)

        {

        SetTitle(strTitle + strDirtyFlag);

    }

    else if ( IsModified() && !bModified )

        {

        int nTitleLength = strTitle.GetLength();

        int nDirtyLength = strDirtyFlag.GetLength();

        SetTitle( strTitle.Left(nTitleLength - nDirtyLength) );

    }

    UpdateFrameCounts();

    CDocument::SetModifiedFlag(bModified);

}