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.
这篇关于文本框中的中间按钮滚动的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:文本框中的中间按钮滚动的东西


基础教程推荐
- c# Math.Sqrt 实现 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01