以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 如何用鼠标中键的滚动来控制容易的滚动条 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=78485) |
-- 作者:blackzhu -- 发布时间:2015/12/10 8:55:00 -- 如何用鼠标中键的滚动来控制容易的滚动条 我在网上找到一个代码,是C#的,我转换后放到MouseDown 中,但是无效. If e.Button = MouseButtons.middle Then Dim mousePoint As New Point(e.X, e.Y) 换算成相对本窗体的位置 mousePoint.Offset(e.Form.BaseForm.Location.X, e.Form.BaseForm.Location.Y) 判断是否在panel内 If e.Sender.BaseControl.RectangleToScreen(e.Sender.BaseControl.DisplayRectangle).Contains(mousePoint) Then 滚动 e.Sender.BaseControl.AutoScrollPosition = New Point(0, e.Sender.BaseControl.VerticalScroll.Value - e.Delta) End If End If 我还想将此代码放入全局: \'\'\' <summary> \'\'\' 滚动方法 \'\'\' </summary> \'\'\' <param name="sender"></param> \'\'\' <param name="e"></param> Public Sub FormSample_MouseWheel(sender As Object, e As MouseEventArgs)
\'获取光标位置
Dim mousePoint As New Point(e.X, e.Y)
\'换算成相对本窗体的位置
mousePoint.Offset(Me.Location.X, Me.Location.Y)
\'判断是否在panel内
If panel_content.RectangleToScreen(panel_content.DisplayRectangle).Contains(mousePoint) Then
\'滚动
panel_content.AutoScrollPosition = New Point(0, panel_content.VerticalScroll.Value - e.Delta)
End If End Sub 但是 e As MouseEventArgs) 通不过!
[此贴子已经被作者于2015/12/10 8:55:41编辑过]
|
-- 作者:Hyphen -- 发布时间:2015/12/10 9:01:00 -- e As System.Windows.Forms.MouseEventArgs 全局代码不能用Me,改成通过sender来获取窗体或者panel的坐标
|
-- 作者:大红袍 -- 发布时间:2015/12/10 9:16:00 -- 汗,肯定要绑定 MouseWheel 事件啊
http://foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=55394&replyID=368746&skin=1
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=41235&skin=0
|
-- 作者:blackzhu -- 发布时间:2015/12/10 9:43:00 -- 以下是引用Hyphen在2015/12/10 9:01:00的发言:
e As System.Windows.Forms.MouseEventArgs 全局代码不能用Me,改成通过sender来获取窗体或者panel的坐标 问题就是出在这边,底层的东西 我忘了!
|
-- 作者:blackzhu -- 发布时间:2015/12/10 9:55:00 -- 搞定谢谢 |