473,787 Members | 2,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

screen flickering

I created a form and overrided OnPaint, OnClick and OnResize methods. My
OnPaint calls base.OnPaint then repaints the whole screen.

The screen flickers a lot! It didn't happen when the app was written in C++.

What is the general strategy to reduce screen flickering with C# Forms?
Perhaps saving the screen as a bitmap and just bitblip when painted, and
only change the bitmap when necessary? is it possible?

ben
Nov 16 '05 #1
8 16929
Try this in your Form's constructor:

this.SetStyle(S ystem.Windows.F orms.ControlSty les.DoubleBuffe r, true);

-vJ

"benben" <be******@yahoo .com.au> wrote in message
news:uL******** ******@TK2MSFTN GP12.phx.gbl...
I created a form and overrided OnPaint, OnClick and OnResize methods. My
OnPaint calls base.OnPaint then repaints the whole screen.

The screen flickers a lot! It didn't happen when the app was written in
C++.

What is the general strategy to reduce screen flickering with C# Forms?
Perhaps saving the screen as a bitmap and just bitblip when painted, and
only change the bitmap when necessary? is it possible?

ben

Nov 16 '05 #2
What does it buffer?

Plus, I do not use standard controls in this project, instead I paint
directly to the form using GDI+.

ben
Try this in your Form's constructor:

this.SetStyle(S ystem.Windows.F orms.ControlSty les.DoubleBuffe r, true);

-vJ

"benben" <be******@yahoo .com.au> wrote in message
news:uL******** ******@TK2MSFTN GP12.phx.gbl...
I created a form and overrided OnPaint, OnClick and OnResize methods. My
OnPaint calls base.OnPaint then repaints the whole screen.

The screen flickers a lot! It didn't happen when the app was written in
C++.

What is the general strategy to reduce screen flickering with C# Forms?
Perhaps saving the screen as a bitmap and just bitblip when painted, and
only change the bitmap when necessary? is it possible?

ben


Nov 16 '05 #3
"benben" <be******@yahoo .com.au> wrote in message
news:en******** ******@TK2MSFTN GP09.phx.gbl...
What does it buffer?
Instead of drawing directly onto the screen, it buffers the image to an
in-memory bitmap, and then blits the bitmap onto the screen. This does
reduce flicker, although your problem might also be caused by the parent
classes OnPaintBackgrou nd implementation. You can override this, and not do
anything in it, or you could set the control Style AllPaintingInWm Paint. I
personally prefer this method, in fact, I usually set the following:

SetStyle(Contro lStyles.DoubleB uffer | ControlStyles.A llPaintingInWmP aint,
ControlStyles.U serPaint, true);

HTH

--
Sean Hederman

http://codingsanity.blogspot.com
Plus, I do not use standard controls in this project, instead I paint
directly to the form using GDI+.

ben
Try this in your Form's constructor:

this.SetStyle(S ystem.Windows.F orms.ControlSty les.DoubleBuffe r, true);

-vJ

"benben" <be******@yahoo .com.au> wrote in message
news:uL******** ******@TK2MSFTN GP12.phx.gbl...
>I created a form and overrided OnPaint, OnClick and OnResize methods. My
> OnPaint calls base.OnPaint then repaints the whole screen.
>
> The screen flickers a lot! It didn't happen when the app was written in
> C++.
>
> What is the general strategy to reduce screen flickering with C# Forms?
> Perhaps saving the screen as a bitmap and just bitblip when painted,
> and
> only change the bitmap when necessary? is it possible?
>
> ben
>
>



Nov 16 '05 #4
benben wrote:
What is the general strategy to reduce screen flickering with C# Forms?


Try reducing hardware acceleration of the display.
Nov 16 '05 #5
I don't think I can do that to my user even if it is applicable. but thanks
anyway for your suggestion!

ben
benben wrote:
What is the general strategy to reduce screen flickering with C# Forms?


Try reducing hardware acceleration of the display.

Nov 16 '05 #6
Thanks Sean!! The problem does improved with your suggestion!!

Just for a matter of interest: if the form buffers the screen, how can I get
access to this bitmap?

Another question: I have been using the Graphics object as the painting
surface. Instead of a Graphics object associated with the actual screen, can
i create other Graphics objects that are associated to 1. a printing surface
2. a bitmap image?

ben
"benben" <be******@yahoo .com.au> wrote in message
news:en******** ******@TK2MSFTN GP09.phx.gbl...
What does it buffer?
Instead of drawing directly onto the screen, it buffers the image to an
in-memory bitmap, and then blits the bitmap onto the screen. This does
reduce flicker, although your problem might also be caused by the parent
classes OnPaintBackgrou nd implementation. You can override this, and not

do anything in it, or you could set the control Style AllPaintingInWm Paint. I
personally prefer this method, in fact, I usually set the following:

SetStyle(Contro lStyles.DoubleB uffer | ControlStyles.A llPaintingInWmP aint,
ControlStyles.U serPaint, true);

HTH

--
Sean Hederman

http://codingsanity.blogspot.com
Plus, I do not use standard controls in this project, instead I paint
directly to the form using GDI+.

ben
Try this in your Form's constructor:

this.SetStyle(S ystem.Windows.F orms.ControlSty les.DoubleBuffe r, true);

-vJ

"benben" <be******@yahoo .com.au> wrote in message
news:uL******** ******@TK2MSFTN GP12.phx.gbl...
>I created a form and overrided OnPaint, OnClick and OnResize methods. My > OnPaint calls base.OnPaint then repaints the whole screen.
>
> The screen flickers a lot! It didn't happen when the app was written in > C++.
>
> What is the general strategy to reduce screen flickering with C# Forms? > Perhaps saving the screen as a bitmap and just bitblip when painted,
> and
> only change the bitmap when necessary? is it possible?
>
> ben
>
>



Nov 16 '05 #7
Yes, you can do that. You can use the same code for both. If you want to get
the buffer, it is best to do the double buffering yourself, writing to a
Graphics created from a bitmap, and transferring the bitmap to the
paint-provided Graphics when done.

Regards,
Frank Hileman

check out VG.net: http://www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
"benben" <be******@yahoo .com.au> wrote in message
news:O5******** ******@TK2MSFTN GP11.phx.gbl...
Thanks Sean!! The problem does improved with your suggestion!!

Just for a matter of interest: if the form buffers the screen, how can I
get
access to this bitmap?

Another question: I have been using the Graphics object as the painting
surface. Instead of a Graphics object associated with the actual screen,
can
i create other Graphics objects that are associated to 1. a printing
surface
2. a bitmap image?

ben
"benben" <be******@yahoo .com.au> wrote in message
news:en******** ******@TK2MSFTN GP09.phx.gbl...
> What does it buffer?


Instead of drawing directly onto the screen, it buffers the image to an
in-memory bitmap, and then blits the bitmap onto the screen. This does
reduce flicker, although your problem might also be caused by the parent
classes OnPaintBackgrou nd implementation. You can override this, and not

do
anything in it, or you could set the control Style AllPaintingInWm Paint.
I
personally prefer this method, in fact, I usually set the following:

SetStyle(Contro lStyles.DoubleB uffer | ControlStyles.A llPaintingInWmP aint,
ControlStyles.U serPaint, true);

HTH

--
Sean Hederman

http://codingsanity.blogspot.com
> Plus, I do not use standard controls in this project, instead I paint
> directly to the form using GDI+.
>
> ben
>
>> Try this in your Form's constructor:
>>
>> this.SetStyle(S ystem.Windows.F orms.ControlSty les.DoubleBuffe r, true);
>>
>> -vJ
>>
>> "benben" <be******@yahoo .com.au> wrote in message
>> news:uL******** ******@TK2MSFTN GP12.phx.gbl...
>> >I created a form and overrided OnPaint, OnClick and OnResize methods. My >> > OnPaint calls base.OnPaint then repaints the whole screen.
>> >
>> > The screen flickers a lot! It didn't happen when the app was written in >> > C++.
>> >
>> > What is the general strategy to reduce screen flickering with C# Forms? >> > Perhaps saving the screen as a bitmap and just bitblip when painted,
>> > and
>> > only change the bitmap when necessary? is it possible?
>> >
>> > ben
>> >
>> >
>>
>>
>
>



Nov 16 '05 #8
I found a trick!

In my original tests I used newly created Graphics objects, e.g.

Graphics paintSurface = Graphics.FromHw nd(this.Handle) ;

And there was a lot of screen flickering.

Once I found that there is already a Graphics object in the PaintEventArgs
parameter passed into my OnPaint, I started to use it and the flickering
disappeared!

Why does creating a new Graphics object out of the window handle create such
an overhead?

ben

"benben" <be******@yahoo .com.au> wrote in message
news:en******** ******@TK2MSFTN GP09.phx.gbl...
What does it buffer?
Instead of drawing directly onto the screen, it buffers the image to an
in-memory bitmap, and then blits the bitmap onto the screen. This does
reduce flicker, although your problem might also be caused by the parent
classes OnPaintBackgrou nd implementation. You can override this, and not

do anything in it, or you could set the control Style AllPaintingInWm Paint. I
personally prefer this method, in fact, I usually set the following:

SetStyle(Contro lStyles.DoubleB uffer | ControlStyles.A llPaintingInWmP aint,
ControlStyles.U serPaint, true);

HTH

--
Sean Hederman

http://codingsanity.blogspot.com
Plus, I do not use standard controls in this project, instead I paint
directly to the form using GDI+.

ben
Try this in your Form's constructor:

this.SetStyle(S ystem.Windows.F orms.ControlSty les.DoubleBuffe r, true);

-vJ

"benben" <be******@yahoo .com.au> wrote in message
news:uL******** ******@TK2MSFTN GP12.phx.gbl...
>I created a form and overrided OnPaint, OnClick and OnResize methods. My > OnPaint calls base.OnPaint then repaints the whole screen.
>
> The screen flickers a lot! It didn't happen when the app was written in > C++.
>
> What is the general strategy to reduce screen flickering with C# Forms? > Perhaps saving the screen as a bitmap and just bitblip when painted,
> and
> only change the bitmap when necessary? is it possible?
>
> ben
>
>



Nov 16 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4073
by: karthigan | last post by:
I am writing a simple hardware test program in C that would run from Windows command line. Inside one of the loops, I have this code fragment that would display the Iteration count. { .... system("cls"); printf("\nIteration:%d", i);
1
2121
by: RickN | last post by:
I have a form loaded with a full screen form image. I've overlayed a number of controls for filling in the form. When the form opens, I can watch as each control loads (flickering). It also does the same thing each time the form scrolls. What is the best strategy for getting rid of the flickering? Thanks, Rick
2
8615
by: John Lee | last post by:
Hi, I have a windows application that uses the listview to display about 50 items in detailed view - 4 columns. The first column is static and other columns will be updated in 100-1000ms - it looks awful when it's running - flickering too much!!! Anyone know how to solve this flickering problem? or how should I deal with this issue? I see some other C++ app can display more than 100 items without any flickering in such as speed. Can...
2
2530
by: John Lee | last post by:
Thanks Jay for your response. I tried your code and it still flickering a lot. To demonstrate it, you can grab a listview, create 3 columns - name, value, timestamp, in form_load event to add 50 items into that listview as Item1 - Item49, add a timer to your windows form, set the timer interval to 100 ms, in the event handler, add the code to update the value and timestamp Random r = new Random(); listView1.BeginUpdate();
0
412
by: benben | last post by:
I created a form and overrided OnPaint, OnClick and OnResize methods. My OnPaint calls base.OnPaint then repaints the whole screen. The screen flickers a lot! It didn't happen when the app was written in C++. What is the general strategy to reduce screen flickering with C# Forms? Perhaps saving the screen as a bitmap and just bitblip when painted, and only change the bitmap when necessary? is it possible? ben
5
2353
by: n00b | last post by:
I have some forms with maybe around 30 controls on each and anytime I load these forms different parts of it start flickering though not all of them at once and not the same ones everytime. the forms are each generally separated into 2-3 different panels and they start flickering with no apparent pattern. I've tried turning on double buffering, same thing, no improvements. I've tested it on different computers with different specifications...
6
3639
by: Mark Thompson | last post by:
I have a problem with my Visual Basic .NET 2003 application which I have so far been unable to resolve. I am trying to get an OpenGL control that I have created working properly as a control on my main form in my VB.NET application. It does work and render correctly but the problem is that there is an awful flickering that happens on most PCs I try it on. The flickering is reminiscent of the sort that you get on a TV when it is not tuned...
3
2247
by: piers.allard | last post by:
I am looking for assistance with an issue I am gettting with an Access2k application. When I have xp style switched on, switching from screen to screen causes the first screen to resize to it's 'restore' size before the second screen appears. This causes a 'flicker' affect on the screen. Any suggestions? Kind Regards Tim Allard
1
2354
by: =?Utf-8?B?Umljaw==?= | last post by:
I am trying to prevent screen flickering when clicked on a button; how do I use Hide Card in vs2005? Any other way?
0
9655
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
9498
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
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5398
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...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.