Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Flicker, even with BufferedGraphicsContext

52 views
Skip to first unread message

Nik Coughlin

unread,
Mar 19, 2007, 7:56:29 PM3/19/07
to
Hi,

I can't seem to elimate flicker. I'm drawing to a panel via its OnPaint.
I've tried setting the form's doublebuffer to true, to no avail, so I tried
using ControlStyles.OptimizedDoubleBuffer, still no good. Then I tried
using good old BufferedGraphicsContext in the panel OnPaint, which has
always worked for me in the past, but I am still getting flicker. It's
driving me crazy. All I'm doing is drawing a couple of GraphicsPaths to the
panel. As soon as I start doing any translation or rotation I get flicker.

Not sure where to go from here. Any suggestions?


Nik Coughlin

unread,
Mar 19, 2007, 9:11:52 PM3/19/07
to

Here's the exe demonstrating the problem, can upload source too if required:
http://nrkn.com/temp/VectorRl.exe


Michael C

unread,
Mar 19, 2007, 11:05:25 PM3/19/07
to
"Nik Coughlin" <nrkn...@gmail.com> wrote in message
news:etn7vl$tje$1...@aioe.org...

You need to set the double buffering of the panel, not the form.

Michael

PS, I don't think anyone's likely to run an exe.


Nik Coughlin

unread,
Mar 19, 2007, 11:06:58 PM3/19/07
to

A panel doesn't have a doublebuffered property. Aside from which, I'm using
manual double buffering (via BufferedGraphicsContext) on the panel, and I'm
still getting flicker.


Nik Coughlin

unread,
Mar 19, 2007, 11:11:12 PM3/19/07
to

Correction, it does have a doublebuffered property, but it's protected so I
can't use it. Shouldn't matter though, given that I'm doing it manually.


Michael C

unread,
Mar 20, 2007, 12:05:12 AM3/20/07
to
"Nik Coughlin" <nrkn...@gmail.com> wrote in message
news:etnjco$jr7$1...@aioe.org...

> Correction, it does have a doublebuffered property, but it's protected so
> I can't use it.

Try inheriting then and setting it.

> Shouldn't matter though, given that I'm doing it manually.

It should definately work.


>
>


Michael C

unread,
Mar 20, 2007, 12:05:48 AM3/20/07
to
"Nik Coughlin" <nrkn...@gmail.com> wrote in message
news:etnjco$jr7$1...@aioe.org...

> Correction, it does have a doublebuffered property, but it's protected so
> I can't use it.

I generally do this stuff in a usercontrol anyway.

Nik Coughlin

unread,
Mar 20, 2007, 12:24:17 AM3/20/07
to
Michael C wrote:
> "Nik Coughlin" <nrkn...@gmail.com> wrote in message
> news:etnjco$jr7$1...@aioe.org...
>> Correction, it does have a doublebuffered property, but it's
>> protected so I can't use it.
>
> Try inheriting then and setting it.
>

I'll give it a try, thanks


Nik Coughlin

unread,
Mar 20, 2007, 12:30:57 AM3/20/07
to

Awesome, thanks.


Bob Powell [MVP]

unread,
Mar 20, 2007, 7:59:44 AM3/20/07
to
Objects that support double buffering only do so for their own drawing
surface.

Child controls have their own windows and so would need their own double
buffering turned on in order to eliminate flicker from their surfaces.

Double buffering the form will not affect any child controls or their
own contained controls. Basically, for forms, user controls and
container controls of all types double buffering us useless.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

Nik Coughlin

unread,
Mar 20, 2007, 5:11:29 PM3/20/07
to
Bob Powell [MVP] wrote:
> Objects that support double buffering only do so for their own drawing
> surface.
>
> Child controls have their own windows and so would need their own
> double buffering turned on in order to eliminate flicker from their
> surfaces.
> Double buffering the form will not affect any child controls or their
> own contained controls. Basically, for forms, user controls and
> container controls of all types double buffering us useless.

Thanks Bob. I just (foolishly) assumed that because the doublebuffered
property of child controls was protected that it must be inherited from the
form.


Glen Flexman

unread,
Apr 19, 2007, 5:49:40 AM4/19/07
to
Does this mean that we need to inherit all the controls on a form to enable
double buffering?

I ask as I have a splitcontainer which holds 2 usercontrols. Each
usercontrol has many panels with various controls on them. The panels are
positioned at runtime and change positions based on a a user selected type.
When a new type is selected you can watch the usercontrol being repainted.
I've so far tried suspend/resume layout. Inheriting the panels and setting
doublebuffered to true.

The user control however still has an ugly slow repaint. We're quite a way
down the development path so it's too late to attempt all this in xaml.

Any ideas on how to ensure double buffering is working correctly?

"Nik Coughlin" <nrkn...@gmail.com> wrote in message

news:etpimb$o1h$1...@aioe.org...

0 new messages