Delphi XE2 TLabel Globesize 导致屏幕左上角出现图形问题

发布于 2024-12-21 22:49:00 字数 394 浏览 2 评论 0原文

自从将应用程序从XE移植到XE2后,我注意到一个奇怪的错误,只需在ide中打开窗体或运行应用程序,屏幕左上角(窗体外)就会绘制一个白色方框,将鼠标或窗口悬停在上方即可离开。我追踪到了 TLabel,只需在表单上放置一个并将 Glowsize 设置为高于 0 就会导致问题。

我重新安装并更新到最新的 XE2 update3,问题仍然存在。有人知道发生了什么事吗?

示例 1

示例 2

在此处输入图像描述

Ever since porting an app from XE to XE2 I noticed a strange bug, just opening the form in the ide or running the app, a white square box is drawn on the top left corner of the screen (out of the form), which goes away upon hovering the mouse or a window over. I tracked this down to TLabel, simply dropping one on the form and setting Glowsize above 0 causes the issue.

I reinstalled and updated to the last XE2 update3 and the issue still occurs. Anyone has a clue what's going on?

example 1

example 2

enter image description here

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

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

发布评论

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

评论(2

桃扇骨 2024-12-28 22:49:00

问题始于使用屏幕设备上下文和标志 DT_CALCRECT 调用 DoDrawTextTCustomLabel.AdjustBounds。因此,如果在该设备上下文上绘制任何内容,它将被绘制到屏幕上。 DT_CALCRECT 标志应该可以防止这种情况,但是 Vcl.Themes.TUxThemeStyle.DoDrawText 中的 DrawThemeTextEx 调用似乎忽略了 DT_CALCRECT + LOptions.dwFlags DTT_CALCRECT 和绘制到设备上下文上,它应该只计算所需的矩形。我不知道为什么 DrawThemeTextEx 这样做(还),但它是一个起点。

更新1:
Delphi 2009似乎不受此影响,但也调用了DrawThemeTextEx。我看到的唯一区别是选项记录的所有未使用字段均为零,而在 Delphi XE2 中它们包含垃圾。也许 DrawThemeTextEx 需要它们为零。

更新2:
Delphi 2009 和 XE2 之间的区别在于,在 Delphi 2009 中不仅指定了 DTT_CALCRECT,而且还指定了 DTT_COMPOSITE。

在 Delphi 2009 中,DTT_COMPOSITE 始终被设置:

Options.dwFlags := DTT_TEXTCOLOR or DTT_COMPOSITED or DTT_GLOWSIZE;

而在 XE2 中,仅当标签绘制在玻璃上时才会设置该标志:

  if csGlassPaint in ControlState then
    Include(LFormat, tfComposited);

The problem starts in TCustomLabel.AdjustBounds with a call to DoDrawText with the screen's device context and the flag DT_CALCRECT. So if anything paints on that device context, it will be painted onto the screen. The DT_CALCRECT flag should prevent that but the DrawThemeTextEx call in Vcl.Themes.TUxThemeStyle.DoDrawText seems to ignore the DT_CALCRECT + LOptions.dwFlags DTT_CALCRECT and paints onto the device context where it should only calculate the required rectangle. I don't know why DrawThemeTextEx does that (yet), but it is a starting point.

UPDATE 1:
Delphi 2009 doesn't seem to be affected by this but also calls DrawThemeTextEx. The only difference I see is that all unused fields of the Options record are zero whereas in Delphi XE2 they contain garbage. Maybe DrawThemeTextEx needs them to be zero.

UPDATE 2:
The difference between Delphi 2009 and XE2 is that in Delphi 2009 not only DTT_CALCRECT is specified but also DTT_COMPOSITE.

In Delphi 2009 the DTT_COMPOSITE is always set:

Options.dwFlags := DTT_TEXTCOLOR or DTT_COMPOSITED or DTT_GLOWSIZE;

whereas in XE2 the flag is only set if the label is painted on glass:

  if csGlassPaint in ControlState then
    Include(LFormat, tfComposited);
战皆罪 2024-12-28 22:49:00

如果您禁用标签上的“自动调整大小”,该问题似乎就会消失。

我没有更深入地调查原因,但作为解决该错误之前的解决方法,它效果很好。

The problem seems to disappear if you disable AutoSize on the label.

I didn't investigate deeper why, but as a workaround until that bug is fixed it does fine.

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