让VB应用程序支持鼠标滚轮(3)
'判断坐标是否在Form1.grdDataGrid窗口内
If pt.x > .Left / Screen.TwipsPerPixelX And _
pt.x < (.Left + .Width) / Screen.TwipsPerPixelX And _
pt.y > .Top / Screen.TwipsPerPixelY And _
pt.y < (.Top + .Height) / Screen.TwipsPerPixelY Then
'滚动明细数据库
If wKeys = 16 Then
'滚动键按下,水平滚动grdDataGrid
If Sgn(wzDelta) = 1 Then
Form1.grdDataGrid.Scroll -1, 0
Else
Form1.grdDataGrid.Scroll 1, 0
End If
Else
'垂直滚动grdDataGrid
If Sgn(wzDelta) = 1 Then
Form1.grdDataGrid.Scroll 0, 0 - WHEEL_SCROLL_LINES
Else
Form1.grdDataGrid.Scroll 0, WHEEL_SCROLL_LINES
End If
End If
Else
'鼠标不在grdDataGrid区域,滚动主数据库
With Form1.datPrimaryRS.Recordset
If Sgn(wzDelta) = 1 Then
If .BOF = False Then
.MovePrevious
If .BOF = True Then
.MoveFirst
End If
End If
Else
If .EOF = False Then
.MoveNext
If .EOF = True Then
.MoveLast
End If
End If
End If
End With
End If
End With
Case Else
WindowProc = CallWindowProc(lpPrevWndProc, hw, _
uMsg, wParam, lParam)
End Select
End Function
Public Function HIWORD(LongIn As Long) As Integer
' 取出32位值的高16位
HIWORD = (LongIn And &HFFFF0000) &H10000
End Function
Public Function LOWORD(LongIn As Long) As Integer
' 取出32位值的低16位
LOWORD = LongIn And &HFFFF&
End Function
---- 7.该例在未安装任何附加鼠标驱动程序的Win2000/98环境,采用联想网络鼠标/罗技银貂,VB6.0下均通过。
---- 需要进一步说明的是,对用户界面鼠标滚轮的操作也要遵循公共用户界面操作习惯,不要随意定义一些怪异的操作,如果你编制的应用程序支持鼠标滚轮,请看看是否符合下面这些标准。
- 上一篇:VB中API的声明特殊问题
- 下一篇:VB中各种数据类型转换函数




