Page 1 of 1

Resize Picture In GUI

Posted: 19 Feb 2020, 01:39
by scriptor2016
Hi, this might be a dumb question but hey here goes anyways:

1. create a new GUI and load an image into it.
If the GUI size is 600x600, then the image loaded into it will scale to 600x600 so the GUI is filled with the picutre

2. The GUI will have +Resize as an option.
So when the GUI is resized, the image will also resize along with it. So if we drag the GUI borders to make it very big, then the picture size scales up
along with it. And if we drag the borders and make the GUI very small, then the picture will scale down with it and also be very small.

Seems like such an easy thing to ask, but I don't know how to explain it so easily.

I haven't found anything on the forums about this.

Anyone know if this is possible?

Re: Resize Picture In GUI

Posted: 19 Feb 2020, 02:27
by flyingDman
Have you looked at guisize (https://www.autohotkey.com/docs/commands/Gui.htm#GuiSize)?

Code: Select all

gui, -dpiscale
gui, -caption +resize
gui, add, picture, x0 y0 w200 h200 vmypic, image1.jpg
gui, show
return

guisize:
GuiControl, Move, mypic, % "w" . A_GuiWidth . " h" . A_GuiHeight
winset redraw
return
If you want to keep the aspect ratio constant, you can do something like this (assuming you have a square image)

Code: Select all

guisize:
GuiControl, Move, mypic, % "w" . A_GuiWidth . " h" . A_GuiWidth
winmove, A,,,, A_GuiWidth, A_GuiWidth
winset redraw
return

Re: Resize Picture In GUI

Posted: 19 Feb 2020, 09:37
by scriptor2016
thanks, this is AWESOME!!

I knew it was something simple but for whatever reason it's something I've never looked into over the years.

Looks like this will be exactly what I need, though :)