📄 drawdoc.cpp
字号:
// DrawDoc.cpp : implementation of the CDrawDoc class
//
#include "stdafx.h"
#include "PropertySheetInSplitter.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)
ON_COMMAND(ID_WINDOW_NEWVIEW, OnWindowNewView)
ON_COMMAND(ID_WINDOW_NEWFORMVIEW, OnWindowNewFormView)
ON_COMMAND(ID_WINDOW_NEWSPLITTER, OnWindowNewSplitter)
ON_COMMAND(ID_WINDOW_NEWSPLITTER2, OnWindowNewSplitter2)
//}}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 );
}
///////////////////////////////////////////////////////////
// Create a new view based on the document template
// parameter and associated with the given document object
CFrameWnd* EkCreateNewWindow( CDocTemplate* pTemplate,
CDocument* pDocument )
{
ASSERT_VALID( pTemplate );
ASSERT_VALID( pDocument );
// 1 - Create the new frame window
// (will in turn create the associated view)
CFrameWnd* pFrame = pTemplate->CreateNewFrame(
pDocument, NULL );
if( pFrame == NULL )
{
// Window creation failed
TRACE0( "Warning: failed to create new frame.\n" );
return NULL;
}
ASSERT_KINDOF( CFrameWnd, pFrame );
// 2 - Tell the frame to update itself
// (and its child windows)
pTemplate->InitialUpdateFrame( pFrame, pDocument );
// 3 - Return a pointer to the new frame window object
return pFrame;
}
void CDrawDoc::OnWindowNewView()
{
EkCreateNewWindow( theApp.m_ptDrawView, this );
}
void CDrawDoc::OnWindowNewFormView()
{
EkCreateNewWindow( theApp.m_ptPSheetFormView, this );
}
void CDrawDoc::OnWindowNewSplitter()
{
EkCreateNewWindow( theApp.m_ptSplitFrame, this );
}
void CDrawDoc::OnWindowNewSplitter2()
{
EkCreateNewWindow( theApp.m_ptSplitFrame2, this );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -