Jump to content
Sign in to follow this  
Nologic

Slow update on Muliple GUICtrlSetColor calls

Recommended Posts

Nologic

Okay I've gone and >updated a example script done by Synapse called title="Schedule system - started 18 January 2008 - 05:15 PM">Schedule system. Which requires this >UDF.

Now in my new code I added the ablity to toggle its enable disable states...and this is where the problem is. Most the time it'll update seemlessly other times...rather sluggish and very visible to the naked eye. Granted I'm running this right now on an older system...have yet to try it on my i5.

That said...is there anyway to update this table as a whole on a single refresh.

Anyways here is the main block of code so one doesn't need to go hunting through the forums just to get an idea of they can help me or not. :)

The _SchedulerState() is where all the action is.

#include <Array.au3>
#include <GUIConstants.au3>
#include <GUICtrlOnHover.au3>

Opt( "GuiOnEventMode" , 1 )

; Colors
$sSwatchOutLine  = '0x000000' ; Black
$sSwatchDisabled = '0xb7b7b7' ; Gray
$aSwatchNormal   = StringSplit( '0xc7b299|0xf7941d|0xfff200|0x00a651|0x0054a6|0x600080|0xB30086|0xcc1015' , '|' )
$aSwatchHover    = StringSplit( '0x998675|0xf26522|0xd8ca03|0x007236|0x003471|0x4D0066|0x990073|0x9e0b0f' , '|' )

$aWeekShort    = StringSplit( 'Sun|Mon|Tue|Wen|Thu|Fri|Sat' , '|' )
$aWeekLong     = StringSplit( 'Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday' , '|' )

Global $aSwatches[169][2] = [[168]]
Global $sSavedSettings = @ScriptDir & "\Scheduler.ini"

Global $aSwatchMock[UBound( $aSwatchNormal )][2] = [[UBound( $aSwatchNormal ) - 1]]
Global $aWeekLabel[8] = [7]

If Not FileExists( $sSavedSettings ) Then _CreateIni()

Global $bSettingsScheduler = IniRead( $sSavedSettings , 'Settings' , 'Scheduler' , 'True' ) ; Bool Scheduler Usage

$iSwatchCount  = 1
$iSwatchSize   = 19
$iSwatchArea   = $iSwatchSize - 1
$iSwatchMargin = $iSwatchSize + 4

$iFontSize    = 9
$iLabelHeight = 17
$iLabelOffset = Round(( $iSwatchSize - $iLabelHeight ) / 2 ) + 1

$iGroupTop  = 10
$iGroupLeft = 16

$iGridTop  = $iGroupTop  + 26 - $iSwatchArea
$iGridLeft = $iGroupLeft + 36 - $iSwatchArea

$iGroupHeight = ( 26 - $iSwatchArea ) + ( $iSwatchArea *  7 ) + ( $iSwatchMargin * 2 ) + $iSwatchSize + 6
$iGroupWidth  = ( 36 - $iSwatchArea ) + ( $iSwatchArea * 24 ) + $iSwatchSize + 20

$Scheduler = GUICreate( "Scheduler" , $iGroupLeft + $iGroupWidth + 16 , $iGroupTop + $iGroupHeight + 16 , -1 , -1 )

    GUISetOnEvent( $GUI_EVENT_CLOSE    , "_Quit" )

    GUICtrlCreateGroup(" Scheduler Table ", $iGroupLeft , $iGroupTop , $iGroupWidth , $iGroupHeight )
        GUICtrlSetFont( -1 , $iFontSize )

        ; Rows / Days in Week
        For $iDay = 1 To 7
            $iGridTop += $iSwatchArea
            $aHours = IniReadSection( $sSavedSettings , $aWeekLong[$iDay] )
            $aWeekLabel[$iDay] = GUICtrlCreateLabel( $aWeekShort[$iDay] , $iGroupLeft + 2 , $iGridTop + $iLabelOffset , 30 , $iLabelHeight , $SS_RIGHT )
                GUICtrlSetFont( -1 , $iFontSize , 700 )
            ; Columns / Hours in Day
            For $iHour = 1 To 24
                $aSwatches[$iSwatchCount][0] = GUICtrlCreateGraphic( $iGridLeft + ( $iHour * $iSwatchArea ) , $iGridTop , $iSwatchSize , $iSwatchSize )
                GUICtrlSetOnEvent(   $aSwatches[$iSwatchCount][0] , "_SwatchState" )
                GUICtrlSetColor(     $aSwatches[$iSwatchCount][0] , $sSwatchOutLine )
                GUICtrlSetState(     $aSwatches[$iSwatchCount][0] , $GUI_ONTOP ) ; Needed if on Tab Control
                $aSwatches[$iSwatchCount][1] = $aHours[$iHour][1]
                GUICtrlSetBkColor(   $aSwatches[$iSwatchCount][0] , $aSwatchNormal[$aSwatches[$iSwatchCount][1]] )
                _GUICtrl_OnHoverRegister( $aSwatches[$iSwatchCount][0] , "_SwatchHover" , "_SwatchLeave" )
                $iSwatchCount += 1
            Next
        Next

        $lbl_ShowDayHour = GUICtrlCreateLabel( "" , $iGridLeft + $iSwatchArea , $iGridTop + $iSwatchMargin + $iLabelOffset , 130 , $iLabelHeight )
            GUICtrlSetFont( -1 , $iFontSize )

        $chk_Scheduler = GUICtrlCreateCheckbox( "Enable Scheduler" , $iGridLeft + $iSwatchArea , $iGroupHeight - 14 , 115 , $iLabelHeight )
            GUICtrlSetFont( -1 , $iFontSize )
            GUICtrlSetOnEvent( $chk_Scheduler , "_SchedulerState" )

        $iSwatchCount = 1
        For $kk = 1 To 2
            $iGridTop += $iSwatchMargin
            $iSwatchOffset = 9
            For $ll = 1 To 4
                $aSwatchMock[$iSwatchCount][0] = GUICtrlCreateGraphic( $iGridLeft + ( $iSwatchArea * $iSwatchOffset ) , $iGridTop , $iSwatchSize , $iSwatchSize )
                    GUICtrlSetBkColor( -1 , $aSwatchNormal[$iSwatchCount] )
                    GUICtrlSetColor( -1 , $sSwatchOutLine )
                    GUICtrlSetState( -1 , $GUI_ONTOP ) ; Needed if on Tab Control
                $aSwatchMock[$iSwatchCount][1] = GUICtrlCreateLabel( "State " & $iSwatchCount , $iGridLeft + ( $iSwatchArea * $iSwatchOffset ) + $iSwatchArea + 4 , $iGridTop + $iLabelOffset , 40 , $iLabelHeight )
                    GUICtrlSetFont(  -1 , $iFontSize )

                $iSwatchOffset += 4
                $iSwatchCount  += 1
            Next
        Next

    GUICtrlCreateGroup("", -99, -99, 1, 1)

    ; Update Controls
    If $bSettingsScheduler = 'True' Then GUICtrlSetState( $chk_Scheduler , $GUI_CHECKED )
    _SchedulerState()

GUISetState( @SW_SHOW )

; Call the Function Every Minute
AdlibRegister( '_CheckScheduler' , 60 * 1000 )

While 1
    Sleep( 100 )
WEnd

