invalidate and onpaint (how to handel multiple rectangels without flicker)

N

news.austin.rr.com

Hi,

I'am writing a graphing custom control in C# .NET CF. I have a rectangle for
the client area which includes an area at the bottom of the graph for
displaying a value on the far left and another value on the far right. I
have another rectangle that is the graph client area. The code below creates
the 2 rectangles.

Rectangle rcClient = this.ClientRectangle;
Rectangle rcGraphClient = new Rectangle(rcClient.X, rcClient.Y,
rcClient.Width, rcClient.Height - 20);

as you can see the second rectangle leaves room for my values to be
displayed on the bottom left and bottom right.

I also use double buffering and draw to a bitmap offscreen.

However, if i only invalidate the rcGraphClient I still get flicker on the
screen. The graph trace is being drawn very fast using a single call to the
drawpolygon method.

The question is this...

should i let my paint routine always draw everything and only invalidate the
rectangles im updating?

Are there any good resources (books) that go into detail on creating high
quality custom controls that are complex like a graphing control?

I just want to know the standard practice on invalidating rectangles and
handling the logic for the onpaint event.

Thanks
 
G

Guest

You do *all* drawing offscreen and you still get flicker? I've never seen
that. The RoundGauge in the SDF has a lot of custom drawing and I've run
multiples on the screen at one time. Another useful technique is in the
ctor create a bitmap of the items that don't change (labels, backgrounds,
etc) and then blit that into your offscreen buffer and draw the new items
onto that, then blit the entire buffer to the screen.

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top