textureview.cpp

来自「Visual_C++.NET实用编程百例」· C++ 代码 · 共 110 行

CPP
110
字号
// textureView.cpp : CtextureView 类的实现
//

#include "stdafx.h"
#include "texture.h"

#include "textureDoc.h"
#include "textureView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CtextureView

IMPLEMENT_DYNCREATE(CtextureView, CView)

BEGIN_MESSAGE_MAP(CtextureView, CView)
	// 标准打印命令
	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()

// CtextureView 构造/析构

CtextureView::CtextureView()
{
	// TODO: 在此处添加构造代码

}

CtextureView::~CtextureView()
{
}

BOOL CtextureView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
	// 样式

	return CView::PreCreateWindow(cs);
}

// CtextureView 绘制

void CtextureView::OnDraw(CDC* pDC)
{
	CtextureDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;
	using namespace Gdiplus;
	Graphics graphics(pDC->m_hDC);
	Image image(L"test.jpg");
	TextureBrush tBrush(&image);
	Pen texturedPen(&tBrush,30);
	graphics.DrawImage(&image,0,0,image.GetWidth(),image.GetHeight());
	graphics.DrawEllipse(&texturedPen,320,20,50,70);
	graphics.DrawLine(&texturedPen,450,10,450,180);
	graphics.DrawRectangle(&texturedPen,350,200,50,70);
	// TODO: 在此处为本机数据添加绘制代码

	// TODO: 在此处为本机数据添加绘制代码
}


// CtextureView 打印

BOOL CtextureView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// 默认准备
	return DoPreparePrinting(pInfo);
}

void CtextureView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 打印前添加额外的初始化
}

void CtextureView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 打印后添加清除过程
}


// CtextureView 诊断

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

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

CtextureDoc* CtextureView::GetDocument() const // 非调试版本是内联的
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CtextureDoc)));
	return (CtextureDoc*)m_pDocument;
}
#endif //_DEBUG


// CtextureView 消息处理程序

⌨️ 快捷键说明

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