在文本中间按钮scrolly事 [英] middle-button scrolly thing in textbox

查看:110
本文介绍了在文本中间按钮scrolly事的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序多行文本框,当我单击鼠标中键向上或向下滚动,这是行不通的。

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米);
。对于任何其他消息类型,请拨打base.WndProc(REF米);

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.

这篇关于在文本中间按钮scrolly事的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