Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Splitter, horizontal (form-based)


'two pictureboxes side by side, separated by gap (SPLITTER_Width)
'Not including Is limiting MouseMove To when cursor is in specific area of the form

Private Const SPLITTER_Width = 50
Private XPercent As Single

Private Sub Form_MouseMove(Button As Integer , Shift As Integer , X As Single , Y As Single )
    If Button = vbLeftButton Then
       XPercent = X / ScaleWidth
        If XPercent < 0 Then XPercent = 0
        If XPercent > 1 Then XPercent = 1
       ArrangeControls
    End If
End Sub

Private Sub ArrangeControls()
Dim width1 As Single     'picture1 Width
Dim width2 As Single     'picture2 Width
    If WindowState = vbMinimized Then Exit Sub    'do nothing if minimized
   width1 = (ScaleWidth - SPLITTER_Width) * XPercent
   Picture1.Move 0, 0, width1, ScaleHeight
   width2 = (ScaleWidth - SPLITTER_Width) - width1
   Picture2.Move width1 + SPLITTER_Width, 0, width2, ScaleHeight
End Sub