Page 1 of 1

ArgumentException when Hiding.Showing MDI child form

Posted: Mon Nov 24, 2008 3:51 pm
by 14049416
I have read several threads on this and I am still not sure what a good approach is.

We have an MDI application that has mdi children containing charts. If the child form his hidden then shown we receive an ArgumentException when it hits the line "Chart.Graphics3D.BackBuffer.Render();" in the OnPaint of TeeChart.cs.

One solution that was pitched by Narcis was to set Graphics3D.UseBuffer to false, i.e. this.tChart1.Graphics3D.UseBuffer = false;

This certainly prevents the error but now the repainting looks bad when another window is passed over the chart. I read some other thread talking about DoubleBufferring but kind of got lost in the replies.

Is there a good solution to my problem, preventing the error and having a clean repaint?

Thanks,
Kevin

Re: ArgumentException when Hiding.Showing MDI child form

Posted: Tue Nov 25, 2008 9:18 am
by Chris
Hello,
WD_Gordon wrote:This certainly prevents the error but now the repainting looks bad when another window is passed over the chart. I read some other thread talking about DoubleBufferring but kind of got lost in the replies.

Is there a good solution to my problem, preventing the error and having a clean repaint?
The history of the implementation of manual double-buffering can be found in this thread:
http://www.teechart.net/support/viewtopic.php?t=6631

As you can read here, the primary motivation for its inclusion into TChart was to prevent sluggish repainting when one window was moved over another. However, at that stage the MDI problems hadn't come into the fore. Now that they are here, the only solution at present is to do what NarcĂ­s suggests.

We are very willing to look into this problem and find a more satisfactory solution to it. If you would be so kind as to write for us a little app we can run "as-is" to reproduce your issue, we will study it and get back to you with more options. You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Posted: Tue Nov 25, 2008 1:45 pm
by 14049416
Another suggestion that I saw was to set the tChart1.Chart.Graphics3D.BackBuffer to null when the object is hidden or shown, i.e. tChart1.Chart.Graphics3D.BackBuffer = null. This seems to work and paints much cleaner than setting this.tChart1.Graphics3D.UseBuffer to false.

Are there any downsides to setting the BackBuffer to null?

Posted: Tue Nov 25, 2008 3:17 pm
by Chris
Hello,
WD_Gordon wrote:Are there any downsides to setting the BackBuffer to null?
Not at all. In fact, this is exactly what TChart's override of OnResize does:

Code: Select all

     protected override void OnResize(EventArgs e)
		{
			if (Chart.Graphics3D.BackBuffer != null)
			{
				Chart.Graphics3D.BackBuffer.Dispose();
				Chart.Graphics3D.BackBuffer = null;
			}
			base.OnResize(e);
		}