Delphi XE2 TLabel glowsize causes graphic issue on top left corner of the screen
Asked Answered
D

2

10

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

Dymoke answered 18/12, 2011 at 22:21 Comment(0)
C
13

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);
Conversazione answered 18/12, 2011 at 23:2 Comment(0)
E
2

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.

Elisabethelisabethville answered 7/1, 2012 at 21:42 Comment(2)
This seems to correlate with Andreas Hausladen's answer. He says the problem has to do with calling DrawThemeTextEx with DT_CALCRECT. I imagine that is only done when there's the need to calculate the size of the label = when the label's AutoSize is True. If you turn of AutoSize, no call with DT_CALCRECT is performed and, consequently, the bug is not produced.Spritsail
Yup that works; setting autosize later after form creation and before changing the caption also seems to avoid the issue (possibly re-appearing later). It remains unfixed in latest update4.Dymoke

© 2022 - 2024 — McMap. All rights reserved.