Func _SchedulerState()
    If _getControlBoolValue( $chk_Scheduler ) Then
        For $ii = 1 To $aWeekLabel[0]
            GUICtrlSetState( $aWeekLabel[$ii] , $GUI_ENABLE )
        Next
        For $ii = 1 To $aSwatchMock[0][0]
            GUICtrlSetState( $aSwatchMock[$ii][1] , $GUI_ENABLE )
            GUICtrlSetBkColor( $aSwatchMock[$ii][0] , $aSwatchNormal[$ii] )
        Next
        For $ii = 1 To $aSwatches[0][0]
            GUICtrlSetState( $aSwatches[$ii][0] , $GUI_ENABLE )
            GUICtrlSetBkColor( $aSwatches[$ii][0] , $aSwatchNormal[$aSwatches[$ii][1]] )
        Next
    Else
        GUICtrlSetData( $lbl_ShowDayHour , '' )
        For $ii = 1 To $aWeekLabel[0]
            GUICtrlSetState( $aWeekLabel[$ii] , $GUI_DISABLE )
        Next
        For $ii = 1 To $aSwatchMock[0][0]
            GUICtrlSetState( $aSwatchMock[$ii][1] , $GUI_DISABLE )
            GUICtrlSetBkColor( $aSwatchMock[$ii][0] , $sSwatchDisabled )
        Next
        For $ii = 1 To $aSwatches[0][0]
            GUICtrlSetState( $aSwatches[$ii][0] , $GUI_DISABLE )
            GUICtrlSetBkColor( $aSwatches[$ii][0] , $sSwatchDisabled )
        Next
    EndIf
EndFunc

Func _SwatchState()
    Local $iCurrentSwatch = _ArraySearch( $aSwatches , @GUI_CTRLID , 1 , 0 , 0 , 0 , 1 , 0 )
    If $iCurrentSwatch <> -1 Then
        $aDayHour = _ReturnDayHour( $iCurrentSwatch )
        $aSwatches[$iCurrentSwatch][1] = _ToggleBase1ArrayValue( $aSwatches[$iCurrentSwatch][1] , $aSwatchNormal )
        GUICtrlSetBkColor( $aSwatches[$iCurrentSwatch][0] , $aSwatchHover[$aSwatches[$iCurrentSwatch][1]] )
        IniWrite( $sSavedSettings , $aDayHour[0] , $aDayHour[1] & "_00-" & $aDayHour[1] & "_59" , $aSwatches[$iCurrentSwatch][1] )
    EndIf
EndFunc

Func _SwatchHover( $iSwatchID )
    Local $iCurrentSwatch = _ArraySearch( $aSwatches , $iSwatchID , 1 , 0 , 0 , 0 , 1 , 0 )
    If $iCurrentSwatch <> -1 Then
        $aDayHour = _ReturnDayHour( $iCurrentSwatch )
        GUICtrlSetData( $lbl_ShowDayHour , $aDayHour[0] & ", " & $aDayHour[1] & ":00 - " & $aDayHour[1] & ":59" )
        GUICtrlSetBkColor( $aSwatches[$iCurrentSwatch][0] , $aSwatchHover[$aSwatches[$iCurrentSwatch][1]] )
    EndIf
EndFunc

Func _SwatchLeave( $iSwatchID )
    Local $iCurrentSwatch = _ArraySearch( $aSwatches , $iSwatchID , 1 , 0 , 0 , 0 , 1 , 0 )
    If $iCurrentSwatch <> -1 Then
        GUICtrlSetBkColor( $aSwatches[$iCurrentSwatch][0] , $aSwatchNormal[$aSwatches[$iCurrentSwatch][1]] )
    EndIf
EndFunc

Func _ReturnDayHour( $iHour )
    Local $aDayHour[2]
    Switch $iHour
        Case   1 To  24
            $aDayHour[0] = "Sunday"
            $aDayHour[1] = $iHour - 1
        Case  25 To  48
            $aDayHour[0] = "Monday"
            $aDayHour[1] = $iHour - 25
        Case  49 To  72
            $aDayHour[0] = "Tuesday"
            $aDayHour[1] = $iHour - 49
        Case  73 To  96
            $aDayHour[0] = "Wednesday"
            $aDayHour[1] = $iHour - 73
        Case  97 To 120
            $aDayHour[0] = "Thursday"
            $aDayHour[1] = $iHour - 97
        Case 121 To 144
            $aDayHour[0] = "Friday"
            $aDayHour[1] = $iHour - 121
        Case 145 To 168
            $aDayHour[0] = "Saturday"
            $aDayHour[1] = $iHour - 145
        Case Else
            $aDayHour[0] = "Unknown"
            $aDayHour[1] = -1
    EndSwitch

    Return $aDayHour
