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 2 procedure TForm1.Cut1Click(Sender: TObject);
3 begin4 SendMessage(ActiveControl.Handle, WM_Cut, 0, 0);
5 end;
6 7 procedure TForm1.Copy1Click(Sender: TObject);
8 begin9 SendMessage(ActiveControl.Handle, WM_Copy, 0, 0);
10 end;
11 12 procedure TForm1.Paste1Click(Sender: TObject);
13 begin14 SendMessage(ActiveControl.Handle, WM_Paste, 0, 0);
15 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