Wednesday, July 4, 2007

Don't use CreateGraphics.

Unless you have a really good reason to, always draw all your UserControls inside OnPaint.

I really hate it when controls flicker. Flickering cannot be solved by getting a newer processer. It is not a problem with the speed of a video card. In computer graphics, it is often faster and easier to simply erase part of a window and redraw it rather than figuring out which individual pixel needs to be updated. Flickering is caused when a background colour is painted before the foreground graphics is painted. The problem is that on windows, each time you paint a pixel you're painting directly to video memory. The rendering of the background color (usually white) is visible for a split second before the foreground pixels are painted over the background.

One big mistake that people make when they write Windows Forms user-controls with DoubleBuffering enabled is that they try to draw onto a control outside of the OnPaint method. This is usually accomplished by creating a graphics context using Control.CreateGraphics in some other event handler and then drawing on the resulting context. This will bypass the inbuilt double buffering support in Windows Forms as you will be drawing directly to video memory rather than to an offscreen buffer.

If a control needs to be updated in response to some event/action, the state of the control should be changed by changing the appropriate variables and then a combination of the Control.Invalid, Control.Update, and Control.Refresh methods should be used to inform the control to redraw itself.

One side-effect of people using CreateGraphics (apart from control flickering), is that they sometimes draw graphics on the control and forget to draw it inside the OnPaint method. This means that the control will not draw itself properly if the control needs to be updated because of external causes (for example, if a window that was once overlapping the control moves).

I've seen this kind of mistake in a simple clock control. In response to a timer event, the developer calls CreateGraphics and paints the new time. The OnPaint method is never overridden. This appears to work most of the time but if a window is dragged over and then off the control, the custom drawn graphics for the control will be missing until the next timer event fires. Composition in Vista with composition (Aero) turned on actually prevents this from actually being much of a problem but I still think it's a nasty way to program controls.

1 Comments:

At July 24, 2008 at 7:28 AM , Anonymous Anonymous said...

gangbang facial -
giants black meat white treat -
her thick black ass -
horny spanish flies -
huge gay pass -
huge movie pass -
in focus girls -
intense penetrations -
internal explosions -
in the vip -
i spy camel toe -
kelsey xxx -
knocked up nina -
latina girl girl -
lesbian teen hunter -
little naughty nymphos -
mandys diary -
mexxxi cunts -
mike in brazil -
mikes apartment -
milf hunter -
milf lessons -
milf next door -
money talks -
monsters of cock -
mr big dicks hot chicks -
mr cameltoe -
mr chews asian beaver -
my busty girlfriend -
naughty indian girls -
ox pass -
panties and fannies -
papi -
pimp my black teen -
please bang my wife -
pov squirt alert -
public invasion -
pump that ass -
real dp dolls -
real hooker videos -
reality kings -
reality pass plus -
real orgasms -
real teens kissing -
round and brown -
round mound of ass -
sammy4u -
sapphic erotica -
security cam chronicles -
see her squirt -
she has a negro problem -
shemale ultra -
smut bus -
solo videos -
stracy stone -
street blowjobs -
street ranger -
swallow for cash -
sweet suckers -
team squirt -
teeny bopper club -
the big swallow -
the mother fucker -
tina blaze -
tinys black adventures -
tongues and toys -
tranny surprise -
tug jobs -
vanessa teen -
vip crew -
we live together -
whore gaggers -
xxx proposal -
mega cock cravers -
2 in the stink -
8th street latinas -
40 inch plus -
abbraxa porn -
adult friend finder -
all reality pass -
all sites access -
all star porn girls -
angels of porn video -
asian creamy pies -
ass parade -
athens girls -
bait bus -
ball honeys -
bangbros network -
bang bus -
barefoot maniacs -
big ass adventure -
big cock teen addiction -
big league facials -
big mouthfuls -
big naturals -
big tit patrol -
big tits round asses -
bikini contest porn -
black creamy pies -
black dicks latin chicks -
black gang white bang -
black mother fuckers -
blind date bangers -
boy girl bang -
boys first time -
brandi belle -
brazil bang -
brick house butts -
bubble butt orgy -
bukkake pee -
busty adventures -
butt cam -
cam crush -
cams -
captain stabbin -
casting couch teens -
coeds need cash -
college teens book bang -
cumfiesta -
cum girls -
dangerous dongs -
euro sex parties -
extreme asses -
extreme naturals -
fat ass pass -
first time auditions -
fisting lessons -
fling -
flower tucci -
french fisting -
french pee -
gag fuck -
ghetto hoochies -
giants black meat white treat -
heels and hoes -
horny spanish flies -
hung like a whore -
im live -
in focus girls -
inter mixed -
in the vip -
i spy camel toe -
its just chocolate -
jake bustsnuts -
knob squad -
kung pao pussy -
lesbian teen hunter -
little coco -
max hardcore porn -
mike in brazil -
milf hunter -
milf lessons -
milf next door -
miss pain -
money talks -
monsters of cock -
mr big dicks hot chicks -
mr cameltoe -
mr chews asian beaver -
my first porn scene -
orgy ental -
ox pass -
panties and fannies -
papi -
pee lover -
penis palooza -
phat booty brazil -
phat booty hoes -
phat white booty -
pimp my black teen -
please bang my wife -
porn multi pass -
public invasion -
pussy foot girls -
pussy pinata -
real arizona amateurs -
reality pass plus -
real orgasms -
red ass teens -
round and brown -
round mound of ass -
sado slaves -
sammy4u -
sapphic erotica -
see her squirt -
she fucks guys -
street blowjobs -
street ranger -
summer time milf -
sweet auditions -
sweet loads -
taylor bow -
team squirt -
teenie video -
teeny bopper club -
the big swallow -
the dirty old man -
thugs and juggs -
tight buttholes -
tinys black adventures -
tranny surprise -
tug jobs -
vip crew -
we live together -
white slave whores -
whore wagon -
xxx proposal -
mike in brazil -
2 in the stink -
8th street latinas -
40 inch plus -
abbraxa porn -
adult friend finder -
all reality pass -
all sites access -
all star porn girls -
angels of porn video -
asian creamy pies -
ass parade -
athens girls -
bait bus -
ball honeys -
bangbros network -
bang bus -
barefoot maniacs -
big ass adventure -
big cock teen addiction -
big league facials -
big mouthfuls -
big naturals -
big tit patrol -
big tits round asses -
bikini contest porn -
black creamy pies -
black dicks latin chicks -
black gang white bang -
black mother fuckers -
blind date bangers -
boy girl bang -
boys first time -
brandi belle -
brazil bang -
brick house butts -
bubble butt orgy -
bukkake pee -
busty adventures -
butt cam -
cam crush -
cams -
captain stabbin -
casting couch teens -
coeds need cash -
college teens book bang -
cumfiesta -
cum girls -
dangerous dongs -
euro sex parties -
extreme asses -
extreme naturals -
fat ass pass -
first time auditions -
fisting lessons -
fling -
flower tucci -
french fisting -
french pee -
gag fuck -
ghetto hoochies -
giants black meat white treat -
heels and hoes -
horny spanish flies -
hung like a whore -
im live -
in focus girls -
inter mixed -
in the vip -
i spy camel toe -
its just chocolate -
jake bustsnuts -
knob squad -
kung pao pussy -
lesbian teen hunter -
little coco -
max hardcore porn -
mike in brazil -
milf hunter -
milf lessons -
milf next door -
miss pain -
money talks -
monsters of cock -
mr big dicks hot chicks -
mr cameltoe -
mr chews asian beaver -
my first porn scene -
orgy ental -
ox pass -
panties and fannies -
papi -
pee lover -
penis palooza -
phat booty brazil -
phat booty hoes -
phat white booty -
pimp my black teen -
please bang my wife -
porn multi pass -
public invasion -
pussy foot girls -
pussy pinata -
real arizona amateurs -
reality pass plus -
real orgasms -
red ass teens -
round and brown -
round mound of ass -
sado slaves -
sammy4u -
sapphic erotica -
see her squirt -
she fucks guys -
street blowjobs -
street ranger -
summer time milf -
sweet auditions -
sweet loads -
taylor bow -
team squirt -
teenie video -
teeny bopper club -
the big swallow -
the dirty old man -
thugs and juggs -
tight buttholes -
tinys black adventures -
tranny surprise -
tug jobs -
vip crew -
we live together -
white slave whores -
whore wagon -
xxx proposal -
mikes apartment -
2 in the stink -
8th street latinas -
40 inch plus -
abbraxa porn -
adult friend finder -
all reality pass -
all sites access -
all star porn girls -
angels of porn video -
asian creamy pies -
ass parade -
athens girls -
bait bus -
ball honeys -
bangbros network -
bang bus -
barefoot maniacs -
big ass adventure -
big cock teen addiction -
big league facials -
big mouthfuls -
big naturals -
big tit patrol -
big tits round asses -
bikini contest porn -
black creamy pies -
black dicks latin chicks -
black gang white bang -
black mother fuckers -
blind date bangers -
boy girl bang -
boys first time -
brandi belle -
brazil bang -
brick house butts -
bubble butt orgy -
bukkake pee -
busty adventures -
butt cam -
cam crush -
cams -
captain stabbin -
casting couch teens -
coeds need cash -
college teens book bang -
cumfiesta -
cum girls -
dangerous dongs -
euro sex parties -
extreme asses -
extreme naturals -
fat ass pass -
first time auditions -
fisting lessons -
fling -
flower tucci -
french fisting -
french pee -
gag fuck -
ghetto hoochies -
giants black meat white treat -
heels and hoes -
horny spanish flies -
hung like a whore -
im live -
in focus girls -
inter mixed -
in the vip -
i spy camel toe -
its just chocolate -
jake bustsnuts -
knob squad -
kung pao pussy -
lesbian teen hunter -
little coco -
max hardcore porn -
mike in brazil -
milf hunter -
milf lessons -
milf next door -
miss pain -
money talks -
monsters of cock -
mr big dicks hot chicks -
mr cameltoe -
mr chews asian beaver -
my first porn scene -
orgy ental -
ox pass -
panties and fannies -
papi -
pee lover -
penis palooza -
phat booty brazil -
phat booty hoes -
phat white booty -
pimp my black teen -
please bang my wife -
porn multi pass -
public invasion -
pussy foot girls -
pussy pinata -
real arizona amateurs -
reality pass plus -
real orgasms -
red ass teens -
round and brown -
round mound of ass -
sado slaves -
sammy4u -
sapphic erotica -
see her squirt -
she fucks guys -
street blowjobs -
street ranger -
summer time milf -
sweet auditions -
sweet loads -
taylor bow -
team squirt -
teenie video -
teeny bopper club -
the big swallow -
the dirty old man -
thugs and juggs -
tight buttholes -
tinys black adventures -
tranny surprise -
tug jobs -
vip crew -
we live together -
white slave whores -
whore wagon -
xxx proposal -
milf hunter -
2 in the stink -
8th street latinas -
40 inch plus -
abbraxa porn -
adult friend finder -
all reality pass -
all sites access -
all star porn girls -
angels of porn video -
asian creamy pies -
ass parade -
athens girls -
bait bus -
ball honeys -
bangbros network -
bang bus -
barefoot maniacs -
big ass adventure -
big cock teen addiction -
big league facials -
big mouthfuls -
big naturals -
big tit patrol -
big tits round asses -
bikini contest porn -
black creamy pies -
black dicks latin chicks -
black gang white bang -
black mother fuckers -
blind date bangers -
boy girl bang -
boys first time -
brandi belle -
brazil bang -
brick house butts -
bubble butt orgy -
bukkake pee -
busty adventures -
butt cam -
cam crush -
cams -
captain stabbin -
casting couch teens -
coeds need cash -
college teens book bang -
cumfiesta -
cum girls -
dangerous dongs -
euro sex parties -
extreme asses -
extreme naturals -
fat ass pass -
first time auditions -
fisting lessons -
fling -
flower tucci -
french fisting -
french pee -
gag fuck -
ghetto hoochies -
giants black meat white treat -
heels and hoes -
horny spanish flies -
hung like a whore -
im live -
in focus girls -
inter mixed -
in the vip -
i spy camel toe -
its just chocolate -
jake bustsnuts -
knob squad -
kung pao pussy -
lesbian teen hunter -
little coco -
max hardcore porn -
mike in brazil -
milf hunter -
milf lessons -
milf next door -
miss pain -
money talks -
monsters of cock -
mr big dicks hot chicks -
mr cameltoe -
mr chews asian beaver -
my first porn scene -
orgy ental -
ox pass -
panties and fannies -
papi -
pee lover -
penis palooza -
phat booty brazil -
phat booty hoes -
phat white booty -
pimp my black teen -
please bang my wife -
porn multi pass -
public invasion -
pussy foot girls -
pussy pinata -
real arizona amateurs -
reality pass plus -
real orgasms -
red ass teens -
round and brown -
round mound of ass -
sado slaves -
sammy4u -
sapphic erotica -
see her squirt -
she fucks guys -
street blowjobs -
street ranger -
summer time milf -
sweet auditions -
sweet loads -
taylor bow -
team squirt -
teenie video -
teeny bopper club -
the big swallow -
the dirty old man -
thugs and juggs -
tight buttholes -
tinys black adventures -
tranny surprise -
tug jobs -
vip crew -
we live together -
white slave whores -
whore wagon -
xxx proposal -
milf lessons -
2 in the stink -
8th street latinas -
40 inch plus -
abbraxa porn -
adult friend finder -
all reality pass -
all sites access -
all star porn girls -
angels of porn video -
asian creamy pies -
ass parade -
athens girls -
bait bus -
ball honeys -
bangbros network -
bang bus -
barefoot maniacs -
big ass adventure -
big cock teen addiction -
big league facials -
big mouthfuls -
big naturals -
big tit patrol -
big tits round asses -
bikini contest porn -
black creamy pies -
black dicks latin chicks -
black gang white bang -
black mother fuckers -
blind date bangers -
boy girl bang -
boys first time -
brandi belle -
brazil bang -
brick house butts -
bubble butt orgy -
bukkake pee -
busty adventures -
butt cam -
cam crush -
cams -
captain stabbin -
casting couch teens -
coeds need cash -
college teens book bang -
cumfiesta -
cum girls -
dangerous dongs -
euro sex parties -
extreme asses -
extreme naturals -
fat ass pass -
first time auditions -
fisting lessons -
fling -
flower tucci -
french fisting -
french pee -
gag fuck -
ghetto hoochies -
giants black meat white treat -
heels and hoes -
horny spanish flies -
hung like a whore -
im live -
in focus girls -
inter mixed -
in the vip -
i spy camel toe -
its just chocolate -
jake bustsnuts -
knob squad -
kung pao pussy -
lesbian teen hunter -
little coco -
max hardcore porn -
mike in brazil -
milf hunter -
milf lessons -
milf next door -
miss pain -
money talks -
monsters of cock -
mr big dicks hot chicks -
mr cameltoe -
mr chews asian beaver -
my first porn scene -
orgy ental -
ox pass -
panties and fannies -
papi -
pee lover -
penis palooza -
phat booty brazil -
phat booty hoes -
phat white booty -
pimp my black teen -
please bang my wife -
porn multi pass -
public invasion -
pussy foot girls -
pussy pinata -
real arizona amateurs -
reality pass plus -
real orgasms -
red ass teens -
round and brown -

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home