一. DrawText函数

1、函数定义,这里引用博客

3359 blog.csdn.net/by _ mxy/article/details/9932967

2、引用一个函数实现的demo

voidcmfctestdlg : onpaint ({ crect rect; getclientrect(rect; CDC* pDc=GetDC (; CFont new_font; //所制作字体宋体格式100是字高verify (new _ font.createpointfont ) 250、_T、pDc ); //选择此字体进入PDC cfont * default _ font=PDC-select object (new _ font )。 //设置使字体背景透明的PDC-setbkmode(transparent )//字体颜色PDC-settextcolor(RGB ) 250、91、91 ) ); //显示文本,中间显示PDC-drawtext (cstring (‘ this isa test!’ ) 、rect,dt _ singleline|dt _ center|dt _ vcenter; 恢复//PDC默认字体PDC-selectobject(default_font ); font对象new_font.DeleteObject (; //CDialogEx:OnPaint (; (二、TextOut函数

1、函数定义

1booltextout(/如果函数调用成功,则返回TRUE;否则返回FALSE

2 HDC hdc,//用于显示字符串的控制ID

3 int nXStart,//字符串所在的开始位置的左上角(x,y )的x坐标

4 int nYStart,//字符串所在的开始位置的左上角(x,y )的y坐标

5 LPCTSTR lpString,//显示的字符串内容

6 int cbString //字符串长度

7;

2、函数使用demo

voidcshowwordview :3360 ondraw (CDC * PDC ) { cshow worddoc * pdoc=get document }; assert_valid(pdoc; if (! pDoc )返回; //TODO:现在将绘图代码pDC=this-GetDC ()添加到本地数据中; CString str; str=’你好’; PDC-textout (100,100,str,sizeof )- 1 ); CString str1; str1=’但别在意!’ ; PDC-textout (100,130,str1; this-releasedc(PDC; }