AlphaBlend在FireMonkey [英] AlphaBlend in FireMonkey

查看:503
本文介绍了AlphaBlend在FireMonkey的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在FireMonkey桌面应用程序中更改 AlphaBlend 值(表单)?那么它在VCL应用程序中可用,但是在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.

截图:

推荐答案

要使您的表单背景半透明,您应该将表单透明度属性设置为 true 并使用 Fill.Color 与αcode> $ AAFFFFFF (含 Fill.Kind = bkSolid )。
在这种情况下,窗体边框变得不可见(至少在Delphi XE2

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)

如果您需要使所有组件以半透明形式然后在 Align = alContents 的表单上放置 TLayout ,并设置其不透明度属性为必需值。

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.

如果您需要使用Alpha混合的半透明窗口,因为它在VCL中,您可以使用相同的方法(对于Windows平台)为 getWindowLong / SetWindowLong 。将透明度返回到 false ,并使用 OnCreate 事件处理程序:

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;

当然,所有的组件都变成trasparent。

of course all your components become trasparent too.

这篇关于AlphaBlend在FireMonkey的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