📄 mygraphview.cpp
字号:
// MyGraphView.cpp : implementation of the CMyGraphView class
//
#include "stdafx.h"
#include "MyGraph.h"
#include "MyGraphDoc.h"
#include "MyGraphView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyGraphView
IMPLEMENT_DYNCREATE(CMyGraphView, CView)
BEGIN_MESSAGE_MAP(CMyGraphView, CView)
//{{AFX_MSG_MAP(CMyGraphView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyGraphView construction/destruction
CMyGraphView::CMyGraphView()
{
// TODO: add construction code here
}
CMyGraphView::~CMyGraphView()
{
}
BOOL CMyGraphView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMyGraphView drawing
void CMyGraphView::OnDraw(CDC* pDC)
{
CMyGraphDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
for(int xPos=20;xPos<100;xPos+=10)
pDC->SetPixel(xPos,30,RGB(0,0,0)); // 绘制像素点
POINT polylpt[5]={{10,100},{50,60},{120,80},{80,150},{30,130}};
pDC->Polyline(polylpt,5); // 绘制五条折线
POINT polybpt[4]={{150,160},{220,60},{300,180},{330,20}};
pDC->PolyBezier(polybpt,4); // 绘制贝济埃曲线
CBrush *pBrhOld;
pBrhOld=(CBrush*)pDC->SelectStockObject(LTGRAY_BRUSH); // 使用浅灰色堆画刷
pDC->RoundRect(400,30,550,100,20,20); // 绘制圆角矩形
pDC->Arc(20,200,200,300,200,250,20,200); // 绘制椭圆弧
pDC->Pie(220,200,400,380,380,270,240,220); // 绘制扇形
pDC->Chord(420,120,540,240,520,160,420,180); // 绘制弦形
POINT polygpt[5]={{450,200},{530,220},{560,300},{480,320},{430,280}};
pDC->Polygon(polygpt,5); // 绘制五边形
pDC->SelectObject(pBrhOld); // 恢复系统默认的画刷
}
/////////////////////////////////////////////////////////////////////////////
// CMyGraphView diagnostics
#ifdef _DEBUG
void CMyGraphView::AssertValid() const
{
CView::AssertValid();
}
void CMyGraphView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMyGraphDoc* CMyGraphView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyGraphDoc)));
return (CMyGraphDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMyGraphView message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -