找不到捕获这个事件的函数,还望专家不吝赐教,谢谢了。

热心网友

在VB6中用API函数GetCursorPos可获得鼠标的当前位置。用Timer控件捕获鼠标位置变化来实现。以下代码可获得鼠标滚动事件的发生。稍加以改变能判断鼠标滚轮滚动的方向。Option ExplicitPrivate Type PointAPI X As Long Y As LongEnd TypeDim MousePos As PointAPIPrivate Declare Function GetCursorPos Lib "user32" _(lpPoint As PointAPI) As LongDim OldX As LongDim OldY As LongDim NewX As LongDim NewY As LongDim UnitValue As LongDim UnitName As StringDim FormatStr As StringPrivate X0 As LongPrivate Y0 As LongConst FormatStr1 = "000000。00"Const FormatStr2 = "0000。0000"Private Sub Form_Load() UnitValue = 1440 UnitName = "英寸" FormatStr = FormatStr1 Timer1。Enabled = True GetCursorPos MousePos OldX = MousePos。X * Screen。TwipsPerPixelX OldY = MousePos。Y * Screen。TwipsPerPixelYEnd SubPrivate Sub Timer1_Timer() GetCursorPos MousePos NewX = MousePos。X * Screen。TwipsPerPixelX NewY = MousePos。Y * Screen。TwipsPerPixelY X0 = NewX - OldX Y0 = NewY - OldY If X0 0 Or Y0 0 Then Text1 = "鼠标滚动" Text1。BackColor = vbRed Else Text1 = "鼠标静止" Text1。BackColor = vbGreen End If OldX = NewX OldY = NewYEnd Sub。