Mannyfresh31 Posted March 21, 2018 Share Posted March 21, 2018 I need help with image resize in a GUI It looks like the images needs to to be repainted when resizing them the code is below as well as some screenshots expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ;Set Hot-Keys HotKeySet("s", "Stop") $random1 = Random(0,9,1) $random2 = Random(0,9,1) $random3 = Random(0,9,1) $Spin = False $Sleep = 50 $Height = 132 #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 492, 252, 181, 124) GUISetBkColor(0x000000) Global $Pic1 = GUICtrlCreatePic( @ScriptDir & "\Numbers\" & $random1 & ".jpg", 48, 16, 100, 132) Global $Pic2 = GUICtrlCreatePic( @ScriptDir & "\Numbers\" & $random2 & ".jpg", 184, 16, 100, 132) Global $Pic3 = GUICtrlCreatePic( @ScriptDir & "\Numbers\" & $random3 & ".jpg", 320, 16, 100, 132) Global $Button1 = GUICtrlCreateButton("Spin", 56, 184, 75, 25) Global $Button2 = GUICtrlCreateButton("Stop", 336, 184, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Spin = True Spin() EndSwitch WEnd Func Spin() While $Spin = True For $a = 1 to 132 Step 10 GUICtrlSetPos ($Pic1,48, 16, 100, 132 - $a ) Sleep($Sleep) Next For $a = 1 to 132 Step 10 GUICtrlSetPos ($Pic2,184, 16, 100, 132 - $a ) Sleep($Sleep) Next For $a = 1 to 132 Step 10 GUICtrlSetPos ($Pic3,320, 16, 100, 132 - $a ) Sleep($Sleep) Next $random1 = Random(0,9,1) $random2 = Random(0,9,1) $random3 = Random(0,9,1) GUICtrlSetImage ( $Pic1, @ScriptDir & "\Numbers\" & $random1 & ".jpg") GUICtrlSetImage ( $Pic2, @ScriptDir & "\Numbers\" & $random2 & ".jpg") GUICtrlSetImage ( $Pic3, @ScriptDir & "\Numbers\" & $random3 & ".jpg") For $a = 1 to 132 Step 10 GUICtrlSetPos ($Pic1,48, 16, 100, 2 + $a ) Sleep($Sleep) Next For $a = 1 to 132 Step 10 GUICtrlSetPos ($Pic2,184, 16, 100, 2 + $a ) Sleep($Sleep) Next For $a = 1 to 132 Step 10 GUICtrlSetPos ($Pic3,320, 16, 100, 2 + $a ) Sleep($Sleep) Next WEnd EndFunc Func Stop() $Spin = False EndFunc Numbers.zip Link to comment Share on other sites More sharing options...
Andreik Posted March 21, 2018 Share Posted March 21, 2018 You don't want to resize picture, probably you want to to move it to looks like a flip. In this case change (for all 3 loops) GUICtrlSetPos ($Pic1,48, 16, 100, 132 - $a ) with GUICtrlSetPos ($Pic1,48, 16-$a, 100, 132 ) Link to comment Share on other sites More sharing options...
Mannyfresh31 Posted March 21, 2018 Author Share Posted March 21, 2018 @Andreikthanks for that effect it looks nice but that's not what I want since your effect only changes the position of the image but I want to resize it like close and open close with one number and open with another number. Link to comment Share on other sites More sharing options...
Bilgus Posted March 21, 2018 Share Posted March 21, 2018 (edited) This is REALLY not the way I would be doing this but whatever its all about learning I suppose Your issue is that you loaded the new pictures while the controls were shrunk I fixed that with a loop to resize them load the random picture and reshrink them I also added a way to stop the darn script while I was at it --Edit Oh I See you Set the hotkey to Stop it expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ;Set Hot-Keys HotKeySet("s", "Stop") $random1 = Random(0, 9, 1) $random2 = Random(0, 9, 1) $random3 = Random(0, 9, 1) $Spin = False $Sleep = 50 $Height = 132 #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 492, 252, 181, 124) GUISetBkColor(0x000000) Global $Pic1 = GUICtrlCreatePic(@ScriptDir & "\Numbers\" & $random1 & ".jpg", 48, 16, 100, 132) Global $Pic2 = GUICtrlCreatePic(@ScriptDir & "\Numbers\" & $random2 & ".jpg", 184, 16, 100, 132) Global $Pic3 = GUICtrlCreatePic(@ScriptDir & "\Numbers\" & $random3 & ".jpg", 320, 16, 100, 132) Global $Button1 = GUICtrlCreateButton("Spin", 56, 184, 75, 25) Global $Button2 = GUICtrlCreateButton("Stop", 336, 184, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Opt("GUIOnEventMode", 1) GUICtrlSetOnEvent($Button2, Stop) $Spin = True Spin() EndSwitch WEnd Func Spin() Local $aPicCtrls[3] = [$Pic1, $Pic2, $Pic3] Local $aPicLeft[3] = [48, 184, 320] While $Spin = True For $i = 0 To UBound($aPicCtrls) - 1 For $a = 1 To 132 Step 10 GUICtrlSetPos($aPicCtrls[$i], $aPicLeft[$i], 16, 100, 132 - $a) Sleep($Sleep) If Not $Spin Then ExitLoop 3 Next Next For $i = 0 To UBound($aPicCtrls) - 1 $iRand = Random(0, 9, 1) GUICtrlSetState($aPicCtrls[$i], $GUI_HIDE) GUICtrlSetPos($aPicCtrls[$i], $aPicLeft[$i], 16, 100, 132) GUICtrlSetImage($aPicCtrls[$i], @ScriptDir & "\Numbers\" & $iRand & ".jpg") GUICtrlSetPos($aPicCtrls[$i], $aPicLeft[$i], 16, 100, 0) GUICtrlSetState($aPicCtrls[$i], $GUI_SHOW) Next For $i = 0 To UBound($aPicCtrls) - 1 For $a = 1 To 132 Step 10 GUICtrlSetPos($aPicCtrls[$i], $aPicLeft[$i], 16, 100, 2 + $a) Sleep($Sleep) If Not $Spin Then ExitLoop 3 Next Next WEnd EndFunc ;==>Spin Func Stop() Opt("GUIOnEventMode", 0) $Spin = False EndFunc ;==>Stop Edited March 21, 2018 by Bilgus Mannyfresh31 1 Link to comment Share on other sites More sharing options...
Mannyfresh31 Posted March 21, 2018 Author Share Posted March 21, 2018 @Bilgus Thank you so much that's the way I wanted, You're the man! Link to comment Share on other sites More sharing options...
KickStarter15 Posted March 23, 2018 Share Posted March 23, 2018 @Mannyfresh31, Thanks for this, I can use this in our current activity "Lucky 3 for a Cause". We are using bottle with numbers in it and shake it for the lucky 3 numbers, once you hit the 3 lucky numbers based, the one that holds the numbers will have cash and 50% of that cash will be donated to our selected charity. \m/ Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
Bilgus Posted March 23, 2018 Share Posted March 23, 2018 @KickStarter15 A word of warning Those numbers are severely NON-Random I would never base a game of chance on them even a charity one.. At the very least see SRandom() in the manual, better would be a few more steps for the calculations, best would be a real(er?) random number generator Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now