⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filemodinotifydoc.cpp

📁 Visual.C++程序设计技巧与实例--配套光盘 第6章 文件和系统操作 本章共11个实例: 1. FolderCopy文件夹的选择和拷贝 2. DeleteCertainFile删除指定路
💻 CPP
字号:
// FileModiNotifyDoc.cpp : implementation of the CFileModiNotifyDoc class
//

#include "stdafx.h"
#include "FileModiNotify.h"

#include "FileModiNotifyDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CFileModiNotifyDoc

IMPLEMENT_DYNCREATE(CFileModiNotifyDoc, CDocument)

BEGIN_MESSAGE_MAP(CFileModiNotifyDoc, CDocument)
	//{{AFX_MSG_MAP(CFileModiNotifyDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFileModiNotifyDoc construction/destruction

CFileModiNotifyDoc::CFileModiNotifyDoc()
{
	// TODO: add one-time construction code here

}

CFileModiNotifyDoc::~CFileModiNotifyDoc()
{
}

BOOL CFileModiNotifyDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CFileModiNotifyDoc serialization

void CFileModiNotifyDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CFileModiNotifyDoc diagnostics

#ifdef _DEBUG
void CFileModiNotifyDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CFileModiNotifyDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CFileModiNotifyDoc commands

BOOL CFileModiNotifyDoc::SaveModified() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CDocument::SaveModified();
}
void CFileModiNotifyDoc::SetModifiedFlag(BOOL bModified)
{
    CString strTitle = GetTitle();

    CString strDirtyFlag = " 文件(文档)已被修改,注意保存喔!"; 
	//注意引号内前面的空格!
    //如果不要引号内前面的空格,save as保存文件对话框中的文件名后会带*号!

	//假如被修改了
    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);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -