By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,446 Members | 3,090 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,446 IT Pros & Developers. It's quick & easy.

Weird refresh/paint situation

P: n/a
I'm drawing graphics using the Graphics object one can grab in a Form's
Paint event. But I'm getting a weird thing happening...

These graphic shapes flicker (even if unchanged). UNLESS- I created a timer
and had the timer update a Label on the form with timer interval set to 10.
Now all the shapes I draw in the Paint event of the form draw WITHOUT
flicker!!!

What is updating a Label doing that is preventing flicker? Is it somehow
calling Paint more often? Why are the graphic shapes NOT being drawn at
times (which I assume is the cause of the flicker, 'frames' (or periods of
time) where the graphics aren't being displayed)?

This is weird because I'm not use to having to draw MORE objects to
elliminate flicker...hehe! Like I said, it's likely because Control's (such
as Label) somehow know what to do with the concepts of invalidated regions,
refresh, and update such that the Form always displays its Graphic objects
without flicker!!!

What can >I< do to accomplish the same thing without having to update a
Control? My solution right now is to create a bogus Label, place it off
screen (which by the way still elliminates the flicker even though its not
drawn!), add a Timer, make Timer update the color of the Label with timer
interval of 10. That is, whatever Label is doing, force it to do it on a
bogus object. But I'd rather do whatever its doing 'purely' to accomplish
this without creating the bogus Label!

Help, and thanks! : )

[==P==]
Nov 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Ok, more data for the problem.

It seems like some sort of timimg issue. Sometimes when I bring another form
up in front of my flickering form and then bring my form back, it stops
flickering (with the occasional shimmy). If I stop the program in the
debugger and thn start it up agian, it usually stops flickering. Obviously
because of this last tidbit I can't use the debugger to solve this... : (

I'm now doing the following, which still doesn't help, in fact it seems to
hurt. I now figure out the bounding box for my graphic and do an
'Invalidate" on this rectangle when I change the graphic. Still doesn't
work.

There must be someone out there that knows why Control's NEVER EVER flicker
but Graphics can!!! HELP!!!!

[==P==]

"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:uf**************@TK2MSFTNGP15.phx.gbl...
I'm drawing graphics using the Graphics object one can grab in a Form's
Paint event. But I'm getting a weird thing happening...

These graphic shapes flicker (even if unchanged). UNLESS- I created a
timer and had the timer update a Label on the form with timer interval set
to 10. Now all the shapes I draw in the Paint event of the form draw
WITHOUT flicker!!!

What is updating a Label doing that is preventing flicker? Is it somehow
calling Paint more often? Why are the graphic shapes NOT being drawn at
times (which I assume is the cause of the flicker, 'frames' (or periods of
time) where the graphics aren't being displayed)?

This is weird because I'm not use to having to draw MORE objects to
elliminate flicker...hehe! Like I said, it's likely because Control's
(such as Label) somehow know what to do with the concepts of invalidated
regions, refresh, and update such that the Form always displays its
Graphic objects without flicker!!!

What can >I< do to accomplish the same thing without having to update a
Control? My solution right now is to create a bogus Label, place it off
screen (which by the way still elliminates the flicker even though its not
drawn!), add a Timer, make Timer update the color of the Label with timer
interval of 10. That is, whatever Label is doing, force it to do it on a
bogus object. But I'd rather do whatever its doing 'purely' to accomplish
this without creating the bogus Label!

Help, and thanks! : )

[==P==]

Nov 17 '05 #2

P: n/a
Let me put this another way. How does one keep the Graphics that MUST be
drawn in the Paint event of the Form from flickering? Like I said, Control's
don't flicker, so why don't these flicker when Graphics shapes (e.g.,
ellipses, curves, circles, rectangles, closed curves, etc.) can? I actually
see these graphics flicker RIGHT NEXT to Controls that don't.

What is the SECRET here? : )

[==P==]

"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:e5**************@TK2MSFTNGP09.phx.gbl...
Ok, more data for the problem.

It seems like some sort of timimg issue. Sometimes when I bring another
form up in front of my flickering form and then bring my form back, it
stops flickering (with the occasional shimmy). If I stop the program in
the debugger and thn start it up agian, it usually stops flickering.
Obviously because of this last tidbit I can't use the debugger to solve
this... : (

I'm now doing the following, which still doesn't help, in fact it seems to
hurt. I now figure out the bounding box for my graphic and do an
'Invalidate" on this rectangle when I change the graphic. Still doesn't
work.

There must be someone out there that knows why Control's NEVER EVER
flicker but Graphics can!!! HELP!!!!

[==P==]

"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:uf**************@TK2MSFTNGP15.phx.gbl...
I'm drawing graphics using the Graphics object one can grab in a Form's
Paint event. But I'm getting a weird thing happening...

These graphic shapes flicker (even if unchanged). UNLESS- I created a
timer and had the timer update a Label on the form with timer interval
set to 10. Now all the shapes I draw in the Paint event of the form draw
WITHOUT flicker!!!

What is updating a Label doing that is preventing flicker? Is it somehow
calling Paint more often? Why are the graphic shapes NOT being drawn at
times (which I assume is the cause of the flicker, 'frames' (or periods
of time) where the graphics aren't being displayed)?

This is weird because I'm not use to having to draw MORE objects to
elliminate flicker...hehe! Like I said, it's likely because Control's
(such as Label) somehow know what to do with the concepts of invalidated
regions, refresh, and update such that the Form always displays its
Graphic objects without flicker!!!

What can >I< do to accomplish the same thing without having to update a
Control? My solution right now is to create a bogus Label, place it off
screen (which by the way still elliminates the flicker even though its
not drawn!), add a Timer, make Timer update the color of the Label with
timer interval of 10. That is, whatever Label is doing, force it to do it
on a bogus object. But I'd rather do whatever its doing 'purely' to
accomplish this without creating the bogus Label!

Help, and thanks! : )

[==P==]


Nov 17 '05 #3

P: n/a
> Let me put this another way. How does one keep the Graphics that MUST be
drawn in the Paint event of the Form from flickering? Like I said, Control's don't flicker, so why don't these flicker when Graphics shapes (e.g.,
ellipses, curves, circles, rectangles, closed curves, etc.) can? I actually see these graphics flicker RIGHT NEXT to Controls that don't.

What is the SECRET here? : )

The flikker is because you background is painted first to clear the
background and then your graphics shapes.
Flikker could be avoided by using a memory device context. where you draw
the complete image in a memory buffer and then swap it to the dialogbox
window, without painting the background first.

Nov 17 '05 #4

P: n/a
> The flikker is because you background is painted first to clear the
background and then your graphics shapes.
Flikker could be avoided by using a memory device context. where you draw
the complete image in a memory buffer and then swap it to the dialogbox
window, without painting the background first.


Sounds like page flipping. I like page flipping!

Ok. I currently draw to a Form (actually, my own class derived from a Form,
but therefore it is a Form) via a Graphics object I get from the Form's
Paint event. How do I easily draw to an off-screen 'memory device context'
instead of the Form, and how do I then do the swap you mentioned?

It sounds like a great idea, but I need details! : )

[==P==]

"Olaf Baeyens" <ol**********@skyscan.be> wrote in message
news:43**********************@news.skynet.be...
Let me put this another way. How does one keep the Graphics that MUST be
drawn in the Paint event of the Form from flickering? Like I said,

Control's
don't flicker, so why don't these flicker when Graphics shapes (e.g.,
ellipses, curves, circles, rectangles, closed curves, etc.) can? I

actually
see these graphics flicker RIGHT NEXT to Controls that don't.

What is the SECRET here? : )

The flikker is because you background is painted first to clear the
background and then your graphics shapes.
Flikker could be avoided by using a memory device context. where you draw
the complete image in a memory buffer and then swap it to the dialogbox
window, without painting the background first.

Nov 17 '05 #5

P: n/a
> Sounds like page flipping. I like page flipping!
You could call it that.
.... It sounds like a great idea, but I need details! : )


I know how to do it in MFC but never done it in .NET
But I think this could explain you it.

http://www.codeproject.com/cs/media/...reeDrawing.asp

The flicker is because you are drawnig on the form and since it is live
drawing you see the build up.
On a very fast computer you might not notice it but on a slow computer it
could be annoying.

I believe that clearing the packground with a specific color, gives the most
flicker.

You could improve by only drawing the parts that changes, that could reduce
flicker, bit when you have to build up the complete image, then it is back.
So the double buffer technique is the best way to solve this problem I
discovered.
Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.