Wrox Programmer Forums
|
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2007, 03:54 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default 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.
 
Old April 20th, 2007, 04:06 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

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.
 
Old April 20th, 2007, 04:11 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

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
 
Old April 20th, 2007, 04:19 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

there is no OnResize
 
Old April 20th, 2007, 04:25 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old April 20th, 2007, 05:22 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

how wud u use this event?
 
Old April 20th, 2007, 05:43 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Resizing the controls AccessAasif@aol.com C# 1 December 12th, 2007 05:25 AM
Need Help with Resizing... alaamri HTML Code Clinic 3 August 29th, 2005 01:54 AM
Dynamically resizing forms siptah Access 4 May 11th, 2005 04:24 AM
Resizing form dotnetprogrammer VS.NET 2002/2003 0 February 23rd, 2005 02:58 AM
Resizing a dropdownlist Hussam_ahmad VS.NET 2002/2003 0 May 11th, 2004 06:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.