📄 mydlgdoc.cpp
字号:
// MYDLGDoc.cpp : implementation of the CMYDLGDoc class
//
#include "stdafx.h"
#include "MYDLG.h"
#include "MyLine.h"
#include "MYDLGDoc.h"
#include "PenDlg.h"/////////////////////
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMYDLGDoc
IMPLEMENT_DYNCREATE(CMYDLGDoc, CDocument)
BEGIN_MESSAGE_MAP(CMYDLGDoc, CDocument)
//{{AFX_MSG_MAP(CMYDLGDoc)
ON_COMMAND(ID_OPTIONS_PEN, OnOptionsPen)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_PEN, OnUpdateOptionsPen)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMYDLGDoc construction/destruction
CMYDLGDoc::CMYDLGDoc()
{
m_pWidth=1;
m_pStyle=PEN_STYLE_SOLID;
m_pColor=RGB(0,0,0);
m_Tu="null"; // TODO: add one-time construction code here
m_qx=50;
m_qy=100;
m_zx=100;
m_zy=200;
}
CMYDLGDoc::~CMYDLGDoc()
{
}
BOOL CMYDLGDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
SetTitle (" 含对话框的画图程序 " );
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMYDLGDoc serialization
void CMYDLGDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
m_ObArray.Serialize(ar);// TODO: add storing code here
}
else
{
m_ObArray.Serialize(ar);// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CMYDLGDoc diagnostics
#ifdef _DEBUG
void CMYDLGDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CMYDLGDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMYDLGDoc commands
void CMYDLGDoc::OnOptionsPen()
{
CPenDlg PenDialog;
PenDialog.m_pWidth=m_pWidth;
PenDialog.m_pStyle=m_pStyle;
PenDialog.m_pColor=m_pColor;
PenDialog.m_Tu=m_Tu;
PenDialog.m_pQx=m_qx;
PenDialog.m_pQy=m_qy;
PenDialog.m_pZx=m_zx;
PenDialog.m_pZy=m_zy;
if(PenDialog.DoModal()==IDOK)
{
m_pWidth=PenDialog.m_pWidth;
m_pStyle=PenDialog.m_pStyle;
m_pColor=PenDialog.m_pColor;
m_Tu= PenDialog.m_Tu;
m_qx=PenDialog.m_pQx;
m_qy=PenDialog.m_pQy;
m_zx=PenDialog.m_pZx;
m_zy=PenDialog.m_pZy;
this->UpdateAllViews(NULL);
}
// TODO: Add your command handler code here
}
void CMYDLGDoc::OnUpdateOptionsPen(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
CMyLine *CMYDLGDoc::GetLine(int index)
{
if (index<0||index>m_ObArray.GetUpperBound())
return 0;
return(CMyLine *)m_ObArray.GetAt(index);
}
int CMYDLGDoc::GetTotalLine()
{ return m_ObArray.GetSize(); }
void CMYDLGDoc::AddLine(int StartX,int StartY,int EndX,int EndY,int Width,int Style,COLORREF Color,CString tu)
{
CMyLine *pMyLine=new CMyLine(StartX,StartY,EndX,EndY,Width,Style,Color,tu);
m_ObArray.Add(pMyLine);
SetModifiedFlag();
}
void CMYDLGDoc::DeleteContents()
{
/*int index;
index=m_ObArray.GetSize();
while(index--)
delete m_ObArray.GetAt(index);
m_ObArray.RemoveAll();*/// TODO: Add your specialized code here and/or call the base class
CDocument::DeleteContents();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -