VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Fun with MouseWheel

by vViktor (7 Submissions)
Category: Miscellaneous
Compatability: VB Script
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (14 Votes)

Just intercepting MouseWheel event with API. Make an empty project (standard exe) and paste code.

Rate Fun with MouseWheel

Private Const PM_REMOVE = &H1
Private Type POINTAPI
 x As Long
 y As Long
End Type
Private Type Msg
 hWnd As Long
 Message As Long
 wParam As Long
 lParam As Long
 time As Long
 pt As POINTAPI
End Type
Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
Private Declare Function WaitMessage Lib "user32" () As Long
Private bCancel As Boolean
Private Const WM_MOUSEWHEEL = 522
Private Sub ProcessMessages()
 Dim Message As Msg
 Do While Not bCancel
  WaitMessage 'Wait For message and...
  If PeekMessage(Message, Me.hWnd, WM_MOUSEWHEEL, WM_MOUSEWHEEL, PM_REMOVE) Then '...when the mousewheel is used...
   If Message.wParam < 0 Then '...scroll up...
    Me.Top = Me.Top + 240
   Else '... or scroll down
    Me.Top = Me.Top - 240
   End If
  End If
  DoEvents
 Loop
End Sub
Private Sub Form_Load()
 Me.AutoRedraw = True
 Me.Print "Please use now mouse wheel to move this form."
 Me.Show
 ProcessMessages
End Sub
Private Sub Form_Unload(Cancel As Integer)
 bCancel = True
End Sub

Download this snippet    Add to My Saved Code

Fun with MouseWheel Comments

No comments have been posted about Fun with MouseWheel. Why not be the first to post a comment about Fun with MouseWheel.

Post your comment

Subject:
Message:
0/1000 characters