views:

193

answers:

2

How could one change the opacity of a TWinControl based control? And why didn't they add this capability to TControl/TWinControl level (why only TForm)?

+5  A: 

Thanks Lars.

I don't how you'd do it. As I understand it, Windows only added the translucency to windows, which is why TForm can handle it, but not individual controls. Remember that most of the VCL is simply a wrapper around the Windows Common Controls, and so if Windows doesn't do it, the related VCL control rarely will either. Third-party components often then extend the basic functionality.

_J_
Please edit this, even controls are windows (`HWND` type). The important point is that support isn there only for windows without the `WS_CHILD` style. A form with an overridden `CreateParams` method which sets the `WS_CHILD` style can't be translucent either.
mghie
mghie, thank you, I think your comment says it all.
_J_
+3  A: 

Controlling the opacity of a window is offered by a feature called layered windows. You can read more about the feature on MSDN. The feature is only available for top-level windows. As far as I can tell, Desktop Window Manager (Vista's "glass" effect) is also only available for top-level windows.

Alternatives available for child windows are to use window regions to mark certain areas of a window as completely transparent, or to use bitmap alpha blending to draw the whole control yourself.

Rob Kennedy
Thanks for the extra effort for linking.
utku_karatas