Delphi Central - Tutorials - The Easy way to Cut Copy and Paste

'

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

I won't explain how I implemented this the first time I tried, but if you have ever done it yourself I think you can imagine its not pretty.


Google
Web www.Delphi-Central.com
Delphi Central - Delphi Programming Tutorials, Hints and Tips