Search code examples
clipboardc++buildervcl

How to disable copy/paste in TEdit


I would like to prevent copy, cut and paste in my TEdit. How can I do this?

I tried setting the Key=NULL on KeyDown event when CTRL+V was pressed on the control, but it didn't work.


Solution

  • You'll need to prevent the WM_CUT, WM_COPY, and WM_PASTE messages from being sent to your TEdit. This answer describes how do to this using just the Windows API. For the VCL, it may be sufficient to subclass TEdit and change its DefWndProc property or override its WndProc method.