Author: William Gerbert
Copy from the active control to the clipboard
Answer:
Use the following piece of code for this.
Note: You may trigger the menu open event and enable/disable the copy/paste menu
items depending on the type of control that is active.
1 procedure CopyButtonClick(Sender: TObject);
2 begin3 if ActiveControl is TMemo then4 TMemo(ActiveControl).CopyToClipboard;
5 if ActiveControl is TDBMemo then6 TDBMemo(ActiveControl).CopyToClipboard;
7 if ActiveControl is TEdit then8 TEdit(ActiveControl).CopyToClipboard;
9 if ActiveControl is TDBedit then10 TDBedit(ActiveControl).CopyToClipboard;
11 end;
12 13 procedure PasteButtonClick(Sender: TObject);
14 begin15 if ActiveControl is TMemo then16 TMemo(ActiveControl).PasteFromClipboard;
17 if ActiveControl is TDBMemo then18 TDBMemo(ActiveControl).PasteFromClipboard;
19 if ActiveControl is TEdit then20 TEdit(ActiveControl).PasteFromClipboard;
21 if ActiveControl is TDBedit then22 TDBedit(ActiveControl).PasteFromClipboard;
23 end;