Title: The Easy Way to Cut Copy and Paste
Question: Shows you how to provide clipboard functionality to all relevant controls on a form with the minimum of code.
Answer:
After a lot of hair pulling out I stumbled across this method of using the windows messages. This is best demonstrated with the following code:
procedure TForm1.Cut1Click(Sender: TObject);
begin
SendMessage (ActiveControl.Handle, WM_Cut, 0, 0);
end;
procedure TForm1.Copy1Click(Sender: TObject);
begin
SendMessage (ActiveControl.Handle, WM_Copy, 0, 0);
end;
procedure TForm1.Paste1Click(Sender: TObject);
begin
SendMessage (ActiveControl.Handle, WM_Paste, 0, 0);
end;
If you are developing a MDI application, you will need to make sure that the message is sent to the active child by using: ActiveMDIChild.ActiveControl.Handle