Delphi XE2 TLabel Globesize 导致屏幕左上角出现图形问题
自从将应用程序从XE移植到XE2后,我注意到一个奇怪的错误,只需在ide中打开窗体或运行应用程序,屏幕左上角(窗体外)就会绘制一个白色方框,将鼠标或窗口悬停在上方即可离开。我追踪到了 TLabel,只需在表单上放置一个并将 Glowsize 设置为高于 0 就会导致问题。
我重新安装并更新到最新的 XE2 update3,问题仍然存在。有人知道发生了什么事吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题始于使用屏幕设备上下文和标志 DT_CALCRECT 调用
DoDrawText
的TCustomLabel.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 始终被设置:
而在 XE2 中,仅当标签绘制在玻璃上时才会设置该标志:
The problem starts in
TCustomLabel.AdjustBounds
with a call toDoDrawText
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. TheDT_CALCRECT
flag should prevent that but theDrawThemeTextEx
call inVcl.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 whyDrawThemeTextEx
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:
whereas in XE2 the flag is only set if the label is painted on glass:
如果您禁用标签上的“自动调整大小”,该问题似乎就会消失。
我没有更深入地调查原因,但作为解决该错误之前的解决方法,它效果很好。
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.