how to "split screen" 
Author Message
 how to "split screen"

Example of what I want to do,  Netscape news reader has 3 windows,
with sliding border lines in between that are movable.  Is there
any way to do this on VB5 with any sort of add on OCX's?

John Watson



Thu, 21 Oct 1999 03:00:00 GMT  
 how to "split screen"

Quote:

> Example of what I want to do,  Netscape news reader has 3 windows,
> with sliding border lines in between that are movable.  Is there
> any way to do this on VB5 with any sort of add on OCX's?

> John Watson

John,
I downloaded this example from somewhere, but I can't remember where.
Anyway, it works in VB 4

'Start a new project, and on the form place a list box (ListLeft), a
text box
'(TextRight), and a picturebox (Splitter). Place the following code into
the
'general declarations area of the form to contain the splitter bar:

Option Explicit

'variable to hold the width of the splitter bar
Private Const SPLT_WDTH As Integer = 30

'variable to hold the last-sized position
Private currSplitPosX As Long

'variable to hold the horizontal & vertical
'offsets of the 2 controls
Dim CTRL_OFFSET As Integer

'variable to hold the Splitter bar color
Dim SPLT_COLOR As Long

Private Sub Form_Load()
    'set the startup variables
    CTRL_OFFSET = 50
    SPLT_COLOR = &H808080

    'set the current splitter bar position to an arbitrary value that
will always
    'be outside the possible range. This allows us to check for movement
of the
    'splitter bar in subsequent mousexxx subs
    currSplitPosX = &H7FFFFFFF

    ListLeft.AddItem "Left list Item 1"
    ListLeft.AddItem "Left list Item 2"
    ListLeft.AddItem "Left list Item 3"
    ListLeft.AddItem "Left list Item 4"
    ListLeft.AddItem "Left list Item 5"

    TextRight = "This code demonstrates how to implement a splitter bar
in a "
    TextRight = TextRight & "Visual Basic project." & vbCrLf & vbCrLf
    TextRight = TextRight & "It's actions are controlled through "
    TextRight = TextRight & "the MouseDown, MouseMove and MouseUp subs
of the "
    TextRight = TextRight & "Splitter PictureBox, and the "
    TextRight = TextRight & "Resize event of the form."
End Sub

Private Sub Form_Resize()
    Dim x1 As Integer
    Dim x2 As Integer
    Dim height1 As Integer
    Dim width1 As Integer
    Dim width2 As Integer

    On Error Resume Next
    'set the height of the controls
    height1 = ScaleHeight - (CTRL_OFFSET * 2)
    width1 = ListLeft.Width
    x1 = CTRL_OFFSET
    x2 = x1 + width1 + SPLT_WDTH - 1
    width2 = ScaleWidth - x2 - CTRL_OFFSET

    'move the left list
    ListLeft.Move x1 - 1, CTRL_OFFSET, width1, height1

    'move the right textbox
    TextRight.Move x2, CTRL_OFFSET, width2 + 1, ListLeft.Height

    'move the splitter bar
    Splitter.Move x1 + ListLeft.Width - 1, CTRL_OFFSET, SPLT_WDTH,
height1

End Sub

Private Sub Splitter_MouseDown(Button As Integer, Shift As Integer, x As
Single, y As Single)
    If Button = vbLeftButton Then
        'change the splitter color
        Splitter.BackColor = SPLT_COLOR
        'set the current position to x
        currSplitPosX = CLng(x)
    Else
        'not the left button, so...if the current position<> default,
        'cause a mouseup
        If currSplitPosX <> &H7FFFFFFF Then
            splitter_MouseUp Button, Shift, x, y
        End If
        'set the current position to the default value
        currSplitPosX = &H7FFFFFFF
    End If

End Sub

Private Sub splitter_MouseMove(Button As Integer, Shift As Integer, x As
Single, y As Single)
    'if the splitter has been moved...
    If currSplitPosX& <> &H7FFFFFFF Then

       'if the current position <> default, reposition the splitter and
       'set this as the current value
       If CLng(x) <> currSplitPosX Then
          Splitter.Move Splitter.Left + x, CTRL_OFFSET, SPLT_WDTH, _
                        ScaleHeight - (CTRL_OFFSET * 2)
          currSplitPosX = CLng(x)
       End If
    End If

End Sub

Private Sub splitter_MouseUp(Button As Integer, Shift As Integer, x As
Single, y As Single)
    'if the splitter has been moved...
    If currSplitPosX <> &H7FFFFFFF Then
        'if the current position <> the last position do a
        'final move of the splitter
        If CLng(x) <> currSplitPosX Then
            Splitter.Move Splitter.Left + x, CTRL_OFFSET, SPLT_WDTH, _
                          ScaleHeight - (CTRL_OFFSET * 2)
        End If

        'call this the default position
        currSplitPosX = &H7FFFFFFF

       'restore the normal splitter colour
        Splitter.BackColor = &H8000000F

        'and check for valid sizings. Either enforce the default minimum
&
        'maximum widths for the left list, or, if within range, set the
width.
        If Splitter.Left > ListLeft.Left + 60 _
        And Splitter.Left < ScaleWidth - CTRL_OFFSET - 180 Then 'the
pane is within range
                  ListLeft.Width = Splitter.Left - ListLeft.Left
        ElseIf Splitter.Left <= ListLeft.Left + 60 Then 'the pane is too
small
                  ListLeft.Width = 60
        Else 'the pane is too wide
                  ListLeft.Width = ScaleWidth - (CTRL_OFFSET * 2) - 180
        End If

        'reposition both lists, and the splitter bar
        Form_Resize

    End If

End Sub

'Select the splitter bar on the form, and change it's icon property
'to 9 - Size W E. Then Run the project. When the mouse passes over
'the splitter bar, it will change into a left-right arrow. Click &
'drag to a new position, and release.



Thu, 21 Oct 1999 03:00:00 GMT  
 how to "split screen"

: Example of what I want to do,  Netscape news reader has 3 windows,
: with sliding border lines in between that are movable.  Is there
: any way to do this on VB5 with any sort of add on OCX's?

: John Watson
--



Fri, 22 Oct 1999 03:00:00 GMT  
 how to "split screen"

On Sun, 04 May 1997 19:04:18 -0400, John Watson

Quote:

>Example of what I want to do,  Netscape news reader has 3 windows,
>with sliding border lines in between that are movable.  Is there
>any way to do this on VB5 with any sort of add on OCX's?

What about a MDI-form with 3 (or more) child-forms?? You have to code
in the Resize-events the place of the childs within the MDI-form.

gr. walther

----- it's the line -----
Walther Musch; Tilburg University
http://pi1438.kub.nl:2080/VisualBasicSource/



Sat, 23 Oct 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to "split screen"

2. Splitting arrays. X=split(split(y,"~"),"*") How Do i do this

3. split by "\n"

4. Visual Basic "split"?

5. "Splitting" data

6. Counterpart of "Split"?

7. Split binary files by a "string"

8. Implementing a "Split Bar" in VB

9. *"*-.,._,.-*"* I"LL TRADE VISUAL C++ FOR VBASIC *"*-.,_,.-*"*

10. Suppress "Disable Macros" Startup Screen

11. kaboom "screen saver"

12. Screen Saver "Prewiew"

 

 
Powered by phpBB® Forum Software