Page 1 of 1

Setting Font for TChart Header

Posted: Wed Sep 17, 2008 4:59 pm
by 9532498
I need to set the Font for the header but can't find a SetFont Property for CTitles. I have the following

e.g.

LOGFONT mlf;
mChart->GetHeader().SetFont(mLf)


does not work (there is no SetFont method for CTitles)

Can someone point me in the right direction?

Posted: Thu Sep 18, 2008 10:07 am
by narcis
Hi nbp,

You need to use GetFont().SetName method as in the example I posted here.

Posted: Fri Feb 13, 2009 8:44 pm
by 9532498
Thanks. SetName() worked for me. Now I want to set the size of the font using the size I get from a CFontDialog but the text on the Chart is very big. I'm using

CFontDialog dlg;
dlg.doModal();


m_Chart->GetHeader().GetFont().SetSize( dlg.GetSize());

I also tried setting the height using the size as follows:

long newSize = m_Chart->GetHeader().GetFont().GetSize() * m_Chart->GetHeader.GetFont().GetPixelsPerInch/72;

m_Chart->GetHeader().GetFont().SetHeight(newSize);

This also produced much larger text than expected...

What property should I be setting?

Thanks

Posted: Fri Feb 13, 2009 9:12 pm
by 9532498
Another related question:

How do I initialize a CFontDialog object (MFC) with properties of the Chart Header? Is there an example I can view?

Thanks.

Posted: Mon Feb 16, 2009 11:50 am
by yeray
Hi nbp,

Here is an example of how you could set the chart's header font size to be shown at the editor:

Code: Select all

	LOGFONT lf;
	memset(&lf, 0, sizeof(LOGFONT));

	CClientDC dc(this);
	lf.lfHeight = -MulDiv(m_Chart1.GetHeader().GetFont().GetSize(), dc.GetDeviceCaps(LOGPIXELSY), 72);

	CFontDialog fdlg(&lf);
    fdlg.DoModal();