Title: How to get the selected text from a Memo control
If you need to know what portion of the text a user selected in a TMemo (or TEdit) component, right after the selection was made, you can use the next code in the OnMouseUp event handler for a TMemo (named Memo1 in the code below) control:
~~~~~~~~~~~~~~~~~~~~~~~~~
procedure TForm1.Memo1MouseUp(
Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer) ;
var
selection : string;
begin
selection := Memo1.SelText;
ShowMessage('Text selected: ' + selection)
end;
~~~~~~~~~~~~~~~~~~~~~~~~~