Private WithEvents IC As MSINKAUTLib.InkCollector
Public mycontrol As Control
Dim handle As Long
Private Sub UserForm_Activate()
ListBox1.List = Evaluate("row(1:30)")
ComboBox1.List = Evaluate("row(1:30)")
End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'stop the scrolling when you leaves control
' destruction of object IC
Set IC = Nothing
End Sub
'I CAN TAKE A FRAME1 HANDLE FOR ALL CONTROLS
'THE HANDLE IS JUST A REFERENCE FOR THE IC OBJECT
'handle = Frame1.[_GethWnd]
Private Sub ComboBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
handle = Frame1.[_GethWnd] 'it take a handle of frame because combobox has not disponible handle
Set mycontrol = ComboBox1
mycontrol.SetFocus
SetupMouseWheel
End Sub
Private Sub Frame1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
handle = Frame1.[_GethWnd]
Set mycontrol = Frame1
mycontrol.SetFocus
SetupMouseWheel
End Sub
Private Sub ListBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
handle = Frame1.[_GethWnd] 'handle = ListBox1.[_GethWnd]' this two can work
Set mycontrol = ListBox1
mycontrol.SetFocus
SetupMouseWheel
End Sub
Private Sub SetupMouseWheel()
Set IC = New MSINKAUTLib.InkCollector
With IC
.hwnd = handle ' The InkCollector requires an 'anchor' hWnd
.SetEventInterest ICEI_MouseWheel, True ' This sets event that you want to listen for
.MousePointer = IMP_Arrow ' If this is not set, the mouse pointer disappears
.DynamicRendering = False ' I suggest turning this off
.DefaultDrawingAttributes.Transparency = 255 ' And making the drawing fullly transparent
.Enabled = True ' This must be set last
End With
End Sub
Private Sub IC_MouseWheel(ByVal Button As MSINKAUTLib.InkMouseButton, ByVal Shift As MSINKAUTLib.InkShiftKeyModifierFlags, ByVal Delta As Long, ByVal X As Long, ByVal Y As Long, Cancel As Boolean)
Select Case True
Case TypeOf mycontrol Is Frame
If Delta > 0 Then
Frame1.ScrollTop = Application.Max(0, Frame1.ScrollTop - 5)
Else
Frame1.ScrollTop = Application.Min(Frame1.ScrollHeight, Frame1.ScrollTop + 5)
End If
Case TypeName(mycontrol) = "ListBox"
If Delta > 0 Then
ListBox1.TopIndex = Application.Max(ListBox1.TopIndex - 1, 0)
Else
ListBox1.TopIndex = Application.Min(ListBox1.TopIndex + 1, ListBox1.ListCount - 1)
End If
Case TypeName(mycontrol) = "ComboBox"
If Delta > 0 Then
ComboBox1.TopIndex = Application.Max(ComboBox1.TopIndex - 1, 0)
Else
ComboBox1.TopIndex = Application.Min(ComboBox1.TopIndex + 1, ComboBox1.ListCount - 1)
End If
End Select
End Sub