MFC: Changing font of a List control

末鹿安然 提交于 2019-12-12 19:07:51

问题


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.

Thanks.


回答1:


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);

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.



来源:https://stackoverflow.com/questions/271845/mfc-changing-font-of-a-list-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!