7

I noticed that in a (Delphi 10.3.3 32-bit VCL app on Windows 10 64-bit) application that the caption of a label would not display if the string was "really" long. Further testing indicates that it is not restricted to a TLabel. TStaticText also behaves the same way and probably all of the TGraphicControls.

With a TLabel on a form, testing indicates that it will show the caption if it is 43,679 characters in length. But any longer and the caption disappears. No combination of autosize, wordwrap, EllipsisPosition changed this behaviour. Tracing through the delphi code, it comes down to 2 statments in VCL.Controls:

  Perform(WM_SETTEXT, 0, Buffer);
  Perform(CM_TEXTCHANGED, 0, 0);

Buffer holds the correct value of the caption's string in all cases. But at 43,680 chars the caption disappears. So it appears to be a Windows limit but I cannot find any confirmation of this.

TomB
  • 750
  • 4
  • 17
  • [Perhaps something like this](https://learn.microsoft.com/en-us/windows/win32/controls/em-limittext) – MBo Nov 17 '20 at 04:08
  • @MBo. Thanks. Doesn't look applicable: "The EM_LIMITTEXT message limits only the text the user can enter." – TomB Nov 17 '20 at 04:58
  • Which version of Delphi are you using? – Remy Lebeau Nov 17 '20 at 05:01
  • 1
    `TLabel` isn't a windowed control, so the first contact with the Windows API should be at `DrawText` or something similar. – Andreas Rejbrand Nov 17 '20 at 07:48
  • I am unable to reproduce this issue. I'm using Delphi 10.3.2 on Windows 7, 64-bit. I am currently looking at a 43691-character `TLabel` in a 32-bit VCL app. – Andreas Rejbrand Nov 17 '20 at 13:29
  • Limit is not related with character string, I can duplicate it with just 4096 characters - one factor is font size. Label, graphic controls or in general VCL does not seem to have any part of it. This is how I duplicate: `var s: string; R: TRect; begin s := StringOfChar('a', 4096); R := ClientRect; DrawText(Canvas.Handle, PChar(s), -1, R, 0);` – Sertac Akyuz Nov 17 '20 at 18:06
  • Although missing in the code I commented, the function does not fail. Same with `DrawThemeTextEx`, what the label use when the app is styled - the function does not fail but content does not show. Limit is the same with DrawText and DrawThemeTextEx. – Sertac Akyuz Nov 17 '20 at 18:09
  • @Remy I am using Delphi 10.3.3; but have also reproduced problem with 10.4.1. – TomB Nov 17 '20 at 19:58
  • @SertacAkyuz "*when the app is styled*" - does the problem happen if the style is turned off? – Remy Lebeau Nov 17 '20 at 20:03
  • @SertacAkyuz I get no change in results when turning runtime themes off; styling is as per default (Windows); and no change in results if I change font size down a couple of steps. – TomB Nov 17 '20 at 20:30
  • @Remy - Yes, runtime themes makes no difference. I'm testing with XE2 (32 or 64 bits make no difference) on W7x64. – Sertac Akyuz Nov 17 '20 at 20:45

0 Answers0