📄 drawdoc.cpp
字号:
// DrawDoc.cpp : implementation of the CDrawDoc class
//
#include "stdafx.h"
#include "ModifiedMark.h"
#include "DrawDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDrawDoc
IMPLEMENT_DYNCREATE(CDrawDoc, CDocument)
BEGIN_MESSAGE_MAP(CDrawDoc, CDocument)
//{{AFX_MSG_MAP(CDrawDoc)
ON_COMMAND(ID_DRAW_SQUARE, OnDrawSquare)
ON_COMMAND(ID_DRAW_CIRCLE, OnDrawCircle)
ON_UPDATE_COMMAND_UI(ID_DRAW_SQUARE, OnUpdateDrawSquare)
ON_UPDATE_COMMAND_UI(ID_DRAW_CIRCLE, OnUpdateDrawCircle)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDrawDoc construction/destruction
CDrawDoc::CDrawDoc()
{
m_point = CPoint( 30, 30 );
m_shape = SQUARE;
}
CDrawDoc::~CDrawDoc()
{
}
BOOL CDrawDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CDrawDoc serialization
void CDrawDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar << m_point << (DWORD) m_shape;
}
else
{
ar >> m_point >> (DWORD&) m_shape;
}
}
/////////////////////////////////////////////////////////////////////////////
// CDrawDoc diagnostics
#ifdef _DEBUG
void CDrawDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CDrawDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDrawDoc commands
void CDrawDoc::OnDrawSquare()
{
m_shape = SQUARE;
UpdateAllViews( NULL );
SetModifiedFlag( TRUE );
}
void CDrawDoc::OnDrawCircle()
{
m_shape = CIRCLE;
UpdateAllViews( NULL );
SetModifiedFlag( TRUE );
}
void CDrawDoc::OnUpdateDrawSquare(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( m_shape == SQUARE );
}
void CDrawDoc::OnUpdateDrawCircle(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck( m_shape == CIRCLE );
}
// Overriden to change the document's title
void CDrawDoc::SetModifiedFlag( BOOL bModified )
{
CString strTitle = GetTitle();
// Note the space before the "modified" marker:
// this prevents some problems with the document
// name in the "Save As" dialog box
CString strIndicator = " *";
// 1 - Set the correct title depending on the new
// state of our document object
if( !IsModified() && bModified )
{
// 1a - Document was "clean", is now "dirty"
SetTitle( strTitle + strIndicator );
}
else if( IsModified() && !bModified )
{
// 1b - Document was "dirty", is now "clean"
SetTitle( strTitle.Left( strTitle.GetLength()
- strIndicator.GetLength() ) );
}
// 2 - Force update of the frame windows titles
// (this will cause the frame windows to show our
// new title)
UpdateFrameCounts();
// 3 - Finally, call the standard function
CDocument::SetModifiedFlag( bModified );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -