Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Zoom a Form In And Out

Status
Not open for further replies.

LesMartin

Programmer
Sep 23, 2003
11
GB
Hi,
This is my first post here so I hope Im in the right forum.
Im pretty new to VB6 and have got a little stuck with my app(Just a pet project I have).

I have a MDI form
On the left of the MDI I have a picture box control im using as a container for my search records controls, when a search is made there is a list box that shows up the results and when the result is clicked on, a form opens in the MDI form with the data required.

The problem is the form that opens is too big for the screen and to view it all you need to use the forms scroll bars.

So in the left picture box control I added 2 buttons, One to Zoom the form In and the other to zoom out the form.

The code I have came up with is just not doing the job correctly it seems to move the form Up& Down at angles???

As I say guys Im very new to VB and I would be very appreciative if someone could assist me with this.

The code I have on my Zoom buttons are below:

Many thanks in advance

LM



Private Sub imgZoomIn_click()
On Error GoTo Error
If imgZoomOut.Enabled = False Then
imgZoomOut.Enabled = True
End If

Form34.Height = Form34.Height + 600
Form34.Width = Form34.Width + 600
Form34.Top = Form34.Top - 300
Form34.Left = Form34.Left - 300

Exit Sub
Error:
imgZoomIn.Enabled = False
End Sub

Private Sub imgZoomOut_click()
On Error GoTo Error

Form34.Height = Form34.Height - 600
Form34.Width = Form34.Width - 600
Form34.Top = Form34.Top + 300
Form34.Left = Form34.Left + 300

Exit Sub
Error:
imgZoomOut.Enabled = False
End Sub
 
Hi P

Yes the form 34 is a child form.

I have a resize control modual that form34's On_load & On_resize events were calling, this was to keep all the controls on the form in proportion to the form34 if it were resized, if I remove these references to the modual the form resizes in and out by using the zoom buttons.

The only problem is that as you can imagine the controls on the form get cropped out now when the form is zoomed out!!

Ever round in circles
Any suggestions are welcomed
Regards
L
 
Ok - I think so,

What you want is resize the controls of your forms.

First you must define a dimension minimal with the Rezize-event of the Child and MDI forms.
Second you must create a dinamical form design with you can reajust with the same resize event. You must see how many controls you have and if its nesesary change al properties this can be able in a class.

Is this you looking for?

peterguhl@yahoo.de
 
Hi P

Yea I think that sounds about right for what I need to do, but to be honest Im not sure where to begin?

Thanks again
 
This is a little example
A form with a text1 textbox

Private Sub Form_Resize()
Dim Factor As Double
With Me
If .Width < 5000 Then .Width = 5000
.Height = .Width * (4 / 5)
Factor = .Width / 5000
End With

With Text1
.FontSize = 8.5 * Factor
.Top = 360 * Factor
.Left = 840 * Factor
.Width = 2055 * Factor
.Height = 325 * Factor
End With
End Sub


peterguhl@yahoo.de
 
Hi P

Right so If i were to use that example on form34, would I just replace Text 1 with a list of all my form controls?

like

Private Sub Form_Resize()
Dim Factor As Double
With Me
If .Width < 5000 Then .Width = 5000
.Height = .Width * (4 / 5)
Factor = .Width / 5000
End With

With Text1,Text2,Text3,Text4,ETC,ETC
.FontSize = 8.5 * Factor
.Top = 360 * Factor
.Left = 840 * Factor
.Width = 2055 * Factor
.Height = 325 * Factor
End With
End Sub

Thanks again
L
 
This if you have more controls

Option Explicit
Public factor As Double
Public OldWidth As Long
Public MyFont As Double

Private Sub Form_Load()
OldWidth = Me.Width
MyFont = 8.5
End Sub

Private Sub Form_Resize()
Dim i As Integer

With Me
If .Width < 5000 Then .Width = 5000
.Height = .Width * (4 / 5)
factor = .Width / OldWidth
OldWidth = .Width
End With

MyFont = MyFont * factor
On Error Resume Next
For i = 0 To Me.Controls().Count
With Me.Controls(i)
.FontSize = MyFont
.Top = .Top * factor
.Left = .Left * factor
.Width = .Width * factor
.Height = .Height * factor
End With
Next i
End Sub



peterguhl@yahoo.de
 
Hi P
What can I say but thanks a bunch.
Your help is appreciated, I'd would never have came up with that.
Many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top