Making the mouse scroll in the IDE is easy, and has already been covered. If you want your PROGRAMS to utilize the scroll wheel, make a new .bas module and insert this code:
Private Declare Function CallWindowProcA& Lib "user32.dll" (ByVal lpPrevWndFunc&, ByVal hWnd&, ByVal Msg&, ByVal Wparam&, ByVal Lparam&)
Private Declare Function SetWindowLongA& Lib "user32.dll" (ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&)
Dim LocalPrevWndProc&
Private Function WindowProc&(ByVal Lwnd&, ByVal Lmsg&, ByVal Wparam&, ByVal Lparam&)
If Lmsg& = &H20A Then
MouseKeys& = Wparam& And 65535
rotation& = Wparam& / 65536
Xpos& = Lparam& And 65535
Ypos& = Lparam& / 65536
GetForm(Lwnd&).MouseWheel MouseKeys&, rotation&, Xpos&, Ypos&
End If
WindowProc& = CallWindowProcA&(LocalPrevWndProc&, Lwnd&, Lmsg&, Wparam&, Lparam&)
End Function
Public Sub WheelHook(PassedForm As Form)
On Error Resume Next
LocalPrevWndProc& = SetWindowLongA&(PassedForm.hWnd, -4, AddressOf WindowProc&)
End Sub
Public Sub WheelUnHook(PassedForm As Form)
On Error Resume Next
WorkFlag& = SetWindowLongA&(PassedForm.hWnd, -4, LocalPrevWndProc&)
End Sub
Private Function GetForm(ByVal hWnd&) As Form
For Each GetForm In Forms
If GetForm.hWnd = hWnd& Then Exit Function
Next GetForm
Set GetForm = Nothing
End Function
Public Sub FlexGridScroll(ByRef fg As MSFlexGrid, ByVal MouseKeys&, ByVal rotation&, ByVal Xpos&, ByVal Ypos&)
On Error Resume Next
With fg
Lstep! = 3
If rotation& > 0 Then
NewValue& = .TopRow - Lstep!
If NewValue& < 1 Then
NewValue& = 1
End If
Else
NewValue& = .TopRow + Lstep!
If NewValue& > .Rows - 1 Then
NewValue& = .Rows - 1
End If
End If
.TopRow = NewValue&
End With
End Sub
This in any form's Form_Load event, just use:
Call WheelHook(Me)
Then for instance, to make a FlexGrid scroll, put this subroutine in the form:
Public Sub MouseWheel(ByVal MouseKeys&, ByVal rotation&, ByVal Xpos&, ByVal Ypos&)
If TypeOf Me.ActiveControl Is MSFlexGrid Then FlexGridScroll Me.ActiveControl, MouseKeys&, rotation&, Xpos&, Ypos&
End Sub