Solved

A Label with caption with more than 255 characters?

Posted on 2004-04-22
7
383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

728 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