Click here to Skip to main content
15,867,594 members
Articles / Programming Languages / C#
Tip/Trick

Flicker free Form Painting

Rate me:
Please Sign up or sign in to vote.
4.33/5 (3 votes)
23 Sep 2010CPOL 21.5K   3   7
Recently i had found a solution for flicker free form loading in my project. Please use the following in designer class file.

CSS
protected override CreateParams CreateParams {
      get {
        CreateParams cp = base.CreateParams;
        cp.ExStyle |= 0x02000000;
        return cp;
      }
    }


To see it at work, minimize and restore the form and observe its painting behavior. Comment the cp.ExStyle assignment to see the difference. All you have to do to use this in your own form is to copy and paste the CreateParams property.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
A Software programmer. Works on ASP.NET, MVC, VB.NET, C#, .NET Compact framework, SSIS, SQL Server, PHP and its frameworks. Other than that likes to play games in PC.

Comments and Discussions

 
GeneralMy vote of 5 Pin
cyberhead5-Dec-19 4:04
cyberhead5-Dec-19 4:04 
GeneralReason for my vote of 5 this post work among all the solutio... Pin
JeanPaul MENSAH12-Feb-11 5:50
JeanPaul MENSAH12-Feb-11 5:50 
GeneralThanks a lot! i have been looking for this for 6 months ago!... Pin
JeanPaul MENSAH12-Feb-11 5:46
JeanPaul MENSAH12-Feb-11 5:46 
GeneralReason for my vote of 3 Ok, but a minimal explanation would ... Pin
Toli Cuturicu11-Oct-10 11:35
Toli Cuturicu11-Oct-10 11:35 
QuestionA Question Pin
johannesnestler24-Sep-10 2:27
johannesnestler24-Sep-10 2:27 
AnswerRe: A Question Pin
johannesnestler5-Oct-10 5:03
johannesnestler5-Oct-10 5:03 
GeneralGeneral Info [modified] Pin
Ron Beyer23-Sep-10 4:02
professionalRon Beyer23-Sep-10 4:02 
The flag is actually called WS_EX_COMPOSITED, and from the MSDN:

With WS_EX_COMPOSITED set, all descendants of a window get bottom-to-top painting order using double-buffering. Bottom-to-top painting order allows a descendent window to have translucency (alpha) and transparency (color-key) effects, but only if the descendent window also has the WS_EX_TRANSPARENT bit set. Double-buffering allows the window and its descendents to be painted without flicker.

BTW, this only works on Windows XP and higher.

modified on Thursday, September 23, 2010 10:25 AM

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.