|
|
 |
| Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning VB 6 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

April 20th, 2007, 04:54 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Resizing Forms
Is there anyway that when a form is resized tht some of the objects resize with it, width ways, and the other objects jst keep to where they are??
__________________
Apocolypse2005, I'm a programmer - of sorts.
|

April 20th, 2007, 05:06 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 1 Time in 1 Post
|
|
Sure. OnResize of the form, read the width and/or height of the form (Me.Height, etc), and change the .Left, .Top, .Height or .Width of the controls you are interested in.
You will have to write the business rules yourself, but once you have, it is a thing of beauty.
You could say:
Code:
If Me.Width > 100 Then
Me.TextBox1.Width = Me.Width - 80 ' Will leave box 20 wide at minimum
End If
You would add similar items for all controls you want to control.
|

April 20th, 2007, 05:11 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
so if i ws using a msflexgrid by the name of PlayGrid
i wud do
If me.width > 100 then
Playgrid.width = me.width - 20
end if
|

April 20th, 2007, 05:19 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
there is no OnResize
|

April 20th, 2007, 05:25 PM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The event is the Resize event, and the event handler will be named Form_Resize()
I don't think Brian was saying there is an "OnResize", but that "On Resize of the form, read the...".
Woody Z
http://www.learntoprogramnow.com
How to use a forum to help solve problems
|

April 20th, 2007, 06:22 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
how wud u use this event?
|

April 20th, 2007, 06:43 PM
|
|
Friend of Wrox
|
|
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Every time a form is resized, a "Hey, You are resizing" event is sent to that form by windows. In VB6 we get a chance to do something with that event by using the Form_Resize event handler template provided by VB6.
You can add this template to your form by selecting it from the procedure dropdown when the object dropdown is set to the form when you are in the Code view of your form. You understand all that, I presume?
Okay - once you have the template, any code in that method will run every time the form is resized.
Here is a very simple example:
Code:
Private Sub Form_Resize()
On Error Resume Next
Text1.Move 50, 50, Me.ScaleWidth - 100, Me.ScaleHeight - 100
End Sub
The above code assumes you have a textbox named text1 on your form. It will essentially "fill" the form with the text1 textbox leaving a 50 twips border all around it. Of course, this is assuming that the forms ScaleMode is set to twips, which is the default. A Twip is a measurement using in lead type printing, and there are 1440 twips per inch. As you resize your form, the textbox will resize as well.
For complex forms with lots of controls it can become very complex to resize all the controls as required. It can be done, of course, but it takes a lot of experience to make this work well. I have a set of classes that I use to wrap all the code for every control on the form, including features for doing splitters, and docking. Luckily, the .NET code for doing the common resizing features is much easier.
Woody Z
http://www.learntoprogramnow.com
How to use a forum to help solve problems
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |