【发布时间】: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