ex25bdoc.cpp

来自「VisualC++技术内幕(第四版)随书盘」· C++ 代码 · 共 93 行

CPP
93
字号
// ex25bDoc.cpp : implementation of the CEx25bDoc class
//

#include "stdafx.h"
#include "ex25b.h"

#include "cdib.h"
#include "ex25bDoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CEx25bDoc

IMPLEMENT_DYNCREATE(CEx25bDoc, CDocument)

BEGIN_MESSAGE_MAP(CEx25bDoc, CDocument)
    //{{AFX_MSG_MAP(CEx25bDoc)
    ON_COMMAND(ID_EDIT_CLEAR_ALL, OnEditClearAll)
    ON_UPDATE_COMMAND_UI(ID_EDIT_CLEAR_ALL, OnUpdateEditClearAll)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEx25bDoc construction/destruction

CEx25bDoc::CEx25bDoc()
{
    m_bDragHere = FALSE;
}

CEx25bDoc::~CEx25bDoc()
{
}

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

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

    return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CEx25bDoc serialization

void CEx25bDoc::Serialize(CArchive& ar)
{
    m_dib.Serialize(ar);
}

/////////////////////////////////////////////////////////////////////////////
// CEx25bDoc diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// CEx25bDoc commands

void CEx25bDoc::OnEditClearAll() 
{
    DeleteContents();
    UpdateAllViews(NULL);
    SetModifiedFlag();
}

void CEx25bDoc::OnUpdateEditClearAll(CCmdUI* pCmdUI) 
{
    pCmdUI->Enable(m_dib.GetSizeImage() > 0);   
}

void CEx25bDoc::DeleteContents() 
{
    m_dib.Empty();
}

⌨️ 快捷键说明

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