Link to home
Start Free TrialLog in
Avatar of Roger Alcindor
Roger Alcindor

asked on

programmatically disable paste

Is it possible to disable pasting text on a form or Edit box ? I don't necessarily want to prevent copying by right-click/copy or ctrl-C but I do want to prevent such copied text being pasted into a specific Edit Box. I wish to force the user to type data in the Edit box.
I am using  Borland or Embarcadero C++ Builder and windows Xp/windows 7
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ooops, just in case you didn't notice, I altered the example to exactly suit your needs. While C++ Builder hadles dialog instantiation differently, the rest of that pure WinAPI example will show how to handle subclassing in the big picture.
Avatar of Roger Alcindor
Roger Alcindor

ASKER

Thanks for your help. I will take some time to study the references.
I have adopted a different approach which involves less code using the VCL Clipboard component to clear the clipboard with an on-click event for the EditBox control in question. the code is as follows:

void __fastcall TForm1::Edit1Click(TObject *Sender)
{
    Clipboard()->Clear();
}
I'd be careful about emptying the clipboard, since that is something that the user won't expect and this would interfere with their workflow... there might be something important in there that was not intended for yor app...
The app is the only one that is running with user interaction. The user has been copying and pasting data that he has previously entered which is not what he should be doing. This measure is intended to force the user to type the entry each time. The IT team have temporarily disabled the right-hand mouse button on this PC (un-beknownst to me) using a registry setting as it would appear that the operator is not aware of ctrl-C/ctrl-V to copy & paste. The application is in an automotive production line environment and the operators are only supposed to use the control application so there is no danger of any interference with their work.