CopyToClipboard (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses an edit box, a rich edit control, and a button on a form. When you click the button, the first line of text is copied from the rich edit control and pasted into the edit box. Note that only the text is pasted. If the rich edit control includes any formatting information, that is not pasted into the edit control. If the destination was a rich edit control, the formatting information would be copied as well.

Code

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  RichEdit1->SelectAll();
  RichEdit1->CopyToClipboard();
  Edit1->Clear();
  Edit1->PasteFromClipboard();
  RichEdit1->SetFocus();
}

__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
  RichEdit1->PlainText = False;
  RichEdit1->Lines->LoadFromFile(L"..\\overview.rtf");
  RichEdit1->ScrollBars = ssVertical;
}

Uses