PantZ4 Posted December 15, 2007 Share Posted December 15, 2007 I have made a little function to make the GUI look like it float when it changes size. My problem is with the height, within the loop. It seems it get negative number when it should be positive number. Below I have done it manual, without loop, and that one works. I just can't understand what is wrong with my loop. This code is fully working, with the quick fix. expandcollapse popup#include <GuiConstants.au3> $GUI = GUICreate("Test GUI<",450,170) GUISetState() Sleep(1000) _GUIResizeFlow($GUI,600,400,250,1) While GuiGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEnd Func _GUIResizeFlow($GUI,$Width,$Height,$Time = 250,$Center = 0) Local $CurrPos = WinGetPos($GUI) Local $WantPos[2] = [$Width,$Height] Local $DiffPos[2] Local $NewPosPerMove[2] = [0] Local $WantTime = $Time Local $Timer Local $TrackedTime = 0 Local $WantCenter = $Center For $i = 0 To $i = 2 Step 1 If $CurrPos[$i+2] < $WantPos[$i] And $CurrPos[$i+2] > 0 Then $DiffPos[$i] = $WantPos[$i] - $CurrPos[$i+2] ElseIf $CurrPos[$i+2] > $WantPos[$i] And $CurrPos[$i+2] > 0 Then $DiffPos[$i] = $CurrPos[$i+2] - $WantPos[$i] EndIf $NewPosPerMove[$i] = $DiffPos[$i] / $WantTime Next ;Quick fix to make it work. Comment it out to see what I mean... Is like it get negative when it should be prositiv. $DiffPos[1] = $WantPos[1] - $CurrPos[3] $NewPosPerMove[1] = $DiffPos[1] / $WantTime ;Un-Comment this line will get you a Msgbox with the variables. For test purpose. ;~ MsgBox(0,"Test","Current Width = "&$CurrPos[2]&@CRLF&"Current Height = "&$CurrPos[3]&@CRLF&"Wanted Width = "&$WantPos[0]&@CRLF&"Wanted Height = "&$WantPos[1]&@CRLF&"Diffrent Width = "&$DiffPos[0]&@CRLF&"Diffrent Height = "&$DiffPos[1]) $Timer = TimerInit() While TimerDiff($Timer) < $WantTime If $TrackedTime <= TimerDiff($Timer) Then $TrackedTime = $TrackedTime + 1 If $WantCenter = 0 Then WinMove($GUI,"",Default,Default,$CurrPos[2]+($NewPosPerMove[0]*TimerDiff($Timer)),$CurrPos[3]+($NewPosPerMove[1]*TimerDiff($Timer)),1) Else WinMove($GUI,"",$CurrPos[0]-(($NewPosPerMove[0]*TimerDiff($Timer)/2)),$CurrPos[1]-(($NewPosPerMove[1]*TimerDiff($Timer)/2)),$CurrPos[2]+($NewPosPerMove[0]*TimerDiff($Timer)),$CurrPos[3]+($NewPosPerMove[1]*TimerDiff($Timer)),1) EndIf EndIf WEnd EndFunc Link to comment Share on other sites More sharing options...
PantZ4 Posted December 16, 2007 Author Share Posted December 16, 2007 No ideas? Link to comment Share on other sites More sharing options...
Valuater Posted December 16, 2007 Share Posted December 16, 2007 How about... #include <GuiConstants.au3> $GUI = GUICreate("Test GUI<", 450, 170) GUISetState() Sleep(1000) _GUIResizeFlow($GUI, 600, 400, 10) While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEnd Func _GUIResizeFlow($GUI, $Width, $Height, $Time = 10) Local $CurrPos = WinGetPos($GUI) $left = $CurrPos[0] $top = $CurrPos[1] $x = $CurrPos[2] $y = $CurrPos[3] Do If $Width > $x Then $x += 1 $left = $left - .5 EndIf If $Height > $y Then $y += 1 $top = $top - .5 EndIf WinMove($GUI, "", $left, $top, $x, $y) Sleep($Time) Until $x = $Width And $y = $Height EndFunc ;==>_GUIResizeFlow 8) 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