RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomEdit.SetSelTextBuf Method

Replaces the selected text with a null-terminated string.

Pascal
procedure SetSelTextBuf(Buffer: PChar);
C++
__fastcall SetSelTextBuf(const char * Buffer);

Use SetSelTextBuf to replace the current selection by the contents of the null-terminated string pointed to by Buffer. If no text is selected, the contents of Buffer are inserted at the cursor. SetSelTextBuf does the same thing as setting the SelText property, except that it takes a pointer to a char type rather than a string.  

C++ Examples: 

 

/*
This example inserts the contents of temp_string at the
current location of the cursor.
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
   const AnsiString Path = "../readme.txt";
   Memo1->Lines->LoadFromFile(Path);
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  char * temp_string = "I am now here";
  Memo1->SetSelTextBuf(temp_string);
}

 

Delphi Examples: 

{
This example inserts the contents of temp_string at the
current location of the cursor.
} 
procedure TForm1.Button1Click(Sender: TObject);
var
  temp_string: array[0..15] of Char;
begin
  temp_string := 'I am now here';
  Memo1.SetSelTextBuf(temp_string);
end;

procedure TForm1.FormCreate(Sender: TObject);
const Path = 'readme.txt';
begin
  Memo1.Lines.LoadFromFile(Path);
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!