RAD Studio |  |

Cutting, Copying, and Pasting Text
See Also
Collapse All

Applications that use the Clipbrd unit can cut, copy, and paste text, graphics, and objects through the clipboard. The edit components that encapsulate the standard text-handling controls all have methods built into them for interacting with the clipboard.

To cut, copy, or paste text with the clipboard, call the edit component's CutToClipboard, CopyToClipboard, and PasteFromClipboard methods, respectively.

For example, the following code attaches event handlers to the OnClick events of the EditCut, EditCopy, and EditPaste commands, respectively:

Copy Code

    procedure TEditForm.CutToClipboard(Sender: TObject);
    begin
      Editor.CutToClipboard;
    end;
    procedure TEditForm.CopyToClipboard(Sender: TObject);
    begin
      Editor.CopyToClipboard;
    end;
    procedure TEditForm.PasteFromClipboard(Sender: TObject);
    begin
      Editor.PasteFromClipboard;
    end;

Copy Code

    void __fastcall TMainForm::EditCutClick(TObject* Sender)
    {    RichEdit1->CutToClipboard();
    }
    void __fastcall TMainForm::EditCopyClick(TObject* Sender)
    {    RichEdit1->CopyToClipboard();
    }
    void __fastcall TMainForm::EditPasteClick(TObject* Sender)
    {    RichEdit1->PasteFromClipboard();
    }

See Also

Using the Clipboard with Graphics

TClipboard

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!