我需要检测用户是否将剪贴板中的文本粘贴到ToolStripTextBox中.因此,我创建了一个继承自ToolStripTextBox的自定义控件.然后我想覆盖WndProc以捕获WM_PASTE消息,但我注意到没有WndProc可以覆盖.对于标准TextBox,所描述的方法工作正常.
有什么建议如何检测ToolStripTextBox上的剪贴板粘贴?
解决方法
似乎无法触及ToolStripTextBox中的WndProc.我出于好奇搜索了一下,然后遇到了答案 –
https://stackoverflow.com/a/4688745/168719
如果使用ToolStripControlHost不是一个选项,那么对于需要自定义处理WndProc的场景,还有其他聪明的解决方案:
http://bytes.com/topic/c-sharp/answers/279168-toolstriptextbox-right-click
Nicholas Paldino [.NET/C# MVP]
I just noticed that. In order to get around this,you can get the hosted TextBox by calling the TextBox property. Then,you should be able to create a class derived from NativeWindow which overrides the WndProc method to ignore the context menu message [or to intercept WM_PASTE,obvIoUsly…] When you get the textBox property,get the handle,and assign the handle to your overridden NativeWindow class.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。