c# - Disable image paste in RichTextBox in Winforms -
we have usercontrols herits richtextbox. forbid user enter image(with copy paste) in user control.
i found several places speaking of this:
currently i've solution:
protected override bool processcmdkey(ref message msg, keys keydata) {     if (keydata == (keys)shortcut.ctrlv || keydata == (keys)shortcut.shiftins)     {         if (clipboard.containsimage())         {             return false;         }     }     return base.processcmdkey(ref msg, keydata); }   which works copy paste ctrl+c-ctrl+v, not contextual menu.
edit
i tried given proposition:
public class customrichbox : richtextbox {     private const int wm_paste = 0x0302;     protected override void wndproc(ref message m)     {         if (m.msg == wm_paste )         {             if (clipboard.containsimage())             {                 return;             }         }         base.wndproc(ref m);     } }   but when ctrl+v, don't receive message
sadly there no global paste-event, on can subscribe in wpf. maybe solution you:
hook on default "paste" event of winforms textbox control
this worked me.
Comments
Post a Comment