Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • Administrators
Posted
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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
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,

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...