Link to home
Start Free TrialLog in
Avatar of paulgriffiths
paulgriffiths

asked on

How do I filter data pasted into a CEdit control

I am using a CEdit in a dialog to allow the user to enter data as either Binary (using chars 0 & 1) or Hex ( using chars 0-9 & A-F); It is very similar to the binary editor found in RegEdt32.

I need a mechanism to prevent illegal characters from being pasted from the clipboard.  

The mechanism must not rely on parsing the entire CEdit buffer on each update as there could be a large amount of data present resulting in a poor response time.

The ideal solution would intercept the paste event, examine the paste buffer and NOT perform the paste operation if invalid characters are found.
ASKER CERTIFIED SOLUTION
Avatar of Tommy Hui
Tommy Hui

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
Avatar of paulgriffiths
paulgriffiths

ASKER

That sorted it!

I had originally wizzed a OnEditPaste() handler for ID_EDIT_PASTE in my CEdit derived class but it never got called.

On your advice I have wizzed a override for CEdit::WindowProc() in my derived class and trapped the WM_PASTE message and it works a treat!

Many Thanks
paulgriffiths