 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Hamid Guest
|
Posted: Fri Feb 24, 2006 12:03 am Post subject: Transparency Mask |
|
|
Hello all !
what is the best component to derive from, to be able to use transparency
masks... |
|
| Back to top |
|
 |
Michael Holdgaard Guest
|
Posted: Fri Feb 24, 2006 12:03 pm Post subject: Re: Transparency Mask |
|
|
Hi Hamid
I don't know if this is any help, but a year ago i tried to make a
transparent panel and the code for this was as follows. Hope it's of any use
/Michael
unit C4TransparentPanel;
interface
uses
SysUtils, Classes, Controls, ExtCtrls, Graphics, Messages;
type
TTransparentPanel = class(TCustomPanel)
protected
procedure Paint; override;
procedure WMEraseBackground(var Message: TWmEraseBkgnd); message
WM_ERASEBKGND;
public
constructor Create(AOwner: TComponent); override;
procedure CreateParams(var Params: TCreateParams); override;
published
property Color;
end;
procedure Register;
implementation
uses Windows;
procedure Register;
begin
RegisterComponents('MyControls', [TTransparentPanel]);
end;
{ TTransparentPanel }
constructor TTransparentPanel.Create(AOwner: TComponent);
begin
inherited;
ControlStyle := ControlStyle - [csOpaque];
BevelInner := bvNone;
BevelOuter := bvNone;
end;
procedure TTransparentPanel.CreateParams(var Params: TCreateParams);
begin
{ call the create of the params }
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle + WS_EX_Transparent;
ControlStyle := ControlStyle - [csOpaque] + [csAcceptsControls];
end;
procedure TTransparentPanel.Paint;
const
Alignments: array[TAlignment] of Longint = (DT_LEFT, DT_RIGHT, DT_CENTER);
var
TopColor, BottomColor: TColor;
procedure AdjustColors(Bevel: TPanelBevel);
begin
TopColor := clBtnHighlight;
if Bevel = bvLowered then TopColor := clBtnShadow;
BottomColor := clBtnShadow;
if Bevel = bvLowered then BottomColor := clBtnHighlight;
end;
begin
If (csDesigning in ComponentState) then
begin
Canvas.brush.color := clbtnshadow;
Canvas.framerect(clientrect);
end;
end;
procedure TTransparentPanel.WMEraseBackground(var Message: TWmEraseBkgnd);
begin
if (*(not Transparent) or*) (csDesigning in ComponentState) then begin
inherited;
end;
end;
end. |
|
| Back to top |
|
 |
Peter Below (TeamB) Guest
|
Posted: Fri Feb 24, 2006 8:03 pm Post subject: Re: Transparency Mask |
|
|
In article <43fe40ae (AT) newsgroups (DOT) borland.com>, Hamid wrote:
| Quote: | what is the best component to derive from, to be able to use transparency
masks...
|
TGraphicControl descendents can easily be made transparent since their host
TWincontrol will paint the area beneath them if the are not marked as
opaque. See the implementation of TCustomLabel for an example.
Transparency with TWincontrols on arbitrary containers is next to impossible
to achieve.
--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be |
|
| Back to top |
|
 |
Marko Binic Guest
|
Posted: Fri Feb 24, 2006 9:03 pm Post subject: Re: Transparency Mask |
|
|
Would it be possible to make a TCustomControl/TWinControl transparent using
the SetWindowRgn method, like with custom-shaped forms? (I ment transparency
in relative to it's siblings, not the parent)
Marko |
|
| Back to top |
|
 |
Peter Below (TeamB) Guest
|
Posted: Sat Feb 25, 2006 12:03 pm Post subject: Re: Transparency Mask |
|
|
In article <43ff6b13 (AT) newsgroups (DOT) borland.com>, Marko Binic wrote:
| Quote: | Would it be possible to make a TCustomControl/TWinControl transparent using
the SetWindowRgn method, like with custom-shaped forms? (I ment transparency
in relative to it's siblings, not the parent)
|
Yes, that works since the parts not enclosed by the window region don't obscure
the parent. But it is no option if you are after a translucency effect. To make
the parent paint the area under the control you would have to remove the
WS_CLIPCHILDREN style from it, and to deal with overlapping controls sharing
the same parent all of them would need to have the WS_CLIPSIBLING styles
removed. So all this is only possible if you have full control over the
container and all controls you may put on it.
--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be |
|
| Back to top |
|
 |
Marko Binic Guest
|
Posted: Sat Feb 25, 2006 2:03 pm Post subject: Re: Transparency Mask |
|
|
Thanks Peter, that's what I needed to hear (read) :)
Marko |
|
| Back to top |
|
 |
Hamid Guest
|
Posted: Mon Mar 06, 2006 5:03 pm Post subject: Re: Transparency Mask |
|
|
Thank you all for your answers
"Hamid" <me (AT) home (DOT) net> wrote in message
news:43fe40ae (AT) newsgroups (DOT) borland.com...
| Quote: | Hello all !
what is the best component to derive from, to be able to use transparency
masks...
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|