Author: Dave G
How to add cut, copy and paste easy
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:
1 procedure TForm1.Cut1Click(Sender: TObject);
2 begin3 SendMessage(ActiveControl.Handle, WM_Cut, 0, 0);
4 end;
5 6 procedure TForm1.Copy1Click(Sender: TObject);
7 begin8 SendMessage(ActiveControl.Handle, WM_Copy, 0, 0);
9 end;
10 11 procedure TForm1.Paste1Click(Sender: TObject);
12 begin13 SendMessage(ActiveControl.Handle, WM_Paste, 0, 0);
14 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