middle-button scrolly thing in textbox(文本框中的中间按钮滚动的东西)
问题描述
我的应用程序中有一个多行文本框,当我中键单击向上或向下滚动时,它不起作用.
i have a multiline textbox in my app and when i middle-click to scroll up or down, it doesn't work.
它在记事本中有效,但在我的文本框中无效.有人知道为什么吗?或者,是否可以在单击中间按钮时以编程方式开始向所需方向滚动?
It works in Notepad, but not in my textbox. Does anybody know why? or, if it is possible to programatically begin scrolling in the desired direction when the middle-button's clicked?
推荐答案
要让鼠标滚轮滚动工作,请创建您自己的继承 TextBox 的自定义 TextBox 类.
To get the mouse wheel scroll thing to work, make your own custom TextBox class that inherits TextBox.
重写 WndProc 方法.
Override the WndProc method.
查看消息类型.
对于消息类型 0x207 (WM_MBUTTONDOWN),调用 DefWndProc(ref m);对于任何其他消息类型,调用 base.WndProc(ref m);
For Message type 0x207 (WM_MBUTTONDOWN), call DefWndProc(ref m); For any other message type, call base.WndProc(ref m);
然后你的文本框会有中间按钮滚动.
Then your text box will have middle button scroll.
通常 Windows.Forms 会覆盖文本框的内置中间按钮功能,因此控件可以在中间按钮上有一个 MouseDown 事件,但这也会禁用固有的滚动功能.返回调用默认窗口处理程序,文本框恢复其滚动功能.
Normally Windows.Forms overrides the built-in middle button feature of the textbox so the control can have a MouseDown event on the middle button, but that also disables the innate scroll feature. Go back to calling the default window handler, and the textbox gets its scroll feature back.
这篇关于文本框中的中间按钮滚动的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:文本框中的中间按钮滚动的东西
基础教程推荐
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
