Flickering.

rifter1818

Well-known member
Joined
Sep 11, 2003
Messages
255
Location
A cold dark place
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.
 
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.
 
PlausiblyDamp said:
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,
 
Back
Top