C#中实现屏蔽Ctrl+C的方法


本文实例讲述了C#实现屏蔽Ctrl+C的方法,代码简单易懂,具有一定的实用价值。分享给大家供大家参考。具体方法如下:

主要实现方法为重写 WndProc,代码如下:

public class MyTextBox : TextBox
{
  public const int WM_COPY = 0x301;
  public const int WM_CUT = 0x300;
  protected override void WndProc(ref Message m)
  {
    if (m.Msg == WM_COPY || m.Msg == WM_CUT) return;//不处理
    base.WndProc(ref m);
  }
}
Clipboard.SetDataObject(null);

希望本文所述C#实例对大家有所帮助。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3