【问题标题】:Caption of PngBitBtn does not appear when runtime themes are enabled启用运行时主题时不显示 PngBitBtn 的标题
【发布时间】:2014-12-05 15:01:30
【问题描述】:

我用一个 PngBitBtn 做了一个简单的项目,然后用以下配置编译它:

  1. 运行时主题被禁用
    • 调试模式 - 确定
    • 发布模式 - 确定
  2. 运行时主题已启用
    • 调试模式 - 确定
    • 发布模式 - PngBitBtn 上没有标题

正确显示字幕的唯一方法是关闭优化。不关闭优化能解决这个问题吗?

提前谢谢你,蒂姆

在 Delphi XE3、XE6 上测试。 平台:win32。 PNGComponents 版本:embarcadero CodeCentral 的最新版本。

打印屏幕:

【问题讨论】:

  • 只是出于好奇,既然 Delphi 本身现在支持开箱即用的 PNG 图像,为什么你还在使用 PngComponents?
  • 我也在想同样的事情......
  • @Tim,自 2009 年以来开箱即用。
  • @Tim,不一定。虽然 TPngSpeedButton、TPngBitBtn 和 TPngCheckListBox 也可以用 Delphi 附带的标准控件替换,但 TPngImageCollection 仍然没有对应物。甚至 TPngImageList 也有其优势,因为它以原生 PNG 格式存储 Png 图像,而标准的 TImageList 转换为 BMP。这可能会给 DFM 文件带来一些显着的大小差异。另一方面:它只是 PNG。
  • @Tim,TButton 将不同的图像作为 TBitmap 复制到其内部图像列表中。 TPngBitBtn 根本不使用图像列表。 TPngImageList 的优点之一是它以 PNG 格式存储图像,而标准 TImageList 使用 BMP 格式,即使图像是从 PNG 文件加载的。

标签: delphi vcl-styles


【解决方案1】:

只是一个错误!

要修复它,请在 PngBitBtn.pas 方法 TPngBitBtnStyleHook.DrawButton 的第 326 行插入以下行:

  Offset := TPoint.Create(0, 0);

该区域的代码现在应该如下所示:

  if not (Control is TPngBitBtn) then
  begin
    inherited;
    Exit;
  end;
  Offset := TPoint.Create(0, 0);
  DrawRect := Control.ClientRect;

【讨论】:

    猜你喜欢
    • 2018-09-30
    • 2021-07-26
    • 1970-01-01
    • 1970-01-01
    • 2012-06-21
    • 2012-03-20
    • 1970-01-01
    • 2012-10-03
    • 1970-01-01
    相关资源
    最近更新 更多