CFont::CreatePointFont
这个函数提供了一种简单的方法来创建指定字体类型和字体大小
BOOL CreatePointFont(
int nPointSize,
LPCTSTR lpszFaceName,
CDC* pDC = NULL
);
参数:
nPointSize
请求的的大小,取其1/10为其字体大小。例如:120为12-point font
lpszFaceName
一个CSTring或者一个指向null-terminated(以空为结尾的)字符串指针来标注字体名称。长度不得超过30个字母。函数EnumFontFamilies可列举能够使用的字体。如果lpszFaceName是NULL,那么GDI uses a device-independent typeface.
pDC
指向CDC对象的指针,用来将字体大小转化为逻辑单位,如果是NULL,那么就根据屏幕当前的上下文(context)来转化
返回值
非零为成功,否则失败
备注
这个函数能根据CDC自动转化字体.
当你完成CFont对象的创建(by the CreatePointFont function),first select the font out of the device context, then delete the CFont object.
例子:
Example
参见
CFont Overview | Class Members | Hierarchy Chart | CFont::CreatePointFontIndirect | CFont::CreateFont
这个函数提供了一种简单的方法来创建指定字体类型和字体大小
BOOL CreatePointFont(
int nPointSize,
LPCTSTR lpszFaceName,
CDC* pDC = NULL
);
参数:
nPointSize
请求的的大小,取其1/10为其字体大小。例如:120为12-point font
lpszFaceName
一个CSTring或者一个指向null-terminated(以空为结尾的)字符串指针来标注字体名称。长度不得超过30个字母。函数EnumFontFamilies可列举能够使用的字体。如果lpszFaceName是NULL,那么GDI uses a device-independent typeface.
pDC
指向CDC对象的指针,用来将字体大小转化为逻辑单位,如果是NULL,那么就根据屏幕当前的上下文(context)来转化
返回值
非零为成功,否则失败
备注
这个函数能根据CDC自动转化字体.
当你完成CFont对象的创建(by the CreatePointFont function),first select the font out of the device context, then delete the CFont object.
例子:
Example
参见
CFont Overview | Class Members | Hierarchy Chart | CFont::CreatePointFontIndirect | CFont::CreateFont
// The code fragment shows how to create a font object,
// select the font object into a DC (device context) for text
// drawing, and finally delete the font object.
// select the font object into a DC (device context) for text
// drawing, and finally delete the font object.
CClientDC dc(this);
CFont font;
VERIFY(font.CreatePointFont(120, "Arial", &dc));
VERIFY(font.CreatePointFont(120, "Arial", &dc));
// Do something with the font just created...
CFont* def_font = dc.SelectObject(&font);
dc.TextOut(5, 5, "Hello", 5);
dc.SelectObject(def_font);
CFont* def_font = dc.SelectObject(&font);
dc.TextOut(5, 5, "Hello", 5);
dc.SelectObject(def_font);
// Done with the font. Delete the font object.
font.DeleteObject();
font.DeleteObject();