⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exampleview.cpp

📁 C++编程的实际例子
💻 CPP
字号:
// ExampleView.cpp : implementation of the CExampleView class
//

#include "stdafx.h"
#include "Example.h"

#include "ExampleDoc.h"
#include "ExampleView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CExampleView

IMPLEMENT_DYNCREATE(CExampleView, CView)

BEGIN_MESSAGE_MAP(CExampleView, CView)
//{{AFX_MSG_MAP(CExampleView)
// 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()

/////////////////////////////////////////////////////////////////////////////
// CExampleView construction/destruction

CExampleView::CExampleView()
{
	// TODO: add construction code here
	
}

CExampleView::~CExampleView()
{
}

BOOL CExampleView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs
	
	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CExampleView drawing

void CExampleView::OnDraw(CDC* pDC)
{
	CExampleDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	using namespace Gdiplus;
	Graphics graphics(pDC->m_hDC);
	Point points[] = {	Point(75, 0),    Point(100, 50), 
		Point(150, 50),  Point(112, 75),
		Point(150, 150), Point(75, 100), 
		Point(0, 150),   Point(37, 75), 
		Point(0, 50),    Point(50, 50)};
	GraphicsPath path;
	path.AddLines(points, 10);
	PathGradientBrush pthGrBrush(&path);
	pthGrBrush.SetCenterColor(Color(255, 255, 0, 0));
	Color colors[] = {	Color(255, 0, 0, 0),   Color(255, 0, 255, 0),
		Color(255, 0, 0, 255), Color(255, 255, 255, 255), 
		Color(255, 0, 0, 0),   Color(255, 0, 255, 0), 
		Color(255, 0, 0, 255), Color(255, 255, 255, 255),
		Color(255, 0, 0, 0),   Color(255, 0, 255, 0)};
	int count = 10;
	pthGrBrush.SetSurroundColors(colors, &count);
	graphics.FillPath(&pthGrBrush, &path);
	graphics.ReleaseHDC(pDC->m_hDC); 
}

/////////////////////////////////////////////////////////////////////////////
// CExampleView diagnostics

#ifdef _DEBUG
void CExampleView::AssertValid() const
{
	CView::AssertValid();
}

void CExampleView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CExampleDoc* CExampleView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExampleDoc)));
	return (CExampleDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CExampleView message handlers

⌨️ 快捷键说明

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