Click here to Skip to main content
16,005,241 members
Home / Discussions / C#
   

C#

 
GeneralRe: visual C# 2005 exiting Pin
engsrini19-Mar-08 12:21
engsrini19-Mar-08 12:21 
GeneralRe: visual C# 2005 exiting Pin
xxmikexx19-Mar-08 12:28
xxmikexx19-Mar-08 12:28 
GeneralRe: visual C# 2005 exiting Pin
xxmikexx19-Mar-08 11:51
xxmikexx19-Mar-08 11:51 
Question[Message Deleted] Pin
123shailesh19-Mar-08 7:18
123shailesh19-Mar-08 7:18 
GeneralRe: Trouble Retrieving Coordinates Pin
Christian Graus19-Mar-08 10:28
protectorChristian Graus19-Mar-08 10:28 
GeneralSSO Pin
IWannaTalk19-Mar-08 6:24
IWannaTalk19-Mar-08 6:24 
GeneralRe: SSO Pin
IWannaTalk20-Mar-08 7:40
IWannaTalk20-Mar-08 7:40 
GeneralControlStyles.OptimizedDoubleBuffer increases my flicker problems Pin
poppabaggins19-Mar-08 6:16
poppabaggins19-Mar-08 6:16 
I'm new to form programming in C#. Just for learning purposes, I tried double buffering to get rid of my flicker problems with a simple test program. The problem is, that enabling double buffering made increased my flicker exponentially. What should I do to solve this?

Here's the code for reference
public partial class DoubleBufferPractice : Form
    {
        Timer timer;
        Rectangle rect;

        public DoubleBufferPractice()
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.UserPaint, true);
            rect = new Rectangle(0, this.Height/3, 50, 50);
            InitializeTimer();
        }

        private void InitializeTimer()
        {
            timer = new Timer();
            timer.Interval = 10;
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();
        }

        private void timer_Tick(object sender, EventArgs e) 
        {
            if(rect.X + rect.Width < this.Width)
                rect.X += 10;
            else
                rect.X = 0;
            this.Invalidate();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            using(Graphics g = this.CreateGraphics()) {
                using(Brush brush = new SolidBrush(Color.Magenta)) {
                    g.FillRectangle(brush, rect);
                }
            }
            base.OnPaint(e);
        }
    }


Also, I'm testing this on my laptop with a 2.0ghz Dual Core Pentium, 2gigs ram, and a 256meg nonshared vram NVidia Geforce 8600 M GT, so I don't think that hardware is the problem.
GeneralRe: ControlStyles.OptimizedDoubleBuffer increases my flicker problems Pin
mmikey719-Mar-08 7:12
mmikey719-Mar-08 7:12 
GeneralRe: ControlStyles.OptimizedDoubleBuffer increases my flicker problems Pin
poppabaggins19-Mar-08 11:31
poppabaggins19-Mar-08 11:31 
QuestionHow to encode an existing txt file? Pin
pcaeiro19-Mar-08 6:15
pcaeiro19-Mar-08 6:15 
GeneralRe: How to encode an existing txt file? Pin
Paul Conrad21-Mar-08 10:06
professionalPaul Conrad21-Mar-08 10:06 
GeneralRe: How to encode an existing txt file? Pin
pcaeiro22-Mar-08 5:26
pcaeiro22-Mar-08 5:26 
GeneralRe: How to encode an existing txt file? Pin
Paul Conrad22-Mar-08 5:37
professionalPaul Conrad22-Mar-08 5:37 
Generalhandlers or 4 sided handles Pin
netJP12L19-Mar-08 6:10
netJP12L19-Mar-08 6:10 
QuestionRe: handlers or 4 sided handles Pin
Krazy Programmer19-Mar-08 7:39
Krazy Programmer19-Mar-08 7:39 
GeneralRe: handlers or 4 sided handles Pin
netJP12L19-Mar-08 8:37
netJP12L19-Mar-08 8:37 
GeneralDateTime.AddDays(1) Issue Pin
Harvey Saayman19-Mar-08 6:10
Harvey Saayman19-Mar-08 6:10 
GeneralRe: DateTime.AddDays(1) Issue Pin
J4amieC19-Mar-08 6:22
J4amieC19-Mar-08 6:22 
GeneralRe: DateTime.AddDays(1) Issue Pin
Harvey Saayman19-Mar-08 6:27
Harvey Saayman19-Mar-08 6:27 
GeneralRe: DateTime.AddDays(1) Issue Pin
phannon8619-Mar-08 6:48
professionalphannon8619-Mar-08 6:48 
GeneralRe: DateTime.AddDays(1) Issue Pin
Harvey Saayman19-Mar-08 6:56
Harvey Saayman19-Mar-08 6:56 
QuestionStatusStrip don't process mouse clicks if parent window is inactive. Pin
Patric_J19-Mar-08 5:24
Patric_J19-Mar-08 5:24 
GeneralVS 2005: 'Data' menu keeps disappearing! [modified] Pin
packmichael19-Mar-08 5:10
packmichael19-Mar-08 5:10 
GeneralRe: VS 2005: 'Data' menu keeps disappearing! Pin
Not Active19-Mar-08 5:27
mentorNot Active19-Mar-08 5:27 

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.