Log in

View Full Version : Zoom image on form



oxicottin
05-19-2020, 09:54 PM
I have a continuous form with an image box in each row. Theimages are saved at 400 X 400px BUT sometimes they are a little different dueto its original size so it might be like 300 X 400px or similar. Anyways, Iwould like to click on my image box (imgJobStep) and the image would eitheropen another form OR enlarge the image box I clicked on to a proportional size.I found the code below but not sure how to use it, will it work?

I would rather have the image box (imgJobStep) enlarge tothe left when clicked on and go back to normal when enlarged when clicked onagain if possible.



Dim newHeight As Integer, newWidth
Dim curHeight As Property, curWidth As Property
Dim Ratio As Single, Multiplier As Single

Set curWidth = Me!FrameName.Properties("Width")
Set curHeight = Me!FrameName.Properties("Height")
Ratio = curWidth / curHeight 'Proportionality Factor
Multiplier = 1.05

newWidth = curWidth * Multiplier
newHeight = newWidth / Ratio 'Maintain Porportionality

If newHeight < 31680 And newWidth < 31680 Then
curWidth = newWidth
curHeight = newHeight
Else
MsgBox "MAXIMUM ZOOM ATTAINED!"
End If

Set curWidth = Nothing
Set curHeight = Nothing

OBP
05-20-2020, 01:34 AM
I don't see any reason why it shouldnt work, you can use a fixed size of your choice as well, also using left and top to position it or open a new form in which the image takes up the whole form or you can use the image media program to view as an original full screen image.
I normally use the last one, but have also used a purpose made form as well, which can just be closed like any other form.
A lot would depend on how many images you have on the original form that would need manipulating.
If you manipulate the size you may have to ensure that it is also "on top" with "bring to front" to prevent it mixing with other fields.

oxicottin
05-26-2020, 09:11 AM
Sorry OBP I was off work for a few days.... I made an example for you to see. What it’s doing when I click on the image is expanding allimages instead of the one being clicked on. Second its not enlarging to thecenter/left and you must click it each time you want it larger. I just wantedto click on the image and have that image move to center in a larger size toget a better view of it. Thoughts?

OBP
05-26-2020, 02:19 PM
I have used one of my databases to test my code I use a text box called text20 that holds either yes or no and uses it to switch sizes.
My image is called photo1 and this code changes the size and position, note that the dimensions use twips in the vba code so you will ahve to play around a bit to get your image the sizes you want 1" =1440 twips.
You will probably want use the code in the forms On current event to set the default size.

If Me.Text20 = "yes" Then
Me.Text20 = "no"
Me.Photo1.Width = 2880
Me.Photo1.Height = 2880
Me.Photo1.Top = 1000
Me.Photo1.Left = 5000

Else:
Me.Text20 = "yes"
Me.Photo1.Width = 5000
Me.Photo1.Height = 5000
Me.Photo1.Top = 1000
Me.Photo1.Left = 4000

End If