Click to See Complete Forum and Search --> : How to change font in ListCtrl


Vladimir Milyaev
April 8th, 1999, 08:31 AM
Hi!
I have code:

CFont Font;
if( Font.CreateFont( 20, //int nHeight,
30, //int nWidth,
0, //int nEscapement,
0, //int nOrientation,
0, //int nWeight,
1, //BYTE bItalic,
0, //BYTE bUnderline,
0, //BYTE cStrikeOut,
1, // BYTE nCharSet,
OUT_DEFAULT_PRECIS, //BYTE nOutPrecision,
CLIP_DEFAULT_PRECIS, //BYTE nClipPrecision,
DEFAULT_QUALITY, //BYTE nQuality,
VARIABLE_PITCH | TMPF_TRUETYPE, //BYTE nPitchAndFamily,
"Arial" //LPCTSTR lpszFacename
))
m_Table.SetFont( &Font, true );

This code does not change font (and size). What is wrong?
I know it is simple. Help, please.

Best regards, Bob.

LALeonard
April 8th, 1999, 11:23 AM
The CFont object must live as long as the CListCtrl object does. This means, the CFont must be a member of the same class the CListCtrl is, or be a (ugh) global variable, or be (ugh) a static variable within a function.

Make the CFont a member of the class and that should fix it.

LA Leonard - Definitive Solutions, Inc.

Vladimir Milyaev
April 9th, 1999, 01:51 AM
Gotcha.

Best regards, Bob.