Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Resize 3 controls

Posted on 2003-10-21
6
Medium Priority
?
195 Views
Last Modified: 2010-05-03
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.
0
Comment
Question by:kwickway
  • 3
  • 3
6 Comments
 
LVL 1

Expert Comment

by:ReapeRalex
ID: 9591872
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
 

Author Comment

by:kwickway
ID: 9592132
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
 
LVL 1

Accepted Solution

by:
ReapeRalex earned 180 total points
ID: 9593026
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kwickway
ID: 9594131
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
 

Author Comment

by:kwickway
ID: 9594171
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
 
LVL 1

Expert Comment

by:ReapeRalex
ID: 9594789
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question