views:

643

answers:

1

Hi guys,

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.

+4  A: 

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(&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.

DavidK