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

📄 333view.cpp

📁 这是一个基于visual C++的可视化图形界面的实现比较简单的画图软件。可以画出一些简单的图形
💻 CPP
字号:
// 333View.cpp : implementation of the CMy333View class
//

#include "stdafx.h"
#include "333.h"

#include "333Doc.h"
#include "333View.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMy333View

IMPLEMENT_DYNCREATE(CMy333View, CView)

BEGIN_MESSAGE_MAP(CMy333View, CView)
	//{{AFX_MSG_MAP(CMy333View)
	ON_COMMAND(ID_CIRLE, OnCirle)
	ON_COMMAND(ID_LINE, OnLine)
	ON_COMMAND(ID_POINT, OnPoint)
	ON_COMMAND(ID_RECT, OnRect)
	ON_COMMAND(ID_ZI, OnZi)
	ON_COMMAND(ID_TRI, OnTri)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMy333View construction/destruction

CMy333View::CMy333View()
{
	// TODO: add construction code here

	m_Brush.CreateSolidBrush(RGB(50,230,230));


}

CMy333View::~CMy333View()
{
}

BOOL CMy333View::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMy333View drawing

void CMy333View::OnDraw(CDC* pDC)
{
	CMy333Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CMy333View printing

BOOL CMy333View::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMy333View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMy333View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMy333View diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMy333View message handlers

void CMy333View::OnCirle() 
{
	// TODO: Add your command handler code here
	CClientDC dc(this);
	dc.SelectObject(&m_Brush);
	dc.Ellipse(0,0,200,200);
}

void CMy333View::OnLine() 
{
	// TODO: Add your command handler code here
	CClientDC dc(this);
	dc.MoveTo(300,100);
	dc.LineTo(500,100);
}

void CMy333View::OnPoint() 
{
	// TODO: Add your command handler code here
	CClientDC dc(this);
	dc.SelectObject(&m_Brush);
	dc.Ellipse(550,100,560,110);

}

void CMy333View::OnRect() 
{
	// TODO: Add your command handler code here
	CClientDC dc(this);
	dc.SelectObject(&m_Brush);
	dc.Rectangle(20,400,200,600);
}

void CMy333View::OnZi() 
{
	// TODO: Add your command handler code here
	CClientDC dc(this);
	dc.TextOut(500,400,"文字输出...",11);
}

void CMy333View::OnTri() 
{
	// TODO: Add your command handler code here
	CClientDC dc(this);
	CPen pen(PS_SOLID,3,RGB(255,50,30));
	dc.SelectObject(&pen);
	dc.MoveTo(500,450);
	dc.LineTo(300,600);
	dc.LineTo(700,600);
	dc.LineTo(500,450);
}

⌨️ 快捷键说明

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