Results 1 to 1 of 1

Thread: [VB 6] Scroll bars - More than meets the eye

  1. #1

    Thread Starter
    Addicted Member cheesebrother's Avatar
    Join Date
    Jul 2011
    Posts
    153

    [VB 6] Scroll bars - More than meets the eye

    Hi everyone, i'm trying to make a scroll bar usercontrol and... i also happen to have a headache. When i first started to make it I though it would be easy but it turned out not to be. So what i'm trying to make is my own scroll bar. My primary reason is so that i can draw everything myself. This is the code i am using (as is obvious only the bear essentials are being drawn, beautiful looks will follow ):

    Code:
    
    Rem This example doesn't really work.  Download the attachment to have the real thing.
    
    Option Explicit
    
    Private Sub scroll_Change()
      Draw
    End Sub
    Private Sub scroll_Scroll()
      Draw
    End Sub
    
    Private Sub UserControl_Resize()
        scroll.Move 0, 0, UserControl.ScaleWidth, UserControl.ScaleHeight
        picD.Move 0, 17, UserControl.ScaleWidth / 2, UserControl.ScaleHeight - 34
        Draw
    End Sub
    
    Sub Draw()
        Cls
        
        On Error Resume Next
        
        Dim Value, sHeight
        sHeight = picD.Height / (scroll.Max / scroll.LargeChange)
        Value = scroll.Value / (scroll.Max / picD.Height)
    
        Debug.Print scroll.Value
        
        Rem Draw Bar
        picD.Line (0, 0)-(UserControl.ScaleWidth, UserControl.ScaleHeight), RGB(200, 200, 200), BF
        
        picD.Line (0, Value - sHeight)-(picD.Width - 1, Value), vbRed, BF
        picD.Line (0, Value - sHeight)-(picD.Width - 1, Value), vbBlack, B
    End Sub
    
    Public Property Get SmallChange() As Integer
        SmallChange = scroll.SmallChange
        Draw
    End Property
    
    Public Property Let SmallChange(newsc As Integer)
        If newsc < 1 Then newsc = 1
        scroll.SmallChange = newsc
        Draw
    End Property
    
    Public Property Get LargeChange() As Integer
        LargeChange = scroll.LargeChange
        Draw
    End Property
    
    Public Property Let LargeChange(newlc As Integer)
        If newlc < 1 Then newlc = 1
        scroll.LargeChange = newlc
        Draw
    End Property
    
    Public Property Get Min() As Integer
        Min = scroll.Min
        Draw
    End Property
    
    Public Property Let Min(newmin As Integer)
        scroll.Min = newmin
        Draw
    End Property
    
    Public Property Get Max() As Integer
        Max = scroll.Max
    End Property
    
    Public Property Let Max(newmax As Integer)
        scroll.Max = newmax
        Draw
    End Property
    
    Public Property Get SValue() As Integer
        SValue = scroll.Value
    End Property
    
    Public Property Let SValue(newval As Integer)
        scroll.Value = newval
        PropertyChanged "SValue"
        Draw
    End Property
    
    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
        scroll.SmallChange = PropBag.ReadProperty("SmallChange", 1)
        scroll.LargeChange = PropBag.ReadProperty("LargeChange", 1)
        scroll.Min = PropBag.ReadProperty("Min", 1)
        scroll.Max = PropBag.ReadProperty("Max", 10)
        scroll.Value = PropBag.ReadProperty("SValue", 1)
        
        Draw
    End Sub
    
    Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
        PropBag.WriteProperty "SmallChange", scroll.SmallChange, 1
        PropBag.WriteProperty "LargeChange", scroll.LargeChange, 1
        PropBag.WriteProperty "Min", scroll.Min, 1
        PropBag.WriteProperty "Max", scroll.Max, 10
        PropBag.WriteProperty "SValue", scroll.Value, 1
        
        Draw
    End Sub
    I really need help for this. I've made it so that my scroll bar and the default vb scrollbar are side by side. It's almost perfect on settings: Min-1, Max-10, Small Change-1, Large Change-1. If you change about any of them(primarily Large Change) my scroll bar becomes radically different from vb's. Right now this usercontrol is working off of vb's scroll bar but after i get it to draw properly off of a value i'll make it independent.
    Attached Files Attached Files
    Hooked for good.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width