13

I need to create transparent component inheriting from TCustomControl.. so it is custom painted, yet is container for other components.

Can you tell me how to achieve this?

migajek
  • 8,524
  • 15
  • 77
  • 116
  • How is what you're asking for different from a TPanel without a border that has the color of its parent? A little more detail? Are you asking about "transparent on aero glass", or mere inheritance of parent color color, or parent control texture? – Warren P Jul 13 '11 at 16:53
  • by "transparent" I mean it doesn't cover the background. So it behaves like TLabel with transparency enabled, yet it is able to host other controls. – migajek Aug 12 '11 at 12:41

1 Answers1

26

Inherit from TCustomTransparentControl and include csAcceptsControls control style at creation.

Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169
  • 2
    +1 - I didn't know that class existed. When was it introduced? If it's been there as long as CB6 (~2001 or Delphi 7 timeframe) I'll be a sad panda. (I wrote a TWinControl descendant class to do this myself, and it was surprisingly tricky.) – David Jul 14 '11 at 04:30
  • 4
    @David - No need to be sad, it appears to have been introduced with [Delphi 2006](http://delphi.about.com/od/productreviews/ss/delphi2006first_7.htm). – Sertac Akyuz Jul 14 '11 at 09:12
  • Seemed too good to be true... Replaced my `TCustomControl` with `TCustomTransparentControl`, compiled, and somehow it does not respond to the mouse at all now... More work to do. – Jerry Dodge Jan 31 '15 at 16:35
  • @Jerry - Did you set 'interceptmouse'? – Sertac Akyuz Jan 31 '15 at 18:13
  • Yup, figured that out shortly after my comment. Now other issues :-( – Jerry Dodge Jan 31 '15 at 22:19