[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 386
  • Last Modified:

A Label with caption with more than 255 characters?

I need to find a component that is like a TLabel but is not limited to 255 characters in the caption. A TMemo is the obvious answer, but I need to have the Autosize and Wordwrap functionality of a label so that the component is only as high as it needs to be once it has determined how many times it needs to wrap itself.

I am autocreating a bunch of TLabels one below another, and need to have each one only give themselves the minimum height they need to display the info. TMemos all default to Height of 89, and I can't seem to get them to snap to minimum size required, as Autosize and Wordwrapped labels do.

Basically the components represent paragraphs but need to do different things if clicked on.
0
MartinC
Asked:
MartinC
  • 2
  • 2
  • 2
  • +1
1 Solution
 
robert_marquardtCommented:
I was not aware that TLabel has a limit at all. Check your compiler options.
0
 
MartinCAuthor Commented:
OK, the only thing I can find is a boolean called "Huge strings". The Help on it says "Enables new garbage collected strings. The string keyword corresponds to the AnsiString type with this option enabled. Otherwise the string keyword corresponds to the ShortString type. Corresponds to {$H}."

I have this already set to Checked. But I still only get 255 chars in my labels.

MartinC
0
 
esoftbgCommented:
If you would like to use a free library try:
JEDI VCL (http://jvcl.sourceforge.net)
  1. TJvRealLabel from Jv Labels palette
      - property text
      - Tested with Text := '0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 0123456789012345678901234567890123456789 ';

  2. TJvxLabel from Jv Controls palette
      - property Caption
      - Tested with Caption := '0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789
0123456789012345678901234567890123456789 '

emil
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Ivanov_GCommented:

  Label.Caption is type TCaption = String....


  // this code work in Delphi 5
  procedure TForm1.Button1Click(Sender: TObject);
  var
    Counter : Integer;
  begin
    Label1.Caption := '';
    for Counter := 1 to 300 do
      Label1.Caption := Label1.Caption + 'a';
  end;


   var S: string;
creates a variable S that holds a string. In the default {$H+} state, the compiler interprets string (when it appears without a bracketed number after it) as AnsiString. Use the {$H–} directive to turn string into ShortString.

0
 
MartinCAuthor Commented:
Hmm, OK, now I have tried it again and it works! I suspect that:

1) I have Huge Strings turned OFF at home
2) I did something funny with the ORDER in which I set the limited width and the AutoSize andf WordWrap.

Anyway, robert_marquardt's solution was all I really needed, so Points to him. Thanks to all.
0
 
esoftbgCommented:
I tested Delphi 7 TLabel, I think it is limited to 955 characters in the caption.
0
 
Ivanov_GCommented:

   Emo, pi4,

   TCaption = String.

   When you have {$H+} - by default - string type range is 4 bytes to 2GB      
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now