本文介绍了MFC:更改列表控件的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在运行时更改列表控件的字体,以便使用固定宽度的字体.我已经看到一些示例,这些示例建议我应该捕获NM_CUSTOMDRAW消息,但我想知道是否有更好的方法可以做到这一点.
I need to at run time change the font of a List Control so as to used a fixed width font. I have seen some examples which suggest I should trap the NM_CUSTOMDRAW message, but I was wondering if there was a better way of doing it.
谢谢.
推荐答案
创建一个适当的CFont对象,并通过调用SetFont()并传入CFont来设置控件的字体,如下所示:
Create an appropriate CFont object, and set the control's font by calling SetFont(), passing in the CFont, like so:
m_font.CreatePointFont(90,"Courier New");
m_listCtrl.SetFont(&m_font);
这假定您有一个带有"CFont m_font"成员和附加到列表控件的"m_listCtrl"成员的窗口或对话框对象.
This assumes that you've got a window or dialog object with a "CFont m_font" member, and an "m_listCtrl" member attached to the list control.
这篇关于MFC:更改列表控件的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!