How do I toggle CreateParams of a user control?
-
Thursday, March 08, 2012 5:25 PM
Hi,
I'm trying to use something similar to the code found here.
http://www.angryhacker.com/blog/archive/2010/07/21/how-to-get-rid-of-flicker-on-windows-forms-applications.aspx
But i do not have a maximize box to trigger the call to reget the CreateParams. I am using a custom user control that is nested within several user controls that are contained within a custom form class that inherits Windows.System.Forms.
I get a massive amount of lag because i have a user interface for a training simulator that needs buttons on the screen for 1 step but then remove them for the next step. It takes time to redraw the 20 or so buttons and sliders, and it's ugly. Basically we can't have that. If i alter the create params the drawing is not as ugly and it's mostly acceptable, but the whole form slows to an unusable crawl. So i need to toggle the create params just for when the buttons get redrawn.
How can i force this on a user control?
All Replies
-
Monday, March 12, 2012 9:55 AM
Hi,
Can you use these codes in your UserControl class?
class MyControl : UserControl
{
protected override CreateParams CreateParams
{
get
{
// Activate double buffering at the form level. All child controls will be double buffered as well.
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // WS_EX_COMPOSITED
return cp;
}
}
}Or could you please provide me with more detailed information about how your Winform app is like?
Thanks
Michael Sun [MSFT]
MSDN Community Support | Feedback to us
-
Tuesday, March 13, 2012 5:38 PM
Thanks for the reply and your time,
I don't have any trouble applying that code to my controls. The problem is that the framerate of the form becomes unusable when i do. So I am trying to toggle the create parameters for when i need double buffered drawing. My control sits inside a control inside a control inside a control inside the main form. The main form is also compiled in a separate project and my control does not know about it. I can't reference it due to circular references. So we can get access to the instance of the main form with a singleton and reflection. That seems to be the route we are taking now. Get access to the main form and alter the maximize box property to switch back and forth between drawing modes.
My question mainly was, is there another method to trigger the fetching of the create parameters? Right now the only thing i can find on the web is set maximizebox = true, and .Net will re-get the create parameters. This is a hack and only works on forms.
-
Wednesday, March 14, 2012 9:31 AM
Hi,
If it's convenient for you, could you please send me a demo project for further investigation about your design? My mail is misun@microsoft.com.
Good day!
Thanks
Michael Sun [MSFT]
MSDN Community Support | Feedback to us


