You load the picture into your picture control outside of GuiSize by specifying vPic, Filname and the dominant dimension in the AutoPicWH(vPic, Filename, DominantDim) call.
In the GuiSize subroutine you call after the AutoXYZ() function calls once AutoPicWH().
The picture controls still have to be rezised with AutoXYZ(). This function only reloads the picture to increase picture quality when the control gets larger and ensures that the aspect ration is maintained and the picture stays within the original boundaries.
Code: Select all
AutoPicWH(vPic:="", Filename:="", DominantDim:="w"){
static cInfo := {}
ctrlID := A_Gui ":" vPic
If (vPic = "") {
For ctrlID, Data in cInfo {
c := StrSplit(ctrlID, ":")
GuiControlGet, i, % c.1 ":Pos", % c.2
DominantDim := iw/ih < Data.a ? "w" : "h"
GuiControl, % c.1 ":" , % c.2, % "*" DominantDim i%DominantDim% " *" (DominantDim="w"?"h":"w") "-1 " Data.f
}
}Else {
GuiControlGet, i, %A_Gui%:Pos, %vPic%
GuiControl, % A_Gui ":", % vPic , % "*" DominantDim i%DominantDim% " *" (DominantDim="w"?"h":"w") "-1 " FileName
GuiControlGet, j, %A_Gui%:Pos, %vPic%
cInfo[ctrlID] := {f:Filename, d:DominantDim, a:jW/jH}
}
}