delphi - 如何使用 Delphi 在控制台应用程序中激活玻璃效果(Windows Vista/7)

标签 delphi windows-7 console-application windows-vista aero-glass

因为我可以在我的控制台应用程序上激活玻璃效果。我使用的是 Windows 7 和 Delphi 2010。

我找到了this应用程序所以它应该是可能的。

最佳答案

几周前我发布了 this article在我的博客上。

关键是使用GetConsoleWindowDwmEnableBlurBehindWindow功能。

GetConsoleWindow 函数检索与调用进程关联的控制台所使用的窗口句柄。

DwmEnableBlurBehindWindow 函数在提供的窗口句柄上启用模糊效果(玻璃)。

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.

这只是一个基本示例;您必须检查 Windows 操作系统版本以避免出现问题。

Screenshot

关于delphi - 如何使用 Delphi 在控制台应用程序中激活玻璃效果(Windows Vista/7),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1766527/

相关文章:

windows-7 - Windows 7 上的 Safari 开发人员证书不适用于我。我应该怎么办?

postgresql密码验证失败

德尔福XE2 : Is it possible to create Mac GUI applications without FireMonkey?

delphi - 快速识别当前过程调用位置的方法

delphi - Delphi XE2试用版中如何缩放TImage控件中加载的图像?

delphi - 如何确定给定字体的行间距(以像素为单位)(对于 TVirtualTreeView)

iis - 为什么从文件夹运行 IIs-express 时会出现错误 http 500.0?

C#:控制台正在输出无穷大(∞)

C++ 控制台窗口闪烁然后消失

docker - 如何在 docker 容器中运行 Symfony 控制台命令