|
-
Apr 3rd, 2000, 06:05 AM
#1
Thread Starter
Member
Sam (or anyone else)-
This post is in reference to a post you made today found here:
http://forums.vb-world.net/showthrea...threadid=13090
This does and doesn't work. It creates the effect that I want for the text box but it also resizes all my buttons, etc which is bad. I messed around with the code to try and make it only do the text box but I can't get the proportions right for some reason. Thanks in advance for any help.
-
Apr 3rd, 2000, 06:43 AM
#2
Hyperactive Member
All you need to do is alter the code you were given to include the following :
Code:
If TypeName(Controls(iNum)) <> "CommandButton" Then
<Do the things you need to do>
End If
Obviously replacing iNum with the variable you had before
-
Apr 3rd, 2000, 07:04 AM
#3
Fanatic Member
TRY THIS OUT
As i see from your rough picture that you want the text box to be about a third of the width of the form so here is how to do it.
Sub Form_Resize()
text1.width=form1.width/3
text1.height=form1.height/2
text1.left=(form1.width-text1.width)/2
text1.top=(form1.height-text1.height)/2
End Sub
every time the form is resized the texbox is resized to remain PROPORTIONAL
Doc Zaf
{;->
-
Apr 3rd, 2000, 07:10 AM
#4
The reasons that the proportions aren't correct is that as I mentioned in my response to your previous post, the order of the parts of the Move method are out of order. It should be
Controls(I).Move .LeftProportions * ScaleWidth, _
.TopProportions * ScaleHeight, _
.WidthProportions * ScaleWidth, _
.HeightProportions * ScaleHeight
and not
Controls(I).Move .LeftProportions * ScaleWidth, _
.TopProportions * ScaleHeight, _
.HeightProportions * ScaleHeight, _
.WidthProportions * ScaleWidth,
-
Apr 3rd, 2000, 07:28 AM
#5
Addicted Member
I saw your previous post but didn't respond because I feel that the others responded well. I guess you feel differently so I'll throw in my two cents.
First of all you're not being very specific on what exactly you want done. Do you want your control to be aligned to the bottom of your Form no matter what the Form's size is? Do you want it to always be the same width as your Form? The full width? The width from a point? Do you want the control to be aligned based on another control?
In any case what you want to pay attention to is your control's Left, Top, Width, and Height properties. Also, any control re-alignment code will probably be placed in the Form's Resize method. While I'm on that note I should also mention that if you're not just adjusting a control's width or height, like moving it, you should use the control's Move method instead of specifing each property individualy, makes sense don't it? Now onto the actual coding of control's alignment properties:
First declare a general constant, such as
Private Const BASIC_DIMENSIONS As Integer = 495
To align the control to the...
Left Side of the Form:
Control.Move(Me.ScaleLeft, Me.ScaleTop, BASIC_DIMENSION, Me.ScaleHeight)
Right Side of the Form:
Control.Move(Me.ScaleWidth - BASIC_DIMENSION, Me.ScaleTop, BASIC_DIMENSION, Me.ScaleHeight)
Top of the Form:
Control.Move(Me.ScaleLeft, Me.ScaleTop, Me.ScaleWidth, BASIC_DIMENSION)
Bottom of the Form:
Control.Move(Me.ScaleLeft, Me.ScaleHeight - BASIC_DIMENSION, Me.ScaleWidth, BASIC_DIMENSION)
Based on a point and keep flush with Right side of Form:
Control.Width = Me.ScaleWidth - Control.Left
Based on a floating point, say you want the Control to always be in the Center of the Form:
Control.Move((Me.ScaleWidth / 2) - (Control.Width / 2), (Me.ScaleHeight / 2) - (Control.Height / 2))
Based on a floating point, Top Right quadrant:
Control.Move(((Me.ScaleWidth / 4) * 3) - (Control.Width / 2), ((Me.ScaleHeight / 4) * 1) - (Control.Height / 2))
To fill a quadrant or portion of the screen, say the Bottom Left quadrant to be half the quadrant's size:
Control.Move(((Me.ScaleWidth / 4) * 1) - (Control.Width / 2), ((Me.ScaleHeight / 4) * 3) - (Control.Height / 2), (Me.ScaleWidth / 4), (Me.ScaleHeight / 4))
To base the position on another Control, say to the Upper Rigt of the Control:
Control.Move(OtherControl.Left + OtherControl.Width, OtherControl.Top)
To base the position on another Control, Lower Left:
Control.Move(OtherControl.Left - Control.Width, OtherControl.Top + OtherControl.Height - Control.Height)
Any other example can be made up from what I've given you so far. Keep in mind that when I say "Control" I mean any VB Object that has the Left, Top, Width, and Height properties, and has a Move method. Such as a CommandButton or a TextBox. I used division to determine the position because I thought fractional sizes would be easier to understand, you could however use percentages to if you feel more comfortable with it, ie.
Fractional> ((Me.ScaleHeight / 4) * 3)
Percentage> (Me.ScaleHeight * 0.75)
are both equivalent.
Also, you could use padding in between your controls to create a more visual appealing interface. It is usually better to use a declared constant for the padding measurement to keep the look of the Form consistent,
for example:
Private Const PADDING As Integer = 50
Control.Move(OtherControl.Left + OtherControl.Width + PADDING, OtherControl.Top)
Keep in mind that you will probably need align all the controls on your Form.
Hope this helps!
Later.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|