Results 1 to 3 of 3

Thread: Splitter;- or Separator lines Control

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2017
    Location
    South Africa (in the middle)
    Posts
    160

    Splitter;- or Separator lines Control

    I get tired of making splitter lines for programs, therefore I decided to make a control.

    Very basic as it's not really my field of expertise, but something that I can use horizontal as well as vertical. What I mean is this:

    Name:  Seperator.png
Views: 893
Size:  2.3 KB

    This is what's on the form:
    Name:  Image 045.png
Views: 883
Size:  4.5 KB
    Name:  Image 046.png
Views: 799
Size:  4.5 KB

    The code is:

    Code:
    'Default Property Values:
    Const m_def_DarkColour = &H0&
    Const m_def_LightColour = &HC0C0C0
    Const m_def_Horizonthal = -1
    'Property Variables:
    Dim m_DarkColour As OLE_COLOR
    Dim m_LightColour As OLE_COLOR
    Dim m_Horizonthal As Boolean
    
    Private Sub UserControl_Resize()
       
       If Horizonthal = True Then
          Line1.X1 = 0
          Line1.X2 = UserControl.Width
          Line1.Y1 = 0
          Line1.Y2 = 0
          
          Line2.X1 = 0
          Line2.X2 = UserControl.Width
          Line2.Y1 = 20
          Line2.Y2 = 20
          UserControl.Height = 40
       ElseIf Horizonthal = False Then
          Line1.X1 = 0
          Line1.X2 = 0
          Line1.Y1 = 0
          Line1.Y2 = UserControl.Height
          
          Line2.X1 = 20
          Line2.X2 = 20
          Line2.Y1 = 0
          Line2.Y2 = UserControl.Height
          UserControl.Width = 40
       End If
       
    End Sub
    
    Public Property Get Enabled() As Boolean
       Enabled = UserControl.Enabled
    End Property
    
    Public Property Let Enabled(ByVal New_Enabled As Boolean)
       UserControl.Enabled() = New_Enabled
       PropertyChanged "Enabled"
    End Property
    
    'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    'MemberInfo=10,0,0,&H00000000&
    Public Property Get DarkColour() As OLE_COLOR
       DarkColour = m_DarkColour
    End Property
    
    Public Property Let DarkColour(ByVal New_DarkColour As OLE_COLOR)
       m_DarkColour = New_DarkColour
       PropertyChanged "DarkColour"
       Line1.BorderColor = m_DarkColour
    End Property
    
    'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    'MemberInfo=10,0,0,&H00C0C0C0&
    Public Property Get LightColour() As OLE_COLOR
       LightColour = m_LightColour
    End Property
    
    Public Property Let LightColour(ByVal New_LightColour As OLE_COLOR)
       m_LightColour = New_LightColour
       PropertyChanged "LightColour"
       Line2.BorderColor = m_LightColour
    End Property
    
    'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    'MemberInfo=0,0,0,-1
    Public Property Get Horizonthal() As Boolean
       Horizonthal = m_Horizonthal
    End Property
    
    Public Property Let Horizonthal(ByVal New_Horizonthal As Boolean)
       m_Horizonthal = New_Horizonthal
       PropertyChanged "Horizonthal"
    End Property
    
    'Initialize Properties for User Control
    Private Sub UserControl_InitProperties()
       m_DarkColour = m_def_DarkColour
       m_LightColour = m_def_LightColour
       m_Horizonthal = m_def_Horizonthal
    End Sub
    
    'Load property values from storage
    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    
       UserControl.Enabled = PropBag.ReadProperty("Enabled", True)
       m_DarkColour = PropBag.ReadProperty("DarkColour", m_def_DarkColour)
       m_LightColour = PropBag.ReadProperty("LightColour", m_def_LightColour)
       m_Horizonthal = PropBag.ReadProperty("Horizonthal", m_def_Horizonthal)
    End Sub
    
    'Write property values to storage
    Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    
       Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True)
       Call PropBag.WriteProperty("DarkColour", m_DarkColour, m_def_DarkColour)
       Call PropBag.WriteProperty("LightColour", m_LightColour, m_def_LightColour)
       Call PropBag.WriteProperty("Horizonthal", m_Horizonthal, m_def_Horizonthal)
    End Sub
    Project: Seperator.zip
    Last edited by Inside; Aug 26th, 2017 at 05:02 AM. Reason: Adding Project
    Programmers are very patient people....while programming....but don't expect them to be patient all the time

  2. #2
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    679

    Re: Splitter;- or Separator lines Control

    so easy usercontrol .but have a bug .

    can set LightColour and DarkColour In the design phase ,but if run .no change

    now fixed:
    Code:
    Private Sub UserControl_Resize()
       
       If Horizonthal = True Then
          Line1.X1 = 0
          Line1.X2 = UserControl.Width
          Line1.Y1 = 0
          Line1.Y2 = 0
          
          Line2.X1 = 0
          Line2.X2 = UserControl.Width
          Line2.Y1 = 20
          Line2.Y2 = 20
          UserControl.Height = 40
       ElseIf Horizonthal = False Then
          Line1.X1 = 0
          Line1.X2 = 0
          Line1.Y1 = 0
          Line1.Y2 = UserControl.Height
          
          Line2.X1 = 20
          Line2.X2 = 20
          Line2.Y1 = 0
          Line2.Y2 = UserControl.Height
          UserControl.Width = 40
       End If
       Line2.BorderColor = m_LightColour
        Line1.BorderColor = m_DarkColour
    End Sub
    Last edited by xxdoc123; Aug 26th, 2017 at 02:42 AM.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2017
    Location
    South Africa (in the middle)
    Posts
    160

    Re: Splitter;- or Separator lines Control

    Quote Originally Posted by xxdoc123 View Post
    so easy usercontrol .but have a bug .

    can set LightColour and DarkColour In the design phase ,but if run .no change
    Sometimes it work and sometimes it don't. I do not really have a problem with that. I use only the set colours.

    I'm not an expert on (almost) anything
    Programmers are very patient people....while programming....but don't expect them to be patient all the time

Tags for this Thread

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