Delphi 7 应用程序中 Aero Glass 的问题

发布于 2024-09-02 05:57:28 字数 1199 浏览 0 评论 0原文

我正在尝试重新制作一些旧项目来支持 Aero Glass。虽然启用玻璃框架很容易,但我遇到了一些主要问题。我使用了这段代码:

var
  xVer: TOSVersionInfo;
  hDWM: THandle;
  DwmIsCompositionEnabled: function(pbEnabled: BOOL): HRESULT; stdcall;
  DwmExtendFrameIntoClientArea: function(hWnd: HWND; const pxMarInset: PRect): HRESULT; stdcall;
  bEnabled: BOOL;
  xFrame: TRect;

// ...

  xVer.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
  GetVersionEx(xVer);
  if xVer.dwMajorVersion >= 6 then
  begin
    hDWM := LoadLibrary('dwmapi.dll');
    @DwmIsCompositionEnabled := GetProcAddress(hDWM, 'DwmIsCompositionEnabled');
    @DwmExtendFrameIntoClientArea := GetProcAddress(hDWM, 'DwmExtendFrameIntoClientArea');
    if (@DwmIsCompositionEnabled <> nil) and
       (@DwmExtendFrameIntoClientArea <> nil) then
    begin
      DwmIsCompositionEnabled(@bEnabled);
      if bEnabled then
      begin
        xRect := Rect(-1, -1, -1, -1);
        DwmExtendFrameIntoClientArea(FrmMain.Handle, @xRect);
      end;
    end;
    FreeLibrary(hDWM);
  end;

所以我现在得到了漂亮的玻璃窗。由于黑色现在是透明颜色(有点愚蠢的选择,为什么不能是粉红色),任何 clBlack 也都会变得透明。这意味着所有标签、编辑、按钮文本...即使我在设计时将文本设置为其他颜色,DWM 仍然使它们具有这种颜色和透明。

好吧,我的问题是 - 是否有可能以某种方式解决这个问题?

I'm trying to remake some of my older projects to support Aero Glass. Although it's kinda easy to enable glass frame, I've encountered some major problems. I used this code:

var
  xVer: TOSVersionInfo;
  hDWM: THandle;
  DwmIsCompositionEnabled: function(pbEnabled: BOOL): HRESULT; stdcall;
  DwmExtendFrameIntoClientArea: function(hWnd: HWND; const pxMarInset: PRect): HRESULT; stdcall;
  bEnabled: BOOL;
  xFrame: TRect;

// ...

  xVer.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
  GetVersionEx(xVer);
  if xVer.dwMajorVersion >= 6 then
  begin
    hDWM := LoadLibrary('dwmapi.dll');
    @DwmIsCompositionEnabled := GetProcAddress(hDWM, 'DwmIsCompositionEnabled');
    @DwmExtendFrameIntoClientArea := GetProcAddress(hDWM, 'DwmExtendFrameIntoClientArea');
    if (@DwmIsCompositionEnabled <> nil) and
       (@DwmExtendFrameIntoClientArea <> nil) then
    begin
      DwmIsCompositionEnabled(@bEnabled);
      if bEnabled then
      begin
        xRect := Rect(-1, -1, -1, -1);
        DwmExtendFrameIntoClientArea(FrmMain.Handle, @xRect);
      end;
    end;
    FreeLibrary(hDWM);
  end;

So I got the pretty glass window now. Due to black being transparent color now (kinda stupid choice, why couldn't it be pink) anything that is clBlack becomes transparent, too. It means all labels, edits, button texts... even if I set text to some other color at design time, DWM still makes them that color AND transparent.

Well, my question would be - whether it's possible to solve this somehow?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

糖果控 2024-09-09 05:57:28

Delphi 7 以及 D2006 之前的所有版本在 Windows Vista 及更新版本中也存在其他问题。

Delphi 2007 是第一个经过 Vista 认证的版本。我的建议是升级到 Delphi 2010。您修补 Delphi 7 的努力对于结果而言太大了。好吧,也许您需要将您的应用程序转换为 Unicode(这个过程远没有听起来那么痛苦 - 特别是如果您使用 Embarcadero 的论坛和/或此网站),但这是值得的。这不仅是为了兼容 Vista,而且还为了新版本 Delphi 中包含的所有好东西,尤其是 Delphi 2010。

HTH

Delphi 7 and all the versions till D2006 has also other problems with Windows Vista and newer.

Delphi 2007 is the fist certified version for Vista. My advice is to upgrade to Delphi 2010. Your effort to patch Delphi 7 is imho too big for the outcome. Ok, perhaps you will need to convert your application to Unicode (a far less painful process than it sounds - especially if you use Embarcadero's forums and/or this site) but it's worth the effort. And this not only for Vista compatibility but also for all the goodies which are packed with newer versions of Delphi, especially with Delphi 2010.

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文