EndFunc

Func _Quit()
    IniWrite( $sSavedSettings , 'Settings' , 'Scheduler' , _getControlBoolValue( $chk_Scheduler ))
    Exit
EndFunc

Func _CreateIni()
    Local $sNewIni = ''
    $sNewIni &= '[Settings]'     & @CRLF
    $sNewIni &= 'Scheduler=True' & @CRLF
    $sNewIni &= @CRLF
    For $ii = 1 To $aWeekLong[0]
        $sNewIni &= '[' & $aWeekLong[$ii] & ']' & @CRLF
        For $jj = 0 To 23
            $sNewIni &= $jj & '_00-' & $jj & '_59=1' & @CRLF
        Next
        $sNewIni &= @CRLF
    Next
    FileWrite( $sSavedSettings , $sNewIni )
EndFunc

Func _ToggleBase1ArrayValue( $iValue , ByRef $aArray )
    $iValue += 1
    If $iValue >= UBound( $aArray ) Then $iValue = 1
    If $iValue <= 0 Then $iValue = 1
    Return $iValue
EndFunc

Func _CheckScheduler()
    If _getControlBoolValue( $chk_Scheduler ) Then
        While $aSwatches[(( @WDAY - 1 ) * 24 ) + @HOUR + 1][1] > 1
            Local $CurrentValue = $aSwatches[(( @WDAY - 1 ) * 24 ) + @HOUR + 1][1]
            Local $CurrentHour  = @HOUR
            Switch $CurrentValue
                Case 2 To 8
                    MsgBox( 0 , $aWeekLong[@WDAY] , @HOUR & ' is set to ' & $CurrentValue )
            EndSwitch
            While @HOUR = $CurrentHour
                Sleep( 60 * 1000 )
            WEnd
        WEnd
    EndIf
EndFunc

Func _getControlBoolValue( $sControl )
    If GUICtrlRead( $sControl ) = 1 Then
         Return True
    Else
        Return False
    EndIf
EndFunc
Edited by Nologic

Share this post


Link to post
Share on other sites
PhoenixXL

Example

#include <Array.au3>
#include <GUIConstants.au3>
#include <GUICtrlOnHover.au3>
#include <WinAPI.au3>
#include <SendMessage.au3>

Opt( "GuiOnEventMode" , 1 )

; Colors
$sSwatchOutLine  = '0x000000' ; Black
$sSwatchDisabled = '0xb7b7b7' ; Gray
$aSwatchNormal   = StringSplit( '0xc7b299|0xf7941d|0xfff200|0x00a651|0x0054a6|0x600080|0xB30086|0xcc1015' , '|' )
$aSwatchHover    = StringSplit( '0x998675|0xf26522|0xd8ca03|0x007236|0x003471|0x4D0066|0x990073|0x9e0b0f' , '|' )

$aWeekShort    = StringSplit( 'Sun|Mon|Tue|Wen|Thu|Fri|Sat' , '|' )
$aWeekLong     = StringSplit( 'Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday' , '|' )

Global $aSwatches[169][2] = [[168]]
Global $sSavedSettings = @ScriptDir & "\Scheduler.ini"

Global $aSwatchMock[UBound( $aSwatchNormal )][2] = [[UBound( $aSwatchNormal ) - 1]]
Global $aWeekLabel[8] = [7]

If Not FileExists( $sSavedSettings ) Then _CreateIni()

Global $bSettingsScheduler = IniRead( $sSavedSettings , 'Settings' , 'Scheduler' , 'True' ) ; Bool Scheduler Usage

$iSwatchCount  = 1
$iSwatchSize   = 19
$iSwatchArea   = $iSwatchSize - 1
$iSwatchMargin = $iSwatchSize + 4

$iFontSize    = 9
$iLabelHeight = 17
$iLabelOffset = Round(( $iSwatchSize - $iLabelHeight ) / 2 ) + 1

