Page 1 of 1

void CTChart::Draw(long, long, long, long, long)

Posted: Tue Sep 30, 2008 5:14 pm
by 9523585
I am using the Draw method to render charts on device contexts that have other components and controls being drawn. Having the chart render on my own DCs lets me control the z-order of all of the controls. So I need the Chart to be transparent to anything else rendered on the DC. A major problem is that I can't get CTChart to render transparently. It always clears the rect specifed to the Draw() method. Is there any way to specify a true transparent graph that would just render itself on the DC and not clear then render?

Posted: Mon Oct 06, 2008 11:02 am
by narcis
Hi TMECHAM,

I'm sorry but as far as I know this is not possible.

Posted: Wed Oct 08, 2008 6:28 pm
by 9525016
Yeah, if I understand you correctly, this can be done. Use tchart's OnBeforeDraw event and then write to the DC from there. This will allow you to draw before the chart is drawn, making it look transparent.

To get the DC you want, I used this function:

Code: Select all

CDC& CGraphs::GetDC() const
{
	VARIANT & dcHandle = GetTChart().GetCanvas().GetHandleDC();
	ASSERT(dcHandle.vt == VT_I4);
	CDC& dc = *CDC::FromHandle((HDC)dcHandle.intVal);
	return dc;	
}
Where GetTChart() is just a function to get the tchart object and CGraphs is just a container class.

If you want the actual AX control to be transparent, then that is more difficult. Possibly by setting the AX extended style to WS_TRANSPARENT (I think that is what it is called) and then capturing the WS_PAINT event, you could _potentially_ get it to work, but I've not tried this.

Hope this helps.