How to create a duble buffer transparent control

°

°Ë´óɽÈË

HI,

I create a custom transparent control, set the style is
ControlStyles.DoubleBuffer, It display black background. How
to create a double buffer transparent control?
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi,

To create a double buffered control the styles that you need to turned on
are

SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint, true);

All those styles are necesery for double buffering to work and it works for
transparent controls as well.

If you still have ptoblems I'd suggest to post some code(preffered) or
explain how you create that transparent conrol. The problem could be there.
 
°

°Ë´óɽÈË

Thank you! The code is:

public class TransControl : System.Windows.Forms.Control {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public TransControl() {
// This call is required by the Windows.Forms Form Designer.
base.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.StandardClick |
ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);

}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing ) {
if( disposing ) {
}
base.Dispose( disposing );
}

protected override void OnPaint(PaintEventArgs e) {
base.OnPaint (e);
}

protected override void OnPaintBackground(PaintEventArgs pevent) {
//do not allow the background to be painted
}
}

Stoitcho Goutsev (100) said:
Hi,

To create a double buffered control the styles that you need to turned on
are

SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint, true);

All those styles are necesery for double buffering to work and it works for
transparent controls as well.

If you still have ptoblems I'd suggest to post some code(preffered) or
explain how you create that transparent conrol. The problem could be there.

--

Stoitcho Goutsev (100) [C# MVP]


°Ë´óɽÈË said:
HI,

I create a custom transparent control, set the style is
ControlStyles.DoubleBuffer, It display black background. How
to create a double buffer transparent control?
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Hi °Ë´óɽÈË,

On my second thought you can't use double buffering with transparent
controls unless you don't do your own double buffering..


--

Stoitcho Goutsev (100) [C# MVP]


°Ë´óɽÈË said:
Thank you! The code is:

public class TransControl : System.Windows.Forms.Control {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public TransControl() {
// This call is required by the Windows.Forms Form Designer.
base.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.StandardClick |
ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);

}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing ) {
if( disposing ) {
}
base.Dispose( disposing );
}

protected override void OnPaint(PaintEventArgs e) {
base.OnPaint (e);
}

protected override void OnPaintBackground(PaintEventArgs pevent) {
//do not allow the background to be painted
}
}

Stoitcho Goutsev (100) said:
Hi,

To create a double buffered control the styles that you need to turned on
are

SetStyle(ControlStyles.DoubleBuffer |
ControlStyles.AllPaintingInWmPaint
|
ControlStyles.UserPaint, true);

All those styles are necesery for double buffering to work and it works for
transparent controls as well.

If you still have ptoblems I'd suggest to post some code(preffered) or
explain how you create that transparent conrol. The problem could be there.

--

Stoitcho Goutsev (100) [C# MVP]


°Ë´óɽÈË said:
HI,

I create a custom transparent control, set the style is
ControlStyles.DoubleBuffer, It display black background. How
to create a double buffer transparent control?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top