Resize 3 controls

Hello, I have a control with three windows in it, one text box, one treeview, and one listview, I have them in the following order:

+--------------+----------------------------------------+
| Treeview1  | Listview1                                     |
|                  |                                                   |
|                  |                                                   |
|                  |                                                   |
|                  |                                                   |
|                  |                                                   |
|                  +----------------------------------------|
|                  | Text1                                          |
|                  |                                                   |
|                  |                                                   |
|                  |                                                   |
+--------------+----------------------------------------+

I want to be able to resize them on the form by clicking on there border, like for instance if i want to make treeview bigger, i just have to click on its left border and thats the same border as the lisview1 & text1 left borders, it would resize them too and make them smaller.  Next I would like to do the same with listview1's bottom border by making it bigger or smaller, it would change the size of text1 also when doing this.

Sorry to confiuse you, but if you have any questions let me know.
kwickwayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ReapeRalexCommented:
There are two ways to do that as far as I see.  One is to get a 3rd party control that will handle the resizing code for you, that other is to hand code it your self.  Try creating a new project and using the wizard to create and explorer like app.  This will have the code for you to butcher and put into you application, or try this link for a tutorial on making it your self:

http://www.cpcug.org/user/access/MCSD/Notes/splitter.htm

Essentialy you will have a control (eg an image control) in between the two controls it wll be resizing.  When the users drags this image controll around the code will resize the other controls to match.  This will look like you are dragging the boarders around, just like in any other application.

For your setup you will need two of these controls, on in between the ListView and Text box to resize them, and one in between the TreeView and other two, this one will get a bit more complicated :)

I was kind of hoping VB6 would come with a control to do this but its something that has to be hand crafted, maybe VB.Net has one built in.  I hope this helps and if you need exact code to use then I'm sure someone can knock something up for you, just ask us :)  Then all you have to do is handle the user resizing the whole window.... :)

ReapeR
0
kwickwayAuthor Commented:
Actually yea, can you "knock somthing up" for me?  =)  I have the whole form resizing contorl all figured out.  Its a fixed sized form. ;D

And yes, vb.net has a really nice feature for this, but im using vb6 for this application..

:D
0
ReapeRalexCommented:
hehe fixed size...  cheat :P  i'm stuck in vb6 too, its what i know and i don't have the time to relearn when i'm supposed to be working!

right, fill the gap between the treeview and other controls with a picture box named "sptVert" then do the same with the gap between the listview and text box, call this "sptHoriz".  now try copying the following code:


Dim boolDragY As Boolean, boolDragX As Boolean
Dim sngYStart As Single, sngYEnd As Single
Dim sngXStart As Single, sngXEnd As Single

Private Sub sptHoriz_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button = vbLeftButton) Then
    boolDragY = True
    sngYStart = Y
    Me.sptHoriz.BackColor = vbGrayText
Else
    boolDragY = False
End If
End Sub

Private Sub sptHoriz_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If boolDragY Then
    If Y <> sngYEnd Then
        sngYEnd = Y
        Me.sptHoriz.Top = Me.sptHoriz.Top - (sngYStart - sngYEnd)
    End If
End If
End Sub

Private Sub sptHoriz_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If boolDragY Then
    Me.sptHoriz.Top = Me.sptHoriz.Top - (sngYStart - sngYEnd)
    Me.ListView1.Height = Me.sptHoriz.Top - Me.ListView1.Top
    Me.Text1.Top = Me.sptHoriz.Top + Me.sptHoriz.Height
    Me.Text1.Height = Me.Height - Me.Text1.Top - 520
    Me.sptHoriz.BackColor = vbButtonFace
End If
boolDragY = False
End Sub

Private Sub sptVert_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button = vbLeftButton) Then
    boolDragX = True
    sngXStart = X
    Me.sptVert.BackColor = vbGrayText
Else
    boolDragX = False
End If
End Sub

Private Sub sptVert_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If boolDragX Then
    If X <> sngXEnd Then
        sngXEnd = X
        Me.sptVert.Left = Me.sptVert.Left - (sngXStart - sngXEnd)
    End If
End If
End Sub

Private Sub sptVert_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If boolDragX Then
    Me.sptVert.Left = Me.sptVert.Left - (sngXStart - sngXEnd)
    Me.TreeView1.Width = Me.sptVert.Left - Me.TreeView1.Left
    Me.Text1.Left = Me.sptVert.Left + Me.sptVert.Width
    Me.Text1.Width = Me.Width - Me.Text1.Left - 230
    Me.ListView1.Left = Me.Text1.Left
    Me.ListView1.Width = Me.Text1.Width
    Me.sptHoriz.Left = Me.Text1.Left
    Me.sptHoriz.Width = Me.Text1.Width
    Me.sptVert.BackColor = vbButtonFace
End If
boolDragX = False
End Sub


on the mouse up events you might have to play with the fixed numbers to stop the controls from ending up in the wrong place, i'll leave this to you for trial and error.  when it is all working set the boarder to none for the picture boxes, et voila!

any probs just ask :)

ReapeR
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

kwickwayAuthor Commented:
YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!YOU ROCK!!!!!!!!

Need I say ... ...Thanks?

Thanks so much!
0
kwickwayAuthor Commented:
I do have a question... On the text box (bottom right side), why does the bottom right change positions?  when i change its size, it actually moves the bottom the first time?

here is the project package...
http://www.verbomail.com/experts-exchange/splitview/form1.zip
0
ReapeRalexCommented:
ok, try

Me.Text1.Height = Me.ScaleHeight - Me.Text1.Top - 30

in sptHoriz_MouseUp and

Me.Text1.Width = Me.ScaleWidth - Me.Text1.Left - 30

in sptVert_MouseUp. using the .scalewidth and .scaleheight properties are a lot more precise, they give you the size of form available to the controls, .width and .height include all the boarders and title bars, hence the large numbers i used to "correct" the answers.  this should be a bit more robust and is less "bodgy" :)

hehe, thanks for the praise, carefull there or my head might inflate :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.