rifter1818 Posted June 7, 2004 Posted June 7, 2004 Before i fall down and have a major seisure (spelling) could some one please help me with the flickering. Im using C#. so far i have done the following settings (on form load) base.SetStyle(ControlStyles.AllPaintingInWmPaint,true); base.SetStyle(ControlStyles.DoubleBuffer,true); Im using a graphics object G = base.createGraphics(); and after the rendering (using the event onPaint)(currently just some collored rectangles and strings) is done i call Application.doEvents(); this.invalidate(); Anyways its flickering like there was no tommorrow. so any help to solve this would be greatly appreciated. Quote
Administrators PlausiblyDamp Posted June 7, 2004 Administrators Posted June 7, 2004 Could you post the actual code from the paint event. Also why are you creating a graphics object in the Form Load if you are doing your rendering in the paint event - you should really use the e.Graphics that is passed into the paint event procedure. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
rifter1818 Posted June 8, 2004 Author Posted June 8, 2004 Could you post the actual code from the paint event. Also why are you creating a graphics object in the Form Load if you are doing your rendering in the paint event - you should really use the e.Graphics that is passed into the paint event procedure. [CS] unsafe private void Form1_Load(object sender, System.EventArgs e) { this.SetStyle(ControlStyles.AllPaintingInWmPaint,true); this.SetStyle(ControlStyles.DoubleBuffer,true); //.............. } protected override void OnPaint(PaintEventArgs e) { //base.OnPaint (e); Graphics G = base.CreateGraphics(); Pen p; Brush B;B = new SolidBrush(Color.Black); byte x,y;int v; for(x=0;x<6;x++) { for(y=0;y<6;y++) { v = (150 * S[x,y].Units); v /= S[x,y].Neighbors.GetUpperBound(0) + 1; v += 105; if(S[x,y].Owner == 0) { p = new Pen(Color.Gray); } else if(S[x,y].Owner == 1) { p = new Pen(Color.FromArgb(v,0,0)); } else { p = new Pen(Color.FromArgb(0,0,v)); } p.Brush = new SolidBrush(p.Color); G.DrawRectangle(p,Rect[x,y]); G.FillRectangle(p.Brush,Rect[x,y]); G.DrawString(S[x,y].Units.ToString(),Form1.ActiveForm.Font,B,Rect[x,y],new StringFormat()); } } G.Dispose(); Application.DoEvents(); this.Invalidate(); } [/CS] Anyways the flickering is driving me nuts, Quote
rifter1818 Posted June 8, 2004 Author Posted June 8, 2004 Fixed Problem was that i wasnt using e.Graphics, thanks again PlausiblyDamp. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.