Jump to content

Busy Indiactor


mother9987
 Share

Recommended Posts

I don't know if anyone else has had the problem of showing that the program is working, but is waiting for something else to happen and has no idea when that will be.

I've got a program that waits for a file to be written to and does nothing until that happens. Anyhow, I was bored and knocked this off. Thought I'd see if it gives anyone else a grin.

#include <GuiConstants.au3>
DIM $process


GuiCreate("Busy Indiactor", 441, 155,(@DesktopWidth-441)/2, (@DesktopHeight-155)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$start = GuiCtrlCreateButton("OK", 10, 120, 180, 30)
$Label_2 = GuiCtrlCreateLabel("", 20, 30, 400, 30)
$exit = GuiCtrlCreateButton("Exit", 250, 120, 180, 30)

GuiSetState()
$process = _guictrlcreatebusy( 20, 30,  400,  15, 25 )
$time=TimerInit()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE or $msg = $exit
        ExitLoop
    Case Else
        If TimerDiff( $time ) > 100 then 
            _guictrladvancebusy($process, 3)
            $time = TimerInit()
        EndIf
    EndSelect
WEnd
Exit





func _guictrlcreatebusy( $iLeft, $iTop, $iWidth, $iHeight, $iDivisions = 21, $fLoad=0.5, $iColor = 0x0000ff, $iBGColor = 0xd0d0d0)
    Local $busy[ $iDivisions + 6]
    Local $boxwidth, $iTopprog

    If $iDivisions = 0 Then
        SetError(1)
        Return 0
    EndIf
    
    If $iHeight < 5 or $iWidth<8 Then
        SetError(2)
        Return 0
    EndIf
    
    If $iWidth/$iDivisions<3 Then
        $iDivisions = Int( ($iWidth - 2) / 3)
    EndIf
    
    $busy[0] = GuiCtrlCreateLabel( "",$iLeft, $iTop+$iHeight*2 +4, $iWidth, $iHeight,-1, $WS_EX_STATICEDGE)
    GuiCtrlSetBkColor( -1, $iBGColor )
    $boxwidth = Int( (($iWidth - 2) / $iDivisions) + .5)
    If $boxwidth < 3 then $boxwidth = 3
    If $boxwidth * ( $iDivisions -1 ) > ( $iWidth - 4 ) Then
        $iDivisions = Int( ( $iWidth - 4 ) / $boxwidth ) + 1
    EndIf
    $iTopprog = Int( $iDivisions * $fLoad )
    $busy[1] = $iDivisions
    $busy[2] = $iDivisions
    $busy[3] = $iTopprog
    $busy[4] = $iColor
    $busy[5] = $iBGColor
    For $i = 0 to $iDivisions - 1
        If $i = $iDivisions - 1 Then
            $boxwidth = $iWidth - 4 - ( $iDivisions ) * $boxwidth
        EndIf
        $busy[$i + 6] = GuiCtrlCreateLabel( "", $iLeft + 2 + $boxwidth * $i, $iTop+$iHeight*2 +6, $boxwidth - 2, $iHeight - 4 )
        If $i<= $iTopprog Then
            GUICtrlSetBkColor( -1, $iColor )
        Else
            GUICtrlSetBkColor( -1, $iBGColor )
        EndIf
    Next
    
    Return $busy
    
EndFunc

func _guictrladvancebusy(ByRef $avBusy, $iIncrements = 1)
        Local $i
        
        $iIncrements = Int( $iIncrements )
        For $i = 1 to $iIncrements
            $avBusy[2] += 1
            $avBusy[3] += 1
            If $avBusy[2] >= $avBusy[1] then $avBusy[2] = 0
            If $avBusy[3] >= $avBusy[1] Then $avBusy[3] = 0
            GUICtrlSetBkColor( $avBusy[ $avBusy[ 3 ] + 6], $avBusy[ 4 ] )
            GUICtrlSetBkColor( $avBusy[ $avBusy[ 2 ] + 6], $avBusy[ 5 ] )
        Next
        
        Return
EndFunc
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...