Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

delphi - AlphaBlend in FireMonkey

How can I change AlphaBlend value (of a form) in a FireMonkey Desktop Application? Well It's available in VCL Application but I couldn't find it in FireMonkey.

Screenshot:

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To make your form background semitransparent you should set form Transparency property to true and use Fill.Color with alpha value like $AAFFFFFF(with Fill.Kind = bkSolid). in this case form border becomes invisible (at least in Delphi XE2)

if you need to make all components at form semitransparent then place TLayout on form with Align = alContents and set its Opacity property to required value.

enter image description here

if you need semitransparent window with alpha blend as it was in VCL you can use the same methods (for Windows platform) as getWindowLong/SetWindowLong. Set transparency back to false and use code like this in form OnCreate event handler:

implementation
uses fmx.platform.win, winapi.windows;
{$R *.fmx}

procedure TMainForm.FormCreate(Sender: TObject);
var h : HWND;
    aStyle : integer;
    alphaValue : byte;
begin
    h := WindowHandleToPlatform(self.Handle).Wnd;
    AStyle := GetWindowLong(h, GWL_EXSTYLE);
    SetWindowLong(h, GWL_EXSTYLE, AStyle or WS_EX_LAYERED);


    AlphaValue := 125;
    SetLayeredWindowAttributes(h, 0, alphaValue, LWA_ALPHA);
end;

of course all your components become trasparent too.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...