$iGroupTop  = 10
$iGroupLeft = 16

$iGridTop  = $iGroupTop  + 26 - $iSwatchArea
$iGridLeft = $iGroupLeft + 36 - $iSwatchArea

$iGroupHeight = ( 26 - $iSwatchArea ) + ( $iSwatchArea *  7 ) + ( $iSwatchMargin * 2 ) + $iSwatchSize + 6
$iGroupWidth  = ( 36 - $iSwatchArea ) + ( $iSwatchArea * 24 ) + $iSwatchSize + 20

Global Const $Scheduler = GUICreate( "Scheduler" , $iGroupLeft + $iGroupWidth + 16 , $iGroupTop + $iGroupHeight + 16 , -1 , -1 )

    GUISetOnEvent( $GUI_EVENT_CLOSE    , "_Quit" )

    GUICtrlCreateGroup(" Scheduler Table ", $iGroupLeft , $iGroupTop , $iGroupWidth , $iGroupHeight )
        GUICtrlSetFont( -1 , $iFontSize )

        ; Rows / Days in Week
        For $iDay = 1 To 7
            $iGridTop += $iSwatchArea
            $aHours = IniReadSection( $sSavedSettings , $aWeekLong[$iDay] )
            $aWeekLabel[$iDay] = GUICtrlCreateLabel( $aWeekShort[$iDay] , $iGroupLeft + 2 , $iGridTop + $iLabelOffset , 30 , $iLabelHeight , $SS_RIGHT )
                GUICtrlSetFont( -1 , $iFontSize , 700 )
            ; Columns / Hours in Day
            For $iHour = 1 To 24
                $aSwatches[$iSwatchCount][0] = GUICtrlCreateGraphic( $iGridLeft + ( $iHour * $iSwatchArea ) , $iGridTop , $iSwatchSize , $iSwatchSize )
                GUICtrlSetOnEvent(   $aSwatches[$iSwatchCount][0] , "_SwatchState" )
                GUICtrlSetColor(     $aSwatches[$iSwatchCount][0] , $sSwatchOutLine )
                GUICtrlSetState(     $aSwatches[$iSwatchCount][0] , $GUI_ONTOP ) ; Needed if on Tab Control
                $aSwatches[$iSwatchCount][1] = $aHours[$iHour][1]
                GUICtrlSetBkColor(   $aSwatches[$iSwatchCount][0] , $aSwatchNormal[$aSwatches[$iSwatchCount][1]] )
                _GUICtrl_OnHoverRegister( $aSwatches[$iSwatchCount][0] , "_SwatchHover" , "_SwatchLeave" )
                $iSwatchCount += 1
            Next
        Next

        $lbl_ShowDayHour = GUICtrlCreateLabel( "" , $iGridLeft + $iSwatchArea , $iGridTop + $iSwatchMargin + $iLabelOffset , 130 , $iLabelHeight )
            GUICtrlSetFont( -1 , $iFontSize )

        $chk_Scheduler = GUICtrlCreateCheckbox( "Enable Scheduler" , $iGridLeft + $iSwatchArea , $iGroupHeight - 14 , 115 , $iLabelHeight )
            GUICtrlSetFont( -1 , $iFontSize )
            GUICtrlSetOnEvent( $chk_Scheduler , "_SchedulerState" )

        $iSwatchCount = 1
        For $kk = 1 To 2
            $iGridTop += $iSwatchMargin
            $iSwatchOffset = 9
            For $ll = 1 To 4
                $aSwatchMock[$iSwatchCount][0] = GUICtrlCreateGraphic( $iGridLeft + ( $iSwatchArea * $iSwatchOffset ) , $iGridTop , $iSwatchSize , $iSwatchSize )
                    GUICtrlSetBkColor( -1 , $aSwatchNormal[$iSwatchCount] )
                    GUICtrlSetColor( -1 , $sSwatchOutLine )
                    GUICtrlSetState( -1 , $GUI_ONTOP ) ; Needed if on Tab Control
                $aSwatchMock[$iSwatchCount][1] = GUICtrlCreateLabel( "State " & $iSwatchCount , $iGridLeft + ( $iSwatchArea * $iSwatchOffset ) + $iSwatchArea + 4 , $iGridTop + $iLabelOffset , 40 , $iLabelHeight )
                    GUICtrlSetFont(  -1 , $iFontSize )

                $iSwatchOffset += 4
                $iSwatchCount  += 1
            Next
        Next

    GUICtrlCreateGroup("", -99, -99, 1, 1)

    ; Update Controls
    If $bSettingsScheduler = 'True' Then GUICtrlSetState( $chk_Scheduler , $GUI_CHECKED )
    _SchedulerState()

