Solved

Resize 3 controls

Posted on 2003-10-21
6
187 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 45 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now