VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Invisible splitter bar with no extra controls. Resizes controls evenly with the resizing of the for

by Ken Henkes (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 7th March 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Invisible splitter bar with no extra controls. Resizes controls evenly with the resizing of the form. (Works best with Windows NT/2000 with

API Declarations



'Create a form with four (4) textboxes positioned as
'Text1 = top and left
'Text2 = top and right
'Text3 = bottom and left
'Text4 = bottom and right

'Paste the code in the module of Form1, execute the app and resize the form

Rate Invisible splitter bar with no extra controls. Resizes controls evenly with the resizing of the for



Option Explicit

Private CanHSize As Boolean 'Resize left and right controls
Private CanVSize As Boolean 'Resize top and bottom controls
Private HSizing As Boolean 'Resizing left and right
Private VSizing As Boolean 'Resizing top and bottom

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

    If CanHSize Then HSizing = True 'Ok to resize left and right controls
    If CanVSize Then VSizing = True 'Ok to resize top and bottom controls
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    If HSizing Then
        'Currently sizing left and right controls
        'Verify adequate left and right borders
        If X > 400 And X < Form1.Width - 520 Then
            Text1.Width = X - 20
            Text3.Width = Text1.Width
            Text2.Left = X + 20
            Text4.Left = Text2.Left
            Form_Resize
        End If
        Exit Sub
    End If
    
    If VSizing Then
        'Currently sizing top and bottom controls
        'Verify adequate top and bottom borders
        If Y > 400 And Y < Form1.Height - 820 Then
            Text1.Height = Y - 20
            Text2.Height = Text1.Height
            Text3.Top = Y + 20
            Text4.Top = Text3.Top
            Form_Resize
        End If
        Exit Sub
    End If
    
    'Check cursor position
    'If between left and right controls, we'll use vertical splitter
    'to resize left and right controls
    'If between top and bottom controls, we'll use horizontal splitter
    'to resize top and bottom controls
    If (X > Text1.Width And X < Text2.Left) And (Y < Text1.Height Or Y > Text3.Top) Then
        CanHSize = True
        CanVSize = False
        Form1.MousePointer = vbSizeWE
    ElseIf (Y > Text1.Height And Y < Text3.Top) And (X < Text1.Width Or X > Text2.Left) Then
        CanHSize = False
        CanVSize = True
        Form1.MousePointer = vbSizeNS
    Else
        CanHSize = False
        CanVSize = False
        Form1.MousePointer = vbDefault
    End If
End Sub


Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    HSizing = False
    VSizing = False
End Sub


Private Sub Form_Resize()
    'Resize controls to stretch with form
    On Local Error Resume Next
    'Resize controls on right to stretch with form
    Text2.Width = Form1.Width - Text2.Left - 120
    Text4.Width = Text2.Width
    
    'resize controls on bottom to stretch with form
    Text3.Height = Form1.Height - Text3.Top - 415
    Text4.Height = Text3.Height
    On Local Error GoTo 0
End Sub


Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    CanHSize = False
    CanVSize = False
    Form1.MousePointer = vbDefault
End Sub


Private Sub Text2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    CanHSize = False
    CanVSize = False
    Form1.MousePointer = vbDefault
End Sub


Private Sub Text3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    CanHSize = False
    CanVSize = False
    Form1.MousePointer = vbDefault
End Sub


Private Sub Text4_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    CanHSize = False
    CanVSize = False
    Form1.MousePointer = vbDefault
End Sub





Download this snippet    Add to My Saved Code

Invisible splitter bar with no extra controls. Resizes controls evenly with the resizing of the for Comments

No comments have been posted about Invisible splitter bar with no extra controls. Resizes controls evenly with the resizing of the for. Why not be the first to post a comment about Invisible splitter bar with no extra controls. Resizes controls evenly with the resizing of the for.

Post your comment

Subject:
Message:
0/1000 characters