Page 1 of 1

Custom OnPaint additions with new release

Posted: Wed Oct 10, 2007 1:28 pm
by 13045435
Hi,

Firstly I wanted to mention that the latest update with the double buffering update is excellent. It’s nice and fast after it’s created the chart, no more sluggish windows.

We have one minor problem as a side effect though which I’m hoping you can help with. We override the OnPaint handler to write custom header and footer information and provide some hot-tracking in a Windows Forms application. What we’re finding is that the header and footer information doesn’t always get redrawn properly when windows are dragged over the top. The underlying chart is fine but if we drag a form over the top quickly, sometimes we only see part of the custom text.

We could probably get rid of most of the existing header and footer code and re-write it to use the chart annotation method but if there’s a simple way around it to accommodate the new changes, we’d prefer to do it that way.

It would be good to know in case there are other occasions we need to override the OnPaint handler.

Posted: Thu Oct 11, 2007 10:02 am
by narcis
Hi Loz,

Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance!

Posted: Thu Oct 11, 2007 12:29 pm
by 13045435
I've posted an example...

The project file is called: ChartOnPaint.rar

The OnPaint handler is in DerivedControls.cs

The function that writes the custom text is DrawHeaderAndFooterText.

We're also doing a few other custom bits and pieces but I've tried to create a basic stripped down example that demonstrates the issue.

To replicate the problem, quickly drag another window over the application when it's running. e.g. Explorer or anything else you have open and you'll see that the thumbnail is painted from what I assume to be the internally cached buffer which doesn't include the added text.

Thanks.

Posted: Mon Oct 15, 2007 1:46 pm
by narcis
Hi Loz,

Thanks for the example project. You can achieve what you request changing your OnPaint override for this:

Code: Select all

		private BufferedGraphics bGraphics;
		private Steema.TeeChart.IChart parent;

		protected override void OnPaint(PaintEventArgs pe)
		{
			base.OnPaint(pe);
			parent = Chart.Parent;
			bGraphics = parent.GetBackBuffer();
			DrawHeaderAndFooterText(bGraphics.Graphics);
			bGraphics.Render();
		}

Posted: Mon Oct 15, 2007 2:06 pm
by 13045435
That's great, many thanks. We'll get the changes put in place as soon as we can.

Thanks for your excellent support.

Posted: Mon Oct 15, 2007 2:25 pm
by narcis
Hi Loz,

You're very welcome! We are glad to hear that helped.

Posted: Mon Oct 22, 2007 11:24 am
by Chris
Hello Loz,

Please be aware that in future releases, the code below will not compile:

Code: Select all

      private BufferedGraphics bGraphics;
      private Steema.TeeChart.IChart parent;

      protected override void OnPaint(PaintEventArgs pe)
      {
         base.OnPaint(pe);
         parent = Chart.Parent;
         bGraphics = parent.GetBackBuffer();
         DrawHeaderAndFooterText(bGraphics.Graphics);
         bGraphics.Render();
      }
The code has been refactored somewhat meaning that the BufferedGraphics class will be available directly from the TeeChart Graphics3D class. The following code will therefore replace the above:

Code: Select all

      protected override void OnPaint(PaintEventArgs pe)
		{
			base.OnPaint(pe);
			DrawHeaderAndFooterText(Chart.Graphics3D.BackBuffer.Graphics);
			Chart.Graphics3D.BackBuffer.Render();
		}