加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-15 04:18:48 所属栏目:大数据 来源:网络整理
导读:因为我可以在我的控制台应用程序上激活玻璃效果.我使用的是 Windows 7和Delphi 2010. 我找到了this申请,所以应该可以. 解决方法 几周前,我在我的博客上发布了 this article. 关键是使用 GetConsoleWindow 和 DwmEnableBlurBehindWindow 功能. GetConsoleWind
因为我可以在我的控制台应用程序上激活玻璃效果.我使用的是 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操作系统版本以避免问题.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读