|
Imports BV.Controls
Imports System.Drawing
Imports System.Windows.Forms
Imports System.ComponentModel
<CLSCompliant(True), DesignTimeVisible(True)> _
Public Class VScrollBar
Public Shadows Property Width() As Integer
Get
Return MyBase.Width
End Get
Set(ByVal value As Integer)
If value <= 50 Then
If value >= 20 Then
MyBase.Width = value
Else
MyBase.Width = 20
End If
Else
MyBase.Width = 50
End If
End Set
End Property
Private Sub VScrollBar_Click(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
If e.Y > Me.btnMiddle.Location.Y Then
Me.Increment()
Else
Me.Decrement()
End If
SetMidButtonLocation()
End Sub
Private Sub btnUp_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles btnUp.Click
Me.SmallDecrement()
SetMidButtonLocation()
End Sub
Private intMidBtnLoc As Point
Private Sub btnMiddle_Down(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles btnMiddle.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
intMidBtnLoc.Y = e.Y
intMidBtnLoc.X = e.X
End If
End Sub
Private Sub btnMiddle_Move(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles btnMiddle.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
Dim y, p As Integer
p = Me.intValue
If (Me.btnMiddle.Location.Y + (e.Y - Me.intMidBtnLoc.Y)) < (Me.ScrollAreaRange) Then
If (Me.btnMiddle.Location.Y + (e.Y - Me.intMidBtnLoc.Y)) > Me.btnUp.Height Then
y = Me.btnMiddle.Location.Y + (e.Y - Me.intMidBtnLoc.Y)
Else
y = Me.btnUp.Height
End If
Else
y = Me.ScrollAreaRange
End If
Me.btnMiddle.Location = New Point(0, y)
Me.intValue = Me.intMax * (y - Me.btnUp.Height) / (Me.Height - Me.btnUp.Height - Me.btnDown.Height)
If y = Me.intMin Then
MyBase.OnScroll(New ScrollEventArgs(ScrollEventType.First, Me.intValue, p, ScrollOrientation.VerticalScroll))
ElseIf y = Me.intMax Then
MyBase.OnScroll(New ScrollEventArgs(ScrollEventType.Last, Me.intValue, p, ScrollOrientation.VerticalScroll))
ElseIf Me.intValue > p Then
MyBase.OnScroll(New ScrollEventArgs(ScrollEventType.LargeIncrement, Me.intValue, p, ScrollOrientation.VerticalScroll))
Else
MyBase.OnScroll(New ScrollEventArgs(ScrollEventType.LargeDecrement, Me.intValue, p, ScrollOrientation.VerticalScroll))
End If
' SetMidButtonLocation()
End If
End Sub
Private Sub btnDown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDown.Click
Me.SmallIncrement()
SetMidButtonLocation()
End Sub
Protected Overrides ReadOnly Property ScrollAreaRange() As Integer
Get
Return (Me.Height - Me.btnUp.Height - Me.btnDown.Height)
End Get
End Property
Protected Overrides Sub SetMidButtonLocation()
Dim y As Integer
y = Me.btnUp.Height + Me.intValue * (Me.ScrollAreaRange - Me.btnMiddle.Height) / Me.intMax
Me.btnMiddle.Location = New Point(0, y)
End Sub
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.