要想使vb响应滚轮有两个方法,一是使用消息钩子,第二种方法是使用combobox控件来响应,这个比较简单。下面简单做个,你做参考(新建一工程,添加一个combobox控件,一个picturebox控件,拷贝下列代码,即可见到滚轮效果)
Dim startPos As Long
'起始位置
Private Sub DrawXY()
'画坐标
Dim s As Integer, i As Integer
s = Picture1.ScaleWidth / 10
Picture1.Cls
For i = 0 To 9
Picture1.Line (i * s + startPos + 5, 5)-(i * s + startPos + 5, Picture1.ScaleHeight - 20), vbBlue
Picture1.CurrentX = i * s + startPos - 3: Picture1.CurrentY = Picture1.ScaleHeight - 15: Picture1.Print i
Next
Picture1.Refresh
End Sub
Private Sub Combo1_Click()
'响应滚轮
startPos = startPos + Val(Combo1) * 5
DrawXY
Combo1.ListIndex = 1
Combo1.SetFocus
End Sub
Private Sub Form_Load()
Combo1.AddItem -1
Combo1.AddItem 0
Combo1.AddItem 1
'响应鼠标滚轮控件付初值
Combo1 = 0
Me.ScaleMode = 3
Picture1.ScaleMode = 3
startPos = 0
DrawXY
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Combo1.SetFocus
End Sub