MFC: Changing font of a List control
c++, message, mfc, visual-c++
Solution
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.
Problem
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.