How to activate glass effect (Windows Vista / 7) in a console application using Delphi

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

I found this application, so this should be possible.

+7
windows-7 windows-vista delphi console-application aero-glass
source share
1 answer

A few weeks ago I posted this article on my blog.

The key is used by GetConsoleWindow and DwmEnableBlurBehindWindow .

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

The DwmEnableBlurBehindWindow function allows DwmEnableBlurBehindWindow to blur the effect (glass) on the supplied 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 should check your Windows version to avoid problems.

Screenshothot

+15
source share

All Articles