Transparent Form

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?
 
R

Rene

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?
 
K

Kevin Spencer

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?
 
G

Gary Brown

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
 

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