Transparent Form

  • Thread starter Thread starter Torleif Berger
  • Start date Start date
T

Torleif Berger

Is it possible to have a transparent Form? And by that I mean that the
background should be transparent.

I have tried to set the Opaque property, but that makes everything
transparent. I use OnPaint an OnBackgroundPaint to draw stuff on the form,
and when I set Opaque, what I draw is transparent as well. And I would
like it not to be.

I have also tried

SetStyle(ControlStyles.SupportsTransparentBackColor)
BackColor = Color.FromArgb(128, Color.Black);

But that only made the Black more gray... Probably because gray is the
default Form background or something..


Any ideas?
 
Have you played around with the TransparencyKey property? Maybe it will do
what you need?



Is it possible to have a transparent Form? And by that I mean that the
background should be transparent.

I have tried to set the Opaque property, but that makes everything
transparent. I use OnPaint an OnBackgroundPaint to draw stuff on the form,
and when I set Opaque, what I draw is transparent as well. And I would
like it not to be.

I have also tried

SetStyle(ControlStyles.SupportsTransparentBackColor)
BackColor = Color.FromArgb(128, Color.Black);

But that only made the Black more gray... Probably because gray is the
default Form background or something..


Any ideas?
 
TransparentColor = Color.Transparent;

The Alpha component is 255, not 128, for full transparency, as in
255,255,255,255 or 255,0,0,0 (both fully transparent).

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

Is it possible to have a transparent Form? And by that I mean that the
background should be transparent.

I have tried to set the Opaque property, but that makes everything
transparent. I use OnPaint an OnBackgroundPaint to draw stuff on the form,
and when I set Opaque, what I draw is transparent as well. And I would
like it not to be.

I have also tried

SetStyle(ControlStyles.SupportsTransparentBackColor)
BackColor = Color.FromArgb(128, Color.Black);

But that only made the Black more gray... Probably because gray is the
default Form background or something..


Any ideas?
 
laptop.local.net...
Is it possible to have a transparent Form? And by that I mean that the
background should be transparent.

this.TransparencyKey = this.BackColor;

in the constructor will set a form's background transparent while allowing
all else to be fully opaque.

Explicitly drawing on the form with semitransparent colors might not do
what you expect. It "merges" the drawn pixels with this.BackColor not
the pixels under the transparent parts of the form.

Another response got the transparency backwards - 0 is fully transparent,
255 opaque.

Gary
 
Back
Top