Here's how to select a row (line) of text in a TMemo control by clicking on it:
Note:Drop a TMemo (Memo1) on a form and call the "SelectMemoLine" procedure from Memo's OnClick event:
~~~~~~~~~~~~~~~~~~~~~~~~~
procedure SelectMemoLine(Memo : TCustomMemo) ;
var
Line : integer;
begin
with Memo do
begin
Line := Perform(EM_LINEFROMCHAR, SelStart, 0) ;
SelStart := Perform(EM_LINEINDEX, Line, 0) ;
SelLength := Length(Lines[Line]) ;
end;
end;
//Usage:
procedure TForm1.Memo1Click(Sender: TObject) ;
begin
SelectMemoLine(Memo1) ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
If you are looking for more TMemo related tips: TMemo to the Max
Delphi tips navigator:
» How to focus a specific cell (by field name) in a DBGrid Delphi component
« How to start your favorite application directly from the Delphi IDE
previous post
next post