Solved

A Label with caption with more than 255 characters?

Posted on 2004-04-22
7
373 Views
Last Modified: 2010-04-05
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
Comment
Question by:MartinC
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 11

Accepted Solution

by:
robert_marquardt earned 60 total points
Comment Utility
I was not aware that TLabel has a limit at all. Check your compiler options.
0
 

Author Comment

by:MartinC
Comment Utility
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
 
LVL 12

Expert Comment

by:esoftbg
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 12

Expert Comment

by:Ivanov_G
Comment Utility

  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
 

Author Comment

by:MartinC
Comment Utility
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
 
LVL 12

Expert Comment

by:esoftbg
Comment Utility
I tested Delphi 7 TLabel, I think it is limited to 955 characters in the caption.
0
 
LVL 12

Expert Comment

by:Ivanov_G
Comment Utility

   Emo, pi4,

   TCaption = String.

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now