GUISetState( @SW_SHOW )

; Call the Function Every Minute
AdlibRegister( '_CheckScheduler' , 60 * 1000 )

While 1
    Sleep( 100 )
WEnd

Func _SchedulerState()

    _SendMessage($Scheduler, $WM_SETREDRAW, False)

    If _getControlBoolValue( $chk_Scheduler ) Then
        For $ii = 1 To $aWeekLabel[0]
            GUICtrlSetState( $aWeekLabel[$ii] , $GUI_ENABLE )
        Next
        For $ii = 1 To $aSwatchMock[0][0]
            GUICtrlSetState( $aSwatchMock[$ii][1] , $GUI_ENABLE )
            GUICtrlSetBkColor( $aSwatchMock[$ii][0] , $aSwatchNormal[$ii] )
        Next
        For $ii = 1 To $aSwatches[0][0]
            GUICtrlSetState( $aSwatches[$ii][0] , $GUI_ENABLE )
            GUICtrlSetBkColor( $aSwatches[$ii][0] , $aSwatchNormal[$aSwatches[$ii][1]] )
        Next
    Else
        GUICtrlSetData( $lbl_ShowDayHour , '' )
        For $ii = 1 To $aWeekLabel[0]
            GUICtrlSetState( $aWeekLabel[$ii] , $GUI_DISABLE )
        Next
        For $ii = 1 To $aSwatchMock[0][0]
            GUICtrlSetState( $aSwatchMock[$ii][1] , $GUI_DISABLE )
            GUICtrlSetBkColor( $aSwatchMock[$ii][0] , $sSwatchDisabled )
        Next
        For $ii = 1 To $aSwatches[0][0]
            GUICtrlSetState( $aSwatches[$ii][0] , $GUI_DISABLE )
            GUICtrlSetBkColor( $aSwatches[$ii][0] , $sSwatchDisabled )
        Next
    EndIf

    _SendMessage($Scheduler, $WM_SETREDRAW, True)
    _WinAPI_RedrawWindow($Scheduler)

EndFunc

Func _SwatchState()
    Local $iCurrentSwatch = _ArraySearch( $aSwatches , @GUI_CTRLID , 1 , 0 , 0 , 0 , 1 , 0 )
    If $iCurrentSwatch <> -1 Then
        $aDayHour = _ReturnDayHour( $iCurrentSwatch )
        $aSwatches[$iCurrentSwatch][1] = _ToggleBase1ArrayValue( $aSwatches[$iCurrentSwatch][1] , $aSwatchNormal )
        GUICtrlSetBkColor( $aSwatches[$iCurrentSwatch][0] , $aSwatchHover[$aSwatches[$iCurrentSwatch][1]] )
        IniWrite( $sSavedSettings , $aDayHour[0] , $aDayHour[1] & "_00-" & $aDayHour[1] & "_59" , $aSwatches[$iCurrentSwatch][1] )
    EndIf
EndFunc

Func _SwatchHover( $iSwatchID )
    Local $iCurrentSwatch = _ArraySearch( $aSwatches , $iSwatchID , 1 , 0 , 0 , 0 , 1 , 0 )
    If $iCurrentSwatch <> -1 Then
        $aDayHour = _ReturnDayHour( $iCurrentSwatch )
        GUICtrlSetData( $lbl_ShowDayHour , $aDayHour[0] & ", " & $aDayHour[1] & ":00 - " & $aDayHour[1] & ":59" )
        GUICtrlSetBkColor( $aSwatches[$iCurrentSwatch][0] , $aSwatchHover[$aSwatches[$iCurrentSwatch][1]] )
    EndIf
EndFunc

Func _SwatchLeave( $iSwatchID )
    Local $iCurrentSwatch = _ArraySearch( $aSwatches , $iSwatchID , 1 , 0 , 0 , 0 , 1 , 0 )
    If $iCurrentSwatch <> -1 Then
        GUICtrlSetBkColor( $aSwatches[$iCurrentSwatch][0] , $aSwatchNormal[$aSwatches[$iCurrentSwatch][1]] )
    EndIf
EndFunc

Func _ReturnDayHour( $iHour )
    Local $aDayHour[2]
    Switch $iHour
        Case   1 To  24
            $aDayHour[0] = "Sunday"
            $aDayHour[1] = $iHour - 1
        Case  25 To  48
            $aDayHour[0] = "Monday"
            $aDayHour[1] = $iHour - 25
        Case  49 To  72
            $aDayHour[0] = "Tuesday"
            $aDayHour[1] = $iHour - 49
        Case  73 To  96
            $aDayHour[0] = "Wednesday"
            $aDayHour[1] = $iHour - 73
        Case  97 To 120
            $aDayHour[0] = "Thursday"
            $aDayHour[1] = $iHour - 97
        Case 121 To 144
            $aDayHour[0] = "Friday"
            $aDayHour[1] = $iHour - 121
        Case 145 To 168
            $aDayHour[0] = "Saturday"
            $aDayHour[1] = $iHour - 145
        Case Else
            $aDayHour[0] = "Unknown"
            $aDayHour[1] = -1
    EndSwitch

    Return $aDayHour
EndFunc

Func _Quit()
    IniWrite( $sSavedSettings , 'Settings' , 'Scheduler' , _getControlBoolValue( $chk_Scheduler ))
    Exit
EndFunc

Func _CreateIni()
    Local $sNewIni = ''
    $sNewIni &= '[Settings]'     & @CRLF
    $sNewIni &= 'Scheduler=True' & @CRLF
    $sNewIni &= @CRLF
    For $ii = 1 To $aWeekLong[0]
        $sNewIni &= '[' & $aWeekLong[$ii] & ']' & @CRLF
        For $jj = 0 To 23
            $sNewIni &= $jj & '_00-' & $jj & '_59=1' & @CRLF
        Next
        $sNewIni &= @CRLF
    Next
    FileWrite( $sSavedSettings , $sNewIni )
EndFunc

Func _ToggleBase1ArrayValue( $iValue , ByRef $aArray )
    $iValue += 1
    If $iValue >= UBound( $aArray ) Then $iValue = 1
    If $iValue <= 0 Then $iValue = 1
    Return $iValue
EndFunc

Func _CheckScheduler()
    If _getControlBoolValue( $chk_Scheduler ) Then
        While $aSwatches[(( @WDAY - 1 ) * 24 ) + @HOUR + 1][1] > 1
            Local $CurrentValue = $aSwatches[(( @WDAY - 1 ) * 24 ) + @HOUR + 1][1]
            Local $CurrentHour  = @HOUR
            Switch $CurrentValue
                Case 2 To 8
                    MsgBox( 0 , $aWeekLong[@WDAY] , @HOUR & ' is set to ' & $CurrentValue )
            EndSwitch
            While @HOUR = $CurrentHour
                Sleep( 60 * 1000 )
            WEnd
        WEnd
    EndIf
EndFunc

Func _getControlBoolValue( $sControl )
    If GUICtrlRead( $sControl ) = 1 Then
         Return True
    Else
        Return False
    EndIf
EndFunc

Check these links

WM_SETREDRAW

RedrawWindow

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
Nologic

You are without a doubt my hero. :)

Very clean and simple, thank you very very much for your help.

I was seriously stumped.

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  

×