Go Premium for a chance to win a PS4. Enter to Win

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

Longer Labels or Memo ?

Which component shoul I use to display text (more than 255 chars which is the limit of either Label ans StaticText) ? I don't want this text to be editable I just want ot display it. If I use TMemo when I disable it so that no user can edit it becomes dimmed. Can I change this ?
0
aloha
Asked:
aloha
1 Solution
 
interCommented:
Hi,

1 - Take a TMemo
2 - Set BorderStyle to bsNone
3 - Set Color to clBtnFace
4 - Set Ctl3D to false
5 - Set ReadOnly to true
6 - DO NOTt set Enabled to FALSE

may this help
Igor
0
 
alohaAuthor Commented:
But that still makes the cursor appear and the text is selectable. I don't what this to happen too.

And How do I assign some text to the Memo in code not in the object inspector? If I use the Text property I cant Assign strings longer than 255 chars. How do I use the Lines property ?

Sorry for not mentioning it earlier.
0
 
interCommented:
Here is for adding text line by line:

Memo1.Lines.Add('this is line 1');
Memo1.Lines.Add('this is line 2');

etc,

Regards,(no disable code sorry)
Igor
0
 
pjdbCommented:
Put the readonly property to true

JDB
0
 
rene100Commented:
Hi aloha
this is the code for a new memo component that should solve your problem:

unit Memo1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TMemo1 = class(TMemo)
  private
    procedure WMLClick(var message: TMessage); message  WM_LButtonDown;
    procedure WMRClick(var message: TMessage); message WM_RButtonDown;
    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Eigene', [TMemo1]);
end;

procedure TMemo1.WMLClick(var message: TMessage);
//dispatch left-mouseclicks
begin
end;
procedure TMemo1.WMRClick(var message: TMessage);
//dispatch right-mouseclicks
begin
end;
end.

additionly, you must set the read-only property to true, the
tabstop property to false and the cursor property to crArrow
(if you don't want to do these things everytime, use
TMemo1=class(TCustomMemo) in spite of TMemo1=class(TMemo) and
publish all properties you need).

hope this help and I didn't forgot something

regards
rene100
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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now