【问题标题】:How to get an aero effect delphi for FMX如何获得 FMX 的空气动力学效果 delphi
【发布时间】:2014-10-04 15:36:56
【问题描述】:

如何在 OSX/Windows 中使用 FMX 为 delphi xe6 获得类似的“航空效果”? 我看到了这个教程,但它是针对 VLC 的吗http://theroadtodelphi.wordpress.com/2009/10/26/glass-effect-in-a-delphi-console-application/

我正在寻找一种类似于 aero 的效果。更具体地说,效果使背景模糊。类似于您在 iOS 中看到的模糊覆盖。

所以我的表单需要是透明的,然后在表单用于背景的地方模糊该图像。

感谢@RRUZ,这是我目前所拥有的。编译,但还不能正常工作:

unit test;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, 
  FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls
  {$IFDEF MACOS32}
  ,FMX.Platform.Mac,
  Macapi.CoreFoundation,
  Macapi.CoreGraphics,
  Macapi.AppKit,
  Macapi.CocoaTypes
  {$ENDIF}
  ;

{$IFDEF MACOS32}
type
 CGSConnection = Pointer;

function CGSSetWindowBackgroundBlurRadius(connection: CGSConnection; windowNumber : NSInteger; radius : integer): CGError; cdecl; external libCoreGraphics name _PU + 'CGSSetWindowBackgroundBlurRadius';
function CGSDefaultConnectionForThread : CGSConnection ; cdecl; external libCoreGraphics name _PU + 'CGSDefaultConnectionForThread';
{$ENDIF}


type
  TForm1 = class(TForm)
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
    procedure enableBlurForWindow(Handle : TWindowHandle);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

{ TForm1 }

procedure TForm1.enableBlurForWindow(Handle: TWindowHandle);
var
  connection : CGSConnection;
  LNSWindow : NSWindow;
begin
  LNSWindow:= WindowHandleToPlatform(Handle).Wnd;
  LNSWindow.setOpaque(False);
  LNSWindow.setBackgroundColor(TNSColor.Wrap(TNSColor.OCClass.colorWithCalibratedWhite(1.0, 0.5)));
  connection := CGSDefaultConnectionForThread();
  CGSSetWindowBackgroundBlurRadius(connection, LNSWindow.windowNumber, 20);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  enableBlurForWindow(Form1.Handle);
end;

end.

【问题讨论】:

  • 该代码用于控制台应用程序,它与这两个框架都没有关联。当然,玻璃是特定于 Windows(Vista 和 7)的。你怎么能指望在 OSX 上有玻璃?
  • 本文描述了在控制台应用程序中使用DWM 函数(顺便说一句,仅在 Windows 中可用)。你能详细说明你的问题吗?也许你想应用透明效果?
  • 已编辑..问题现在更清楚了吗?
  • 您希望在哪个操作系统中产生这种效果?
  • 对于 Windows,您可以使用 DWM 功能,对于 OSX,试试这个cocoasnippets.io/cocoa/ui/nswindow/coregraphics/2014/02/27/…

标签: delphi delphi-xe6


【解决方案1】:

在 FMX 应用中获取这个效果比在 VCL 中简单得多,FMX 带来了特定的组件来将效果应用到其他组件或表单(包括模糊效果)。

只需将组件放在表单上并激活它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-18
    • 1970-01-01
    • 1970-01-01
    • 2016-04-21
    相关资源
    最近更新 更多