Per pixel alpha blend on control (not on a form)

  • Thread starter Thread starter Dnf
  • Start date Start date
D

Dnf

I want to make my control (and it child controls) to be alpha blended (just
like the form can do with Opacity property) but I don't know how to do it.
I attempted to use WS_EX_LAYERED style and SetLayeredWindowAttributes but
when I set this style on the control in CreateParms I got a message error
(Error creating window handle.)
I was also playing with WS_EX_TRANSPARENT style and
ControlStyles.SupportsTransparentBackColor but those methods don¢t make
child controls transparent.
 
Hi Dnf,

Only toplevel window can be layered. Speaking of windows form those are
Forms.

For control what you need to do is to set control's
SupportsTransparentBackColor and UserPaint style.

in the controls constructor add the following line

this.SetStyle(ControlStyles.SupportsTransparentBackColor |
ControlStyles.UserPaint , true);

The you can set alpha blended colors for control's background color.
 
Back
Top