新建一个单文档工程;
在OnDraw函数加入如下代码;
void CShgView::OnDraw(CDC* pDC)
{
CShgDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CString strshg[5]; //字义输出诗歌
strshg[0] = "八阵图";
strshg[1] = "功盖三分国";
strshg[2] = "名成八阵图";
strshg[3] = "江流石不转";
strshg[4] = "遗恨失吞吴";
//创建两个字体对象
CFont *OldFont, NewFont;
LOGFONT MyFont = {
30,
10,
0,
0,
0,
1,
1,
0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH,
"黑体"
};
NewFont.CreatePointFont(200, "宋体", NULL);
OldFont = pDC->SelectObject(&NewFont);
pDC->TextOut(150, 100, strshg[0]);
pDC->SelectObject(OldFont);
NewFont.DeleteObject();
pDC->SelectStock