473,889 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Weird refresh/paint situation

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
5 1406
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*******@Roun dTripInc.com> wrote in message
news:uf******** ******@TK2MSFTN GP15.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
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*******@Roun dTripInc.com> wrote in message
news:e5******** ******@TK2MSFTN GP09.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*******@Roun dTripInc.com> wrote in message
news:uf******** ******@TK2MSFTN GP15.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
> 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
> 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**********@s kyscan.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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2596
by: Minti | last post by:
Hi there all, I am having a weird problem in the following Applet code, <begin code> public class MouseInputTester extends java.applet.Applet { private String msg = ""; private int mouseX ; private int mouseY; static int i = 0;
13
3814
by: Wolfgang Kaml | last post by:
Hello All, I have been researching newsgroups and knowledgebase all morning and not found a solution that would solve the problem I have. I am having an ASP or ASPX web page that implement a counter functionality and read/insert some data in a MS Access database on that Windows 2003 server. The weird part is, as long as the web page is very short in size, I can hit the refresh button and Internet Explorer will reload the page and display...
1
14144
by: Amy | last post by:
What's different between Controls method Refresh() and Invalidate(), Refresh() and Update()? Your help will be appreciated. Thanks.
1
6282
by: James | last post by:
I have a data grid refresh problem. I have a few columns and the first column is data in the form of numbers. And in the form of the data grid if I specify for example something like a code(in a text box) the column of numbers should change colors depending on whether the number was in the specified code(if it belongs to the code, color the cell (first column) in Red and if not in some other color). It all works out fine until I scroll...
3
6740
by: redneon | last post by:
Is an event fired whenever there's a screen refresh? I'm wanting to run a certain method whenever there's a screen refresh and was wondering if I could override wndproc and listen for an event to do it. Any ideas? Darrell
2
1899
by: Peter Oliphant | last post by:
I now have graphics being drawn in the Paint event of my form (yeah, and it's very cool). Problem was that it only updated any changes to these graphics when Paint was called. So, I then made it so the Refresh() method of the form was called for each graphic object. In this case it drew just fine, but Paint was being called so often I lost control of the form (e.g., trying to close the form using the close 'x' in upper right corner...
17
8569
by: SamSpade | last post by:
picDocument is a picturebox When I do picDocument.Invalidate() the box paints. But if instead I do picDocument.Refresh() the box does not paint. What does Refresh do. I guessed it did an Invalidate and an Update. Can someone shed some light?
4
1168
by: CJ Taylor | last post by:
Alright, I wrote this program that is used throughout my entire company for the past 9 months. Now, we have deployed it to well over 100 machines. So my Sys Admin comes up to me today and tells me how a list box will not display any values that are bound to it, unless he clicks on another tab and then comes back (presumably calling a refresh). So for a test I went ahead and called refresh whenever the list box was clicked on, jsut...
1
7207
by: Executor | last post by:
Hi you all, I have created a usercontrol with a filledEllipses on a filledRectangle, using this Paint event: private void myControl_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { SolidBrush aBrush = new SolidBrush(this.BackColor); e.Graphics.FillRectangle(aBrush, 10,10, this.Width - 10, this.Height
0
9962
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9810
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11198
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9609
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7150
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5829
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4647
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3256
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.