Jump to content
Sign in to follow this  
kor

Problem with gui ctrl set data

Recommended Posts

kor

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $progressbar1, $progressbar2, $button, $wait, $s, $msg, $m
    GUICreate("My GUI Progressbar", 220, 100, 100, 200)
    $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20)
    $button = GUICtrlCreateButton("Start", 75, 70, 70, 20)
    GUISetState()
    Local $i = 0
    Do
        $msg = GUIGetMsg()
        If $msg = $button Then
                    GUICtrlSetData($progressbar1, $i += 10)
                    Sleep(300)
                    GUICtrlSetData($progressbar1, $i += 10)
                    Sleep(300)
                    GUICtrlSetData($progressbar1, $i += 10)
                    Sleep(300)
                    GUICtrlSetData($progressbar1, $i += 10)
                    Sleep(300)
                    GUICtrlSetData($progressbar1, $i += 10)
                    Sleep(300)
        EndIf
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Modified sample script from the GuiCtrlCreateProgress

When I try and run I get an error parsing function call with the $i += 10

I'm not sure why I can't preform this operation.

Share this post


Link to post
Share on other sites
JLogan3o13

Hi, kor. A couple of ways you can do it, as GUICtrlSetData does not like the += attempt at incrementing. From your example, this is the simplest:

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
    Local $progressbar1, $progressbar2, $button, $wait, $s, $msg, $m
    GUICreate("My GUI Progressbar", 220, 100, 100, 200)
    $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20)
    $button = GUICtrlCreateButton("Start", 75, 70, 70, 20)
    GUISetState()
    Local $i = 0
    Do
        $msg = GUIGetMsg()
        If $msg = $button Then
                    GUICtrlSetData($progressbar1, $i + 10)
                    Sleep(300)
                    GUICtrlSetData($progressbar1, $i + 20)
                    Sleep(300)
                    GUICtrlSetData($progressbar1, $i + 30)
                    Sleep(300)
                    GUICtrlSetData($progressbar1, $i + 40)
                    Sleep(300)
                    GUICtrlSetData($progressbar1, $i + 50)
                    Sleep(300)
        EndIf
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
kor

I cheated and took the easy way out.

$iBarCount += 5 ; step the precentage
        GUICtrlSetData($hBar, $iBarCount) ; set the progress bar percentage
        Sleep(200) ; sleep to allow time to see progress step and read messages

Share this post


Link to post
Share on other sites
JLogan3o13

Easy is what we're aiming for. Glad you worked it out :oops:


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×