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 8 16863
Try this in your Form's constructor:
this.SetStyle(System.Windows.Forms.ControlStyles.D oubleBuffer, true);
-vJ
"benben" <be******@yahoo.com.au> wrote in message
news:uL**************@TK2MSFTNGP12.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
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(System.Windows.Forms.ControlStyles.D oubleBuffer, true);
-vJ
"benben" <be******@yahoo.com.au> wrote in message news:uL**************@TK2MSFTNGP12.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
"benben" <be******@yahoo.com.au> wrote in message
news:en**************@TK2MSFTNGP09.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 OnPaintBackground implementation. You can override this, and not do
anything in it, or you could set the control Style AllPaintingInWmPaint. I
personally prefer this method, in fact, I usually set the following:
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint,
ControlStyles.UserPaint, 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(System.Windows.Forms.ControlStyles.D oubleBuffer, true);
-vJ
"benben" <be******@yahoo.com.au> wrote in message news:uL**************@TK2MSFTNGP12.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 > >
benben wrote: What is the general strategy to reduce screen flickering with C# Forms?
Try reducing hardware acceleration of the display.
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.
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**************@TK2MSFTNGP09.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 OnPaintBackground implementation. You can override this, and not
do anything in it, or you could set the control Style AllPaintingInWmPaint. I personally prefer this method, in fact, I usually set the following:
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint, ControlStyles.UserPaint, 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(System.Windows.Forms.ControlStyles.D oubleBuffer, true);
-vJ
"benben" <be******@yahoo.com.au> wrote in message news:uL**************@TK2MSFTNGP12.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 > >
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**************@TK2MSFTNGP11.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**************@TK2MSFTNGP09.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 OnPaintBackground implementation. You can override this, and not do anything in it, or you could set the control Style AllPaintingInWmPaint. I personally prefer this method, in fact, I usually set the following:
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint, ControlStyles.UserPaint, 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(System.Windows.Forms.ControlStyles.D oubleBuffer, true); >> >> -vJ >> >> "benben" <be******@yahoo.com.au> wrote in message >> news:uL**************@TK2MSFTNGP12.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 >> > >> > >> >> > >
I found a trick!
In my original tests I used newly created Graphics objects, e.g.
Graphics paintSurface = Graphics.FromHwnd(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**************@TK2MSFTNGP09.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 OnPaintBackground implementation. You can override this, and not
do anything in it, or you could set the control Style AllPaintingInWmPaint. I personally prefer this method, in fact, I usually set the following:
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint, ControlStyles.UserPaint, 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(System.Windows.Forms.ControlStyles.D oubleBuffer, true);
-vJ
"benben" <be******@yahoo.com.au> wrote in message news:uL**************@TK2MSFTNGP12.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 > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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.
{
.......
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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?
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |