Posted by webmaster Guido on June 20, 2005 In Reply to: click and select line (hightlight) in TMemo
posted by Johan *DClub* on June 20, 2005 Selecting text in a Delphi TMemo component is done by setting the SelStart and SelLength properties. If you want to select the entire current line with a mouse click, start
by creating an OnClick event handler for the Memo. Here's a source code example: procedure TForm1.Memo1Click(Sender: TObject); var CurrentLine: integer; begin CurrentLine := Memo1.Perform(EM_LINEFROMCHAR, -1, 0); Memo1.SelStart := Memo1.Perform(EM_LINEINDEX, CurrentLine, 0); Memo1.SelLength := Length(Memo1.Lines[CurrentLine]); end; |