p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 20th, 2007, 04:54 PM
Friend of Wrox
Points: 797, Level: 10
Points: 797, Level: 10 Points: 797, Level: 10 Points: 797, Level: 10
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old April 20th, 2007, 05:06 PM
Friend of Wrox
Points: 5,269, Level: 30
Points: 5,269, Level: 30 Points: 5,269, Level: 30 Points: 5,269, Level: 30
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 1 Time in 1 Post
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old April 20th, 2007, 05:11 PM
Friend of Wrox
Points: 797, Level: 10
Points: 797, Level: 10 Points: 797, Level: 10 Points: 797, Level: 10
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old April 20th, 2007, 05:19 PM
Friend of Wrox
Points: 797, Level: 10
Points: 797, Level: 10 Points: 797, Level: 10 Points: 797, Level: 10
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Default

there is no OnResize
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old 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
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old April 20th, 2007, 06:22 PM
Friend of Wrox
Points: 797, Level: 10
Points: 797, Level: 10 Points: 797, Level: 10 Points: 797, Level: 10
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Default

how wud u use this event?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old 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
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 02:54 AM
Dynamically resizing forms siptah Access 4 May 11th, 2005 05: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 07:08 AM



All times are GMT -4. The time now is 12:11 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc