Jump to content

Problem with gui ctrl set data


kor
 Share

Recommended Posts

#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.

Link to comment
Share on other sites

  • Moderators

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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...