Click here to Skip to main content
15,921,113 members
Home / Discussions / C#
   

C#

 
AnswerRe: ComboBox SelectedIndexChanged Pin
Martin#8-Nov-06 1:48
Martin#8-Nov-06 1:48 
AnswerRe: ComboBox SelectedIndexChanged Pin
ednrgc8-Nov-06 2:51
ednrgc8-Nov-06 2:51 
GeneralRe: ComboBox SelectedIndexChanged Pin
freshonlineMax8-Nov-06 3:03
freshonlineMax8-Nov-06 3:03 
GeneralRe: ComboBox SelectedIndexChanged Pin
ednrgc8-Nov-06 3:05
ednrgc8-Nov-06 3:05 
QuestionHigh CPU load caused by this.Invalidate(myRegion); [modified] Pin
Mike Novy8-Nov-06 1:33
Mike Novy8-Nov-06 1:33 
AnswerRe: High CPU load caused by this.Invalidate(myRegion); Pin
vineas8-Nov-06 4:27
vineas8-Nov-06 4:27 
GeneralRe: High CPU load caused by this.Invalidate(myRegion); Pin
Mike Novy8-Nov-06 5:48
Mike Novy8-Nov-06 5:48 
GeneralRe: High CPU load caused by this.Invalidate(myRegion); Pin
vineas8-Nov-06 6:49
vineas8-Nov-06 6:49 
By invalidating regions, you are creating a clipping rectangle, and when Paint gets called, one of the properties of the PaintEventArgs is a "ClipRectangle". If possible, you should use this rectangle to only paint those items that got invalidated.

For instance, suppose you have two graphs on the screen, and your clipping region is around the 2nd graph (I apologize for the ASCII drawing here, I couldn't find a suitable image online quickly)
                      +--------------------------+
+---------------+     |    +---------------+     |
|               |     |    |               |     |
|               |     |    |               |     |
|  graph 1      |     |    |  graph 2      |     |
|               |     |    |               |     |
|               |     |    |               |     |
|               |     |    |               |     |
+---------------+     |    +---------------+     |
                      +--------------------------+


In your paint handler, you should be using this ClipRectangle value to draw only graph 2 - graph 1 has not been invalidated and does not need to be redrawn.

However, if your paint handler does not use the ClipRectangle value and draws everything, you are wasting CPU cycles, because not only does this not need to change, but the Graphics object passed into the handler is also setup with the clip rectangle value - and it won't even paint outside of that area (even if your drawing code does).

This is why only the areas you invalidated flicker when you turn off double buffering - the Graphics object has already been setup to clip the drawing, but you're still using CPU cycles attempting to draw outside this area.

-----
In the land of the blind, the one eyed man is king.

GeneralRe: High CPU load caused by this.Invalidate(myRegion); [modified] Pin
Mike Novy8-Nov-06 7:44
Mike Novy8-Nov-06 7:44 
GeneralRe: High CPU load caused by this.Invalidate(myRegion); Pin
vineas8-Nov-06 8:06
vineas8-Nov-06 8:06 
GeneralRe: High CPU load caused by this.Invalidate(myRegion); Pin
Mike Novy8-Nov-06 8:46
Mike Novy8-Nov-06 8:46 
GeneralRe: High CPU load caused by this.Invalidate(myRegion); Pin
vineas8-Nov-06 9:20
vineas8-Nov-06 9:20 
GeneralRe: High CPU load caused by this.Invalidate(myRegion); Pin
Mike Novy8-Nov-06 9:52
Mike Novy8-Nov-06 9:52 
GeneralRe: High CPU load caused by this.Invalidate(myRegion); Pin
vineas8-Nov-06 10:46
vineas8-Nov-06 10:46 
Questionhow to get a date format mm.dd.yyyy( e.g. 12.31.2006) Pin
yogita charhate8-Nov-06 0:36
yogita charhate8-Nov-06 0:36 
AnswerRe: how to get a date format mm.dd.yyyy( e.g. 12.31.2006) Pin
Colin Angus Mackay8-Nov-06 0:44
Colin Angus Mackay8-Nov-06 0:44 
GeneralRe: how to get a date format mm.dd.yyyy( e.g. 12.31.2006) Pin
yogita charhate8-Nov-06 1:27
yogita charhate8-Nov-06 1:27 
QuestionHow Create Nonrectangular form in c#.net 2005 Pin
mohammadSoft8-Nov-06 0:30
mohammadSoft8-Nov-06 0:30 
AnswerRe: How Create Nonrectangular form in c#.net 2005 Pin
c_onica8-Nov-06 2:14
c_onica8-Nov-06 2:14 
QuestionHow to access from objects from other class Pin
signimage8-Nov-06 0:26
signimage8-Nov-06 0:26 
AnswerRe: How to access from objects from other class Pin
Colin Angus Mackay8-Nov-06 0:42
Colin Angus Mackay8-Nov-06 0:42 
AnswerRe: How to access from objects from other class Pin
quiteSmart8-Nov-06 0:56
quiteSmart8-Nov-06 0:56 
AnswerRe: How to access from objects from other class Pin
Mairaaj Khan8-Nov-06 1:07
professionalMairaaj Khan8-Nov-06 1:07 
AnswerRe: How to access from objects from other class Pin
mohammadSoft8-Nov-06 1:38
mohammadSoft8-Nov-06 1:38 
Questionhow to use TableAdapter in VC# 2005 ? Pin
hdv2128-Nov-06 0:26
hdv2128-Nov-06 0:26 

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.