exampl~3.cpp

来自「本书所附光盘的内容包含了开发实例的所有程序源码」· C++ 代码 · 共 62 行

CPP
62
字号
// Example016View.cpp : CExample016View 类的实现
//
#include "stdafx.h"
#include "Example016.h"
#include "Example016Doc.h"
#include "Example016View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// CExample016View
IMPLEMENT_DYNCREATE(CExample016View, CView)
BEGIN_MESSAGE_MAP(CExample016View, CView)
END_MESSAGE_MAP()

// CExample016View 构造/销毁
CExample016View::CExample016View()
{
	// TODO: 在此处添加构造代码
}

CExample016View::~CExample016View()
{
}

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

// CExample016View 绘制
void CExample016View::OnDraw(CDC* pDC)
{
	CExample016Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: 在此处为本机数据添加绘制代码
	using namespace Gdiplus;
	Graphics graphics(pDC->m_hDC);
	WCHAR string[256];
	wcscpy(string, L"Visual C++");

	StringFormat stringFormat;
	stringFormat.SetFormatFlags(StringFormatFlagsDirectionVertical);

	Font myFont(L"Arial", 20);
	PointF origin(100.0f, 0.0f);
	SolidBrush blackBrush(Color(255, 0, 0, 255));

	graphics.DrawString( string, wcslen(string), &myFont, origin,  &stringFormat, &blackBrush);
}

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

⌨️ 快捷键说明

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