Click here to Skip to main content
15,881,089 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
Generalvirtual methods on existing value types Pin
Ben Watson1-May-03 17:39
Ben Watson1-May-03 17:39 
GeneralRe: virtual methods on existing value types Pin
James T. Johnson1-May-03 17:57
James T. Johnson1-May-03 17:57 
Generalpaint application question Pin
lfsong30-Apr-03 0:41
lfsong30-Apr-03 0:41 
GeneralRe: paint application question Pin
J. Dunlap30-Apr-03 8:31
J. Dunlap30-Apr-03 8:31 
GeneralRe: paint application question Pin
lfsong1-May-03 17:55
lfsong1-May-03 17:55 
GeneralRe: paint application question Pin
James T. Johnson1-May-03 18:06
James T. Johnson1-May-03 18:06 
GeneralRe: paint application question Pin
lfsong2-May-03 5:30
lfsong2-May-03 5:30 
GeneralRe: paint application question Pin
James T. Johnson2-May-03 14:57
James T. Johnson2-May-03 14:57 
LynnSong wrote:
this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);

This code set's up double buffering, which is similar to what you already in that you do all of your drawing to an off-screen buffer then the framework draws it on the screen for you.

There is an added advantage to letting the framework do this. First is that you get some speed increases because the framework ensures the underlying BitBlt will work as fast possible to the screen (Compatible bitmaps etc).

Now to the issue of the flicker. Flicker is caused by taking an image, clearing it, then drawing another image on top of it. The eye picks up each of those 3 'frames' and thus you see flicker. Usually this happens because OnPaintBackground erases the image with a single color, then OnPaint replaces that with the image. But from what you say you are doing all of your drawing in OnPaintBackground, so as long as you don't draw to the Graphics object representing the screen until you are ready to erase what is there you shouldn't be seeing flicker. Unless of course, you call base.OnPaintBackground which is going to cause flicker as it draws the solid background for you then you draw your background.

There is one consideration when dealing with a DoubleBuffer'd control. You only get the DoubleBuffer when you do your drawing during the Paint event, at any other time you will be drawing to the screen which negates the point of using the DoubleBuffer. This is why I mentioned calling Invalidate you needed something to be redrawn, Invalidate will cause OnPaint to be called, which uses the DoubleBuffer. As an optimization you can call Invalidate, and pass in just the area that needs to be updated.

Even if you just have a dumb implementation of OnPaint (ie it just redraws everything) you should see some improvement by calling Invalidate with the changed areas because the Graphics object shouldn't be drawing stuff outside of the ClipRectangle anyway, but you can make it better yet by having OnPaint only draw what needs refreshing (stuff within the ClipRectangle).

HTH,

James

"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation

GeneralRe: paint application question Pin
lfsong2-May-03 19:03
lfsong2-May-03 19:03 
GeneralRe: paint application question Pin
James T. Johnson2-May-03 23:00
James T. Johnson2-May-03 23:00 
GeneralRe: paint application question Pin
lfsong4-May-03 18:46
lfsong4-May-03 18:46 
GeneralRe: paint application question Pin
J. Dunlap4-May-03 18:57
J. Dunlap4-May-03 18:57 
GeneralRe: paint application question Pin
lfsong4-May-03 22:52
lfsong4-May-03 22:52 
GeneralRe: paint application question Pin
James T. Johnson4-May-03 19:05
James T. Johnson4-May-03 19:05 
GeneralRe: paint application question Pin
J. Dunlap4-May-03 19:36
J. Dunlap4-May-03 19:36 
GeneralRe: paint application question Pin
James T. Johnson4-May-03 20:24
James T. Johnson4-May-03 20:24 
GeneralRe: paint application question Pin
J. Dunlap4-May-03 20:29
J. Dunlap4-May-03 20:29 
GeneralRe: paint application question Pin
lfsong4-May-03 23:36
lfsong4-May-03 23:36 
GeneralRe: paint application question Pin
James T. Johnson5-May-03 1:01
James T. Johnson5-May-03 1:01 
QuestionAm I running as a native image? Pin
solidstore29-Apr-03 1:20
solidstore29-Apr-03 1:20 
AnswerRe: Am I running as a native image? Pin
Stephane Rodriguez.29-Apr-03 2:18
Stephane Rodriguez.29-Apr-03 2:18 
GeneralLow level network application Pin
Andrei Matei28-Apr-03 22:29
Andrei Matei28-Apr-03 22:29 
GeneralRe: Low level network application Pin
Andy Davey29-Apr-03 16:16
Andy Davey29-Apr-03 16:16 
Generalcall to the main thread Pin
OmegaSupreme28-Apr-03 15:59
OmegaSupreme28-Apr-03 15:59 
GeneralRe: call to the main thread Pin
Andy Davey28-Apr-03 16:24
Andy Davey28-Apr-03 16:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.