|
-
Apr 26th, 2006, 04:14 PM
#1
New Member
Re: VB6 - MouseWheel with Any Control (originally just MSFlexGrid Scrolling)
Great work but...
I do not like individually testing for min and max for each control, so I extracted those lines into a function in the module:
Public Function MouseWheelChange(CurrentValue As Variant, DeltaValue As Variant, MinValue As Variant, MaxValue As Variant) As Variant
Dim newvalue As Variant
newvalue = CurrentValue + DeltaValue
If newvalue < MinValue Then
newvalue = MinValue
ElseIf newvalue > MaxValue Then
newvalue = MaxValue
End If
MouseWheelChange = newvalue
End Function
The MouseWheel() sub now looks like:
Public Sub MouseWheel(ByVal MouseKeys As Long, ByVal Rotation As Long, ByVal Xpos As Long, ByVal Ypos As Long)
On Error Resume Next
If TypeOf Me.ActiveControl Is VScrollBar Then
With VScroll1
.Value = MouseWheelChange(.Value, Sgn(Rotation) * .LargeChange, .Min, .Max)
End With
ElseIf TypeOf Me.ActiveControl Is TextBox Then
Text1.Text = MouseWheelChange(Text1.Text, Rotation, -1000, 1000)
End If
End Sub
Just my 2 cents.
-
Jun 22nd, 2006, 07:09 PM
#2
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|