问题
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