gpt4 book ai didi

c# - 在 ToolStripTextBox (C#) 中检测来自剪贴板的粘贴

转载 作者:行者123 更新时间:2023-11-30 12:32:10 25 4
gpt4 key购买 nike

我需要检测用户是否将剪贴板中的文本粘贴到 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.

关于c# - 在 ToolStripTextBox (C#) 中检测来自剪贴板的粘贴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11846130/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com