XBasic3000
XBasic3000

Reputation: 3486

how to make the richedit not to select or hightlight?

help i wnted the richedit cannot be highlighted/ disable the hightlight or selection of text? also remove the cursor pos. the application is intended for display only the rtf text and not editing so i dont need those features. in delphi

Upvotes: 2

Views: 3883

Answers (4)

denim
denim

Reputation: 1347

You can simply disable the RichEdit to prevent text selection and to hide the text cursor:

RichEdit.Enabled := FALSE;

Upvotes: 0

No'am Newman
No'am Newman

Reputation: 6477

You could set the readonly property of the RichEdit to be true - this prevents keystrokes, etc.

Upvotes: 1

Mawg
Mawg

Reputation: 40140

Just to clarify - you definitely need rich text features, like color, size, etc? And you definitely want to forbid copy from your control & paste somewhere else? Is that it exactly?

I would suggest that you override OnMouseUp, OnSaveCLipboard, OnSelectionChange from TRichEdit and the inherited methods GetSelTextBuf, CopyToClipboard, CutToClipboard, SelectAll .. maybe Repaint, Update and a few more.

Be sure of what you want - if you can live without rich text features, then just use some TLabels and write the text programatically.

If you must have rich text I see a few choices - write a lot of even handlers for your componet, or create your own component derived from TRichEdit, which makes it easier to have sevaral of them on one form, or look at sites like Tori's and see if someone else already made such acomponent.

Good luck.

Upvotes: 2

RRUZ
RRUZ

Reputation: 136391

you can set the SelLength property to 0 in the OnSelectionChange event

procedure TForm1.RichEdit1SelectionChange(Sender: TObject);
begin
 TRichEdit(Sender).SelLength:=0;
end;

Upvotes: 4

Related Questions