Jump to content

Cancel Button on Progress Bar


GAM
 Share

Recommended Posts

#include <GUIConstants.au3>

GUICreate("Test",220,100) ;, -1,-1, $WS_CAPTION, $WS_EX_TOPMOST)
$progressbar = GUICtrlCreateProgress (10,15,200,20,$PBS_SMOOTH)
$procent = GUICtrlCreateLabel ('0 %', 10,40,200,20,$SS_CENTER)
$start = GUICtrlCreateButton ("Start",35,68,70,22)
$stop = GUICtrlCreateButton ("Stop",115,68,70,22)
GUICtrlSetState($stop,$GUI_DISABLE)
GUISetState()

$run = 0
$i = 0

While 1
  $msg = GUIGetMsg()

  If $msg = $GUI_EVENT_CLOSE Then ExitLoop
  If $msg = $start Then 
    $run = 1 
    GUICtrlSetState($start,$GUI_DISABLE)
    GUICtrlSetState($stop,$GUI_ENABLE)
  EndIf
  If $msg = $stop Then 
    $run = 0
    GUICtrlSetState($start,$GUI_ENABLE)
    GUICtrlSetState($stop,$GUI_DISABLE)
  EndIf
    If $run Then
    $i = $i + 1
    If $i > 100 Then $i = 0

    GUICtrlSetData ($progressbar,$i)
    GUICtrlSetData ($procent,$i & ' %')
    Sleep(100)
  EndIf
Wend

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