views:

678

answers:

1

As I can activate the glass effect on my console applications. I am using Windows 7 and Delphi 2010.

I found this application so it should be possible.

alt text

Thanks.

+13  A: 

Hi @Salvador, a couple of weeks ago I published this article on my blog.

The key is use the GetConsoleWindow and DwmEnableBlurBehindWindow functions.

The GetConsoleWindow function retrieves the window handle used by the console associated with the calling process.

The DwmEnableBlurBehindWindow function Enables the blur effect (glass) on the provided window handle.

program ConsoleGlassDelphi;

{$APPTYPE CONSOLE}

    uses
  Windows,
  SysUtils;

type
  DWM_BLURBEHIND = record
    dwFlags                 : DWORD;
    fEnable                 : BOOL;
    hRgnBlur                : HRGN;
    fTransitionOnMaximized  : BOOL;
  end;

function DwmEnableBlurBehindWindow(hWnd : HWND; const pBlurBehind : DWM_BLURBEHIND) : HRESULT; stdcall; external  'dwmapi.dll' name 'DwmEnableBlurBehindWindow';//function to enable the glass effect
function GetConsoleWindow: HWND; stdcall; external kernel32 name 'GetConsoleWindow'; //get the handle of the console window

function DWM_EnableBlurBehind(hwnd : HWND; AEnable: Boolean; hRgnBlur : HRGN = 0; ATransitionOnMaximized: Boolean = False; AFlags: Cardinal = 1): HRESULT;
var
  pBlurBehind : DWM_BLURBEHIND;
begin
  pBlurBehind.dwFlags:=AFlags;
  pBlurBehind.fEnable:=AEnable;
  pBlurBehind.hRgnBlur:=hRgnBlur;
  pBlurBehind.fTransitionOnMaximized:=ATransitionOnMaximized;
  Result:=DwmEnableBlurBehindWindow(hwnd, pBlurBehind);
end;

begin
  try
    DWM_EnableBlurBehind(GetConsoleWindow(), True);
    Writeln('See my glass effect');
    Writeln('Go Delphi Go');
    Readln;
  except
    on E:Exception do
      Writeln(E.Classname, ': ', E.Message);
  end;
end.

This is just a basic example, you must check the windows OS version to avoid issues.

alt text

RRUZ
That is very cool!
Mick
Seconded - very cool!
David M
Thirded. Very, VERY cool. :)
Deltics
Forth, inc(Cool); ;-/
avar
Thanks very much
Salvador