I have a picturebox on a form. I want to know how I can detect if the picture is larger than the picturebox, then resize it if needed.
Here is the code that I am using to detect if the picture is larger. It doesn't work. It resizes even if the picture is smaller. I don't understand why.
Here is the sub I am using to resize the picture. It works, but it does not keep the ratio of the picture.Code:If thepic.Picture.Height > thepic.Height Or thepic.Picture.Width > thepic.Width Then ...
Code:Private Sub ScalePic(handle As PictureBox) With handle .ScaleMode = 3 .AutoRedraw = True .PaintPicture .Picture, _ 0, 0, .ScaleWidth, .ScaleHeight, _ 0, 0, .Picture.Width / 26.46, _ .Picture.Height / 26.46 .Picture = handle.Image End With End Sub




Reply With Quote