Page 1 of 1
custom legend bounds before drawing
Posted: Mon Apr 13, 2009 2:12 pm
by 15052934
I'm using V8.0.0.5 in MSVC 2008, trying to position the legend using the custom position settings. I would like to align the right side of the legend with something, say, the right side of the chart. I need the width of the legend when I draw it in its new location, but ShapeBounds returns the previous width which may include clipping or use a different font. Is there a way of determining the size of the legend box before I draw it?
Thanks,
JBell
Posted: Tue Apr 14, 2009 9:42 am
by narcis
Hi JBell,
You can use this code in form's initialization:
Code: Select all
m_Chart1.GetLegend().SetCustomPosition(true);
m_Chart1.GetEnvironment().InternalRepaint();
And implement chart's OnAfterDraw event like this:
Code: Select all
int width = m_Chart1.GetLegend().GetShapeBounds().GetRight() -
m_Chart1.GetLegend().GetShapeBounds().GetLeft();
int left = m_Chart1.GetAxis().GetBottom().GetIEndPos() - width;
m_Chart1.GetLegend().SetLeft(left);
Posted: Tue Apr 14, 2009 6:49 pm
by 15052934
InternalRepaint is what I was missing, thanks.
JBell