0

How can I get a similar 'aero effect' in OSX/Windows for delphi xe6 using FMX? I see this tutorial but is it is for VLC http://theroadtodelphi.wordpress.com/2009/10/26/glass-effect-in-a-delphi-console-application/

I am looking for an effect that is something similar to aero. More specifically, where the effect blurs the background. Similar to a blurred overlay you would see in iOS.

So my form would need to be transparent, and then blur that image where the form is to make use for the background.

Thanks to @RRUZ this is what I have so far. Compiles, but doesn't quite work yet:

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.
ThisGuy
  • 1,405
  • 1
  • 24
  • 51
  • That code is for a console application, which has affinity to neither framework. And of course, glass is specific to Windows (Vista and 7). How can you expect to have glass on OSX? – David Heffernan Aug 11 '14 at 18:26
  • The article describe the use of the [DWM](http://msdn.microsoft.com/en-us/library/aa969527%28v=vs.85%29.aspx) functions (btw only available in Windows) in a console application. Can you elaborate your question? maybe do you want apply a transparency effect? – RRUZ Aug 11 '14 at 18:27
  • edited.. is the question more clear now? – ThisGuy Aug 11 '14 at 19:13
  • And which operating system are you hoping to have this effect? – David Heffernan Aug 11 '14 at 21:06
  • For Windows you can use the DWM functions and for OSX try this http://cocoasnippets.io/cocoa/ui/nswindow/coregraphics/2014/02/27/translucent-nswindow-with-blurred-background.html – RRUZ Aug 12 '14 at 01:25
  • So that makes this a pure OSX question – David Heffernan Aug 12 '14 at 06:36
  • @RRUZ is there an example or starting point you can lead me on to translate that for FMX? – ThisGuy Aug 12 '14 at 14:46
  • @ThisGuy, I don't have a MacBook right now to test but this must work http://pastebin.com/kYw6e6p6 – RRUZ Aug 12 '14 at 17:07
  • edited. Thanks a ton by the way for helping me. – ThisGuy Aug 12 '14 at 21:59
  • @ThisGuy maybe is related to your OSX version try this http://stackoverflow.com/questions/11174918/how-to-get-window-with-semi-transparent-blurred-background/14475293#14475293 – RRUZ Aug 12 '14 at 22:05
  • ^ Makes reference to an unamed private api to which the link is broken to. – ThisGuy Aug 12 '14 at 22:12

1 Answers1

1

Get this effect in FMX application is much simpler than in VCL, FMX brings specific components to apply effects to other components or forms (including the Blur effect).

Just drop the component on the form and activate it.

enter image description here