Jump to content
Sign in to follow this  
KANlFUSA

GUI Progress Bar problem (solved)

Recommended Posts

Please help me
how to edit , after click OK msgbox "finish" , gui (GUICtrlCreateProgress(235, 198, 333, 3) and  Guictrlcreatelabel("",235,198,333,1,0x01) will disappear.  after that click back START button can rerun again?
 
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>


#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", 806, 456, -1, -1)
Global $Button1 = GUICtrlCreateButton("START", 313, 144, 80, 38, $BS_CENTER)
GUISetState(@SW_SHOW)



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

Case $Button1
pbar()



    EndSwitch

 WEnd




Func pbar()

$progressbar = GUICtrlCreateProgress(235, 198, 333, 3)
$label = Guictrlcreatelabel("",235,198,333,1,0x01)
Guictrlsetbkcolor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState()

local $progressbar
  local  $i = 0

      While Guigetmsg() <> -1
        $i = $i+2
        GUICtrlSetData($progressbar, $i)
        GUICtrlSetData($label,$i)

        Sleep(1)
        If $i = 100 then msgfinish()

     WEnd

EndFunc



Func msgfinish()

 MsgBox(0,"Finish","Finish","")
If @Error = 1 then
Exit
Endif
Return

EndFunc

 

 
Edited by KANlFUSA

Share this post


Link to post
Share on other sites

If you want to make controls disappear/reappear, the best way is to show/hide them
You need also to take care to exit loop when you're done

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

Global $Form1 = GUICreate("Form1", 806, 456, -1, -1)
Global $Button1 = GUICtrlCreateButton("START", 313, 144, 80, 38, $BS_CENTER)
$progressbar = GUICtrlCreateProgress(235, 198, 333, 3)
GUICtrlSetState(-1, $GUI_HIDE)
$label = Guictrlcreatelabel("",235,198,333,1,0x01)
Guictrlsetbkcolor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            pbar()
    EndSwitch
 WEnd


Func pbar()
  GUICtrlSetState($progressbar, $GUI_SHOW)
  GUICtrlSetState($label, $GUI_SHOW)
  local  $i = 0
      While Guigetmsg() <> $GUI_EVENT_CLOSE
        $i = $i+2
        GUICtrlSetData($progressbar, $i)
        GUICtrlSetData($label,$i)
        Sleep(1)
        If $i = 100 then Exitloop
     WEnd
    msgfinish()
EndFunc

Func msgfinish()
  MsgBox(0,"Finish","Finish","")
  GUICtrlSetState($progressbar, $GUI_HIDE)
  GUICtrlSetState($label, $GUI_HIDE)
EndFunc

 

Edited by mikell

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  

×
×
  • Create New...