SelText (C++)
Description
This example copies selected text from one text edit to another. The example requires two text edits and two buttons.
Char *Buffer;
Code
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  int Size = Edit1->SelLength; //Get the length of the selected text in Edit1.
  Size++;                      //Add room for null character.
  Char *Buffer = new Char[Size];  //Creates Buffer dynamic variable
  Edit1->GetSelTextBuf(Buffer,Size); //Puts Edit1->Text into Buffer
  Edit2->Text = Buffer;
  delete [] Buffer;
}
//---------------------------------------------------------------------------
/*
Note: The same thing could be accomplished easier as follows:
*/
void __fastcall TForm1::Button2Click(TObject *Sender)
{
  Edit2->Text = Edit1->SelText;
}
Uses
- Vcl.StdCtrls.TCustomEdit.GetSelTextBuf ( fr | de | ja )
 - Vcl.StdCtrls.TCustomEdit.SelText ( fr | de | ja )