Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

A Label with caption with more than 255 characters?

Posted on 2004-04-22
7
Medium Priority
?
385 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 240 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

618 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