Private Const SPLITTER_WIDTH = 40
' The percentage occupied by the PictureBox.
Private Percentage1 As Single
' True when we are dragging the splitter.
Private Dragging As Boolean
' Arrange the controls on the form.
Private Sub ArrangeControls()
Dim wid1 As Single
Dim wid2 As Single
' Don't bother if we're iconized.
If WindowState = vbMinimized Then Exit Sub
wid1 = (ScaleWidth - SPLITTER_WIDTH) * Percentage1
Picture1.Move 0, 0, wid1, ScaleHeight
wid2 = (ScaleWidth - SPLITTER_WIDTH) - wid1
Picture2.Move wid1 + SPLITTER_WIDTH, 0, wid2, _
ScaleHeight
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As _
Integer, X As Single, Y As Single)
Dragging = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As _
Integer, X As Single, Y As Single)
If Not Dragging Then Exit Sub
Percentage1 = X / ScaleWidth
If Percentage1 < 0 Then Percentage1 = 0
If Percentage1 > 1 Then Percentage1 = 1
ArrangeControls
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As _
Integer, X As Single, Y As Single)
Dragging = False
End Sub
|