<div dir="ltr"><div dir="ltr">This is the correct code (?):<br><br>[code]Private Sub Scale(img As Image)<br><br> Dim w, h As Integer<br><br> w = img.W<br> h = img.H<br> If h > w Then<br> $H = PictureBox1.H<br> $W = (PictureBox1.H * w) \ h<br> If $W > PictureBox1.W Then<br> $W = PictureBox1.W<br> $H = (PictureBox1.W * $H) \ $W<br> $X = PictureBox1.X<br> $Y = PictureBox1.Y + ((PictureBox1.H - $H) \ 2)<br> Return<br> Endif<br> $Y = PictureBox1.Y<br> $X = PictureBox1.X + ((PictureBox1.W - $W) \ 2)<br> Else<br> $W = PictureBox1.W<br> $H = (PictureBox1.W * h) \ w<br> If $H > PictureBox1.H Then<br> $H = PictureBox1.H<br> $W = (PictureBox1.H * $W) \ $H<br> $Y = PictureBox1.Y<br> $X = PictureBox1.X + ((PictureBox1.W - $W) \ 2)<br> Return<br> Endif<br> $X = PictureBox1.X<br> $Y = PictureBox1.Y + ((PictureBox1.H - $H) \ 2)<br> Endif<br><br>End [/code]<br><br>Although I would love to be able to create a code capable of scaling images on the Form_Resize event<br>A task too burdensome for my tired brain.<br><br>Regards<br>Gianluigi<br></div></div><br><div class="gmail_quote"><div dir="ltr">Il giorno ven 30 nov 2018 alle ore 13:10 Gianluigi <<a href="mailto:bagonergi@gmail.com">bagonergi@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">I need to paint an image in a new image and then show it in a picturebox.<br>The thing seems to work correctly only if the picturebox is the only component on the window.<br>If the hbox is present, the image is deformed (stretching) and the lower part of the image is positioned under the hbox.<br>Am I wrong?<br>I attach a project and two explanatory images (with magnifying glass).</div><div dir="ltr"><br></div><div>Regards</div><div>Gianluigi<br></div></div>
</blockquote></div>