G
Guest
How to implement flicker-free double-buffering on a user control? I am am
adding a control to a autoscrolling panel on my form. When I scroll with the
panel, the usercontrol is not drawn smoothly. Are there any techniques that
can be applied to remedy this?
I have alreday tried the following:
protected override void OnPaint(PaintEventArgs e)
{
Graphics gxOff = null;
Bitmap m_bmpOffscreen = null;
if (m_bmpOffscreen == null)
m_bmpOffscreen = new Bitmap(ClientSize.Width,
ClientSize.Height);
//e.ClipRectangle.IntersectsWith
gxOff = Graphics.FromImage(m_bmpOffscreen);
gxOff.Clear(this.BackColor);
//Draw from the memory bitmap
e.Graphics.DrawImage(m_bmpOffscreen, e.ClipRectangle,
e.ClipRectangle, GraphicsUnit.Pixel);
//base.OnPaint(e);
gxOff.Dispose();
}
protected override void OnPaintBackground(PaintEventArgs e)
{
}
adding a control to a autoscrolling panel on my form. When I scroll with the
panel, the usercontrol is not drawn smoothly. Are there any techniques that
can be applied to remedy this?
I have alreday tried the following:
protected override void OnPaint(PaintEventArgs e)
{
Graphics gxOff = null;
Bitmap m_bmpOffscreen = null;
if (m_bmpOffscreen == null)
m_bmpOffscreen = new Bitmap(ClientSize.Width,
ClientSize.Height);
//e.ClipRectangle.IntersectsWith
gxOff = Graphics.FromImage(m_bmpOffscreen);
gxOff.Clear(this.BackColor);
//Draw from the memory bitmap
e.Graphics.DrawImage(m_bmpOffscreen, e.ClipRectangle,
e.ClipRectangle, GraphicsUnit.Pixel);
//base.OnPaint(e);
gxOff.Dispose();
}
protected override void OnPaintBackground(PaintEventArgs e)
{
}