code_junkie

Enabling Double Buffering

Nov 12th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. // Activates double buffering
  2. this.SetStyle(ControlStyles.DoubleBuffer |
  3. ControlStyles.OptimizedDoubleBuffer |
  4. ControlStyles.UserPaint |
  5. ControlStyles.AllPaintingInWmPaint, true);
  6. this.UpdateStyles();
  7.  
  8. SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, value);
  9.  
  10. form.SetStyle(ControlStyles.OptimizedDoubleBuffer, value);
  11.  
  12. public static void SetDoubleBuffered(System.Windows.Forms.Control c)
  13. {
  14. //Taxes: Remote Desktop Connection and painting
  15. //http://blogs.msdn.com/oldnewthing/archive/2006/01/03/508694.aspx
  16. if (System.Windows.Forms.SystemInformation.TerminalServerSession)
  17. return;
  18.  
  19. System.Reflection.PropertyInfo aProp = typeof(System.Windows.Forms.Control).GetProperty(
  20. "DoubleBuffered",
  21. System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
  22. aProp.SetValue(c, true, null);
  23. }
Add Comment
Please, Sign In to add comment