一,[FILE/CLOSE]的实现过程:
1.CDocument::OnFileClose()
void CDocument::OnFileClose()
{
if (!SaveModified())
return;
OnCloseDocument();
}
2.CDocument::SaveModified()
BOOL CDocument::SaveModified()
{
//内容是否更改,如果没有直接返回
if (!IsModified())
return TRUE;
//获得文档的标题和名字.....
//弹出提示框,告诉用户是否保存
CString prompt;
AfxFormatString1(prompt, AFX_IDP_ASK_TO_SAVE, name);
switch (AfxMessageBox(prompt, MB_YESNOCANCEL, AFX_IDP_ASK_TO_SAVE))
{
case IDCANCEL:
return FALSE; // 取消
case IDYES:
if (!DoFileSave())
return FALSE; // 保存
break;
case IDNO: //不保存
break;
default:
ASSERT(FALSE);
break;
}
return TRUE; //