HighTechTalks DotNet Forums  

custom Usercontrol flicker on resize

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss custom Usercontrol flicker on resize in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
MariusI
 
Posts: n/a

Default custom Usercontrol flicker on resize - 09-08-2005 , 06:54 AM






Hi, i've created a user control which can be resized at runtime. When the
control is resized, it flickers. I use the following controlstyles:

this.SetStyle(ControlStyles.UserPaint |
ControlStyles.Opaque | ControlStyles.AllPaintingInWmPaint,
true);

I've also tried double buffering, but this seems to have the weird effect of
disabling the OnPaint method (never triggers, but the child controls are
still painted). A similiar post suggested using the WS_CLIPCHILDREN, but i do
not know how to change the window style after the window has been created.
Any suggestion on how to fix this anoying flickering is highly appreachiated.

Reply With Quote
  #2  
Old   
Sergey Bogdanov
 
Posts: n/a

Default Re: custom Usercontrol flicker on resize - 09-08-2005 , 07:01 AM






Try to override the OnPaintBackground method in this manner:

protected override void OnPaintBackground(PaintEventArgs pevent)
{
// this line stays commented
//base.OnPaintBackground (pevent);
}


--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


MariusI wrote:
Quote:
Hi, i've created a user control which can be resized at runtime. When the
control is resized, it flickers. I use the following controlstyles:

this.SetStyle(ControlStyles.UserPaint |
ControlStyles.Opaque | ControlStyles.AllPaintingInWmPaint,
true);

I've also tried double buffering, but this seems to have the weird effect of
disabling the OnPaint method (never triggers, but the child controls are
still painted). A similiar post suggested using the WS_CLIPCHILDREN, but i do
not know how to change the window style after the window has been created.
Any suggestion on how to fix this anoying flickering is highly appreachiated.

Reply With Quote
  #3  
Old   
MariusI
 
Posts: n/a

Default Re: custom Usercontrol flicker on resize - 09-08-2005 , 07:10 AM



the ControlStyles.Opaque ensures that the OnPaintBackGround is never called,
so that won't help

"Sergey Bogdanov" wrote:

Quote:
Try to override the OnPaintBackground method in this manner:

protected override void OnPaintBackground(PaintEventArgs pevent)
{
// this line stays commented
//base.OnPaintBackground (pevent);
}


--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


MariusI wrote:
Hi, i've created a user control which can be resized at runtime. When the
control is resized, it flickers. I use the following controlstyles:

this.SetStyle(ControlStyles.UserPaint |
ControlStyles.Opaque | ControlStyles.AllPaintingInWmPaint,
true);

I've also tried double buffering, but this seems to have the weird effect of
disabling the OnPaint method (never triggers, but the child controls are
still painted). A similiar post suggested using the WS_CLIPCHILDREN, but i do
not know how to change the window style after the window has been created.
Any suggestion on how to fix this anoying flickering is highly appreachiated.


Reply With Quote
  #4  
Old   
Martin Boltendal
 
Posts: n/a

Default Re: custom Usercontrol flicker on resize - 09-08-2005 , 07:25 AM



Also add the ControlStyles.DoubleBuffer or
ControlStyles.OptimizedDoubleBuffer (depending on the framework version you
use).

So the line will read:

this.SetStyle(ControlStyles.UserPaint |
ControlStyles.Opaque |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer, true);

This will reduce the flickering almost to probably zero otherwise you might
have a problem in your code that is
unneccisserily calling the OnPaint event/method multiple times for no
reason.

Hope it helps,

Poolbeer


"MariusI" <MariusI (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi, i've created a user control which can be resized at runtime. When the
control is resized, it flickers. I use the following controlstyles:

this.SetStyle(ControlStyles.UserPaint |
ControlStyles.Opaque | ControlStyles.AllPaintingInWmPaint,
true);

I've also tried double buffering, but this seems to have the weird effect
of
disabling the OnPaint method (never triggers, but the child controls are
still painted). A similiar post suggested using the WS_CLIPCHILDREN, but i
do
not know how to change the window style after the window has been created.
Any suggestion on how to fix this anoying flickering is highly
appreachiated.



Reply With Quote
  #5  
Old   
MariusI
 
Posts: n/a

Default Re: custom Usercontrol flicker on resize - 09-08-2005 , 07:49 AM



I've also tried using the OptimizedDoubleBuffer controlstyle, but that does
not help. The painting of the contained controls are not triggered by the
onpaint method. The OptimizedDoubleBuffer controlstyle means that the onpaint
method recieves a bitmap graphics object through its paint event args instead
of a graphics object which refers to the actual window. This does not seem to
apply to the contained controls which paint directly to the window, creating
a flicker. I think i have to look into the WM_ERASEBKG event.

"Martin Boltendal" wrote:

Quote:
Also add the ControlStyles.DoubleBuffer or
ControlStyles.OptimizedDoubleBuffer (depending on the framework version you
use).

So the line will read:

this.SetStyle(ControlStyles.UserPaint |
ControlStyles.Opaque |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer, true);

This will reduce the flickering almost to probably zero otherwise you might
have a problem in your code that is
unneccisserily calling the OnPaint event/method multiple times for no
reason.

Hope it helps,

Poolbeer


"MariusI" <MariusI (AT) discussions (DOT) microsoft.com> wrote in message
news:2315558A-D71D-4F86-AFE3-8918E6E3736F (AT) microsoft (DOT) com...
Hi, i've created a user control which can be resized at runtime. When the
control is resized, it flickers. I use the following controlstyles:

this.SetStyle(ControlStyles.UserPaint |
ControlStyles.Opaque | ControlStyles.AllPaintingInWmPaint,
true);

I've also tried double buffering, but this seems to have the weird effect
of
disabling the OnPaint method (never triggers, but the child controls are
still painted). A similiar post suggested using the WS_CLIPCHILDREN, but i
do
not know how to change the window style after the window has been created.
Any suggestion on how to fix this anoying flickering is highly
appreachiated.




Reply With Quote
  #6  
Old   
Sergey Bogdanov
 
Posts: n/a

Default Re: custom Usercontrol flicker on resize - 09-08-2005 , 07:59 AM



Sorry, didn't noticed it. About your other question; how to remove
WS_CLIPCHILDREN, here you are the code snippet:

protected override CreateParams CreateParams
{
get
{
CreateParams createParams = base.CreateParams;
createParams.Style &= ~WS_CLIPCHILDREN;
return createParams;
}
}

const int WS_CLIPCHILDREN = 0x02000000;

but not sure that that can help you.


--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


MariusI wrote:
Quote:
the ControlStyles.Opaque ensures that the OnPaintBackGround is never called,
so that won't help

"Sergey Bogdanov" wrote:


Try to override the OnPaintBackground method in this manner:

protected override void OnPaintBackground(PaintEventArgs pevent)
{
// this line stays commented
//base.OnPaintBackground (pevent);
}


--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com


MariusI wrote:

Hi, i've created a user control which can be resized at runtime. When the
control is resized, it flickers. I use the following controlstyles:

this.SetStyle(ControlStyles.UserPaint |
ControlStyles.Opaque | ControlStyles.AllPaintingInWmPaint,
true);

I've also tried double buffering, but this seems to have the weird effect of
disabling the OnPaint method (never triggers, but the child controls are
still painted). A similiar post suggested using the WS_CLIPCHILDREN, but i do
not know how to change the window style after the window has been created.
Any suggestion on how to fix this anoying flickering is highly appreachiated.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.