找不到捕獲這個事件的函數,還望專家不吝賜教,謝謝了。
熱心網友
在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。