Solved

A Label with caption with more than 255 characters?

Posted on 2004-04-22
7
379 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
ID: 10896344
I was not aware that TLabel has a limit at all. Check your compiler options.
0
 

Author Comment

by:MartinC
ID: 10896755
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
ID: 10896978
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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10896994

  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
ID: 10897116
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
ID: 10897120
I tested Delphi 7 TLabel, I think it is limited to 955 characters in the caption.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10897153

   Emo, pi4,

   TCaption = String.

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
code issue 8 155
Delphi: making a BW image transparent 10 61
Delphi Seattle StructureView color 1 14
FMX TEdit KeyUp handler detecting  "enter" key 4 14
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 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