Sign in to follow this  
Followers 0
Marcelos

Graphical Control week planner

3 posts in this topic

Hi

Im looking for a control like the one that used in AD to select the logon hours.

Im thinking to create one ,if i dont find any alternative for having a way to give the user to select hours on the week.

how do i select only a cell in a list and change the color of the cell if the mouse buton is clicked and selecting many cells.

thanks in advance.

Share this post


Link to post
Share on other sites



Marcelos,

Perhaps this might give you a couple of pointers as to how you might proceed: ;)

#include <GUIConstantsEx.au3>

#Include <GuiScrollBars_Ex.au3>

Global $iItems = 50        ; Number of items in list
Global $iDisplayItems = 20 ; Number of items in GUI
Global $aLabelID[$iItems]  ; ControlIDs of labels
Global $aData[$iItems][2]  ; Data and colour state of labels

; Fill data array
For $i = 0 To UBound($aData) - 1
    $aData[$i][0] = $i & " - " & $i & " - " & $i & " - " & $i ; Data
    $aData[$i][1] = 0                                         ; State
Next

; Create GUI
$hGui = GUICreate("Scroll Colour Line List", 420, 20 + $iDisplayItems * 20)

; Create "list"
For $i = 0 To $iItems - 1
    $aLabelID[$i] = GUICtrlCreateLabel($aData[$i][0], 10, 10 + ($i * 20), 380, 20)
Next

GUISetState()

; Generate scrollbars
_GUIScrollbars_Generate($hGui, 0, 4 + ($iItems * 20))

While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        ; Click on label so change colour
        Case $aLabelID[0] To $aLabelID[19]
            $iIndex = $iMsg - $aLabelID[0]
            ; Toggle colour data
            $aData[$iIndex][1] = Not $aData[$iIndex][1]
            ; Change line colour
            Switch $aData[$iIndex][1]
                Case 0
                    GUICtrlSetColor($aLabelID[$iIndex], 0x000000)
                Case 1
                    GUICtrlSetColor($aLabelID[$iIndex], 0xFF0000)
            EndSwitch
    EndSwitch

WEnd
M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hi Melba23

Thanks for the hint. Still i took another aproach

this code permits to select hours on the week and save to a INI file.

the question here is. how i do the selection of the hours, instead of clicking square by square, to select them by clicking and also when the mouse is over and clicked. :-)

 Marry Crhismass!!! and happy new year

;--- includes
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
;----- variables
$ConfigFileINI="config.ini"
Global $B_TT_SCH[8][24]
Global $TTA[8]
Global $TTA[23]
Global $TimeTrackerActive[8][25]
$fFlag = False
$buttonClose=""
$B_TT_Save=""
$FormTimeTrackerSettings=""
; config init
    if FileExists($ConfigFileINI) then
        TT_createTimeArray()
    Else
        ;set a default hours
        For $i=1 To 7
            For $j=0 To 23
                If $i>1 And $i<7 Then
                    If $j>9 And $j<19 Then
                        $TimeTrackerActive[$i][$j]=True
                    Else
                        $TimeTrackerActive[$i][$j]=False
                    endif
                Else
                    $TimeTrackerActive[$i][$j]=False
                endif
            next
        next
        IniWrite($ConfigFileINI, "TimeTracker", "TimeTrackerActive1", "0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0")
        IniWrite($ConfigFileINI, "TimeTracker", "TimeTrackerActive2", "0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|0|0|0|0|0")
        IniWrite($ConfigFileINI, "TimeTracker", "TimeTrackerActive3", "0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|0|0|0|0|0")
        IniWrite($ConfigFileINI, "TimeTracker", "TimeTrackerActive4", "0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|0|0|0|0|0")
        IniWrite($ConfigFileINI, "TimeTracker", "TimeTrackerActive5", "0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|0|0|0|0|0")
        IniWrite($ConfigFileINI, "TimeTracker", "TimeTrackerActive6", "0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|0|0|0|0|0")
        IniWrite($ConfigFileINI, "TimeTracker", "TimeTrackerActive7", "0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0")
        TT_createTimeArray()
    EndIf

    TimeTrackerSettings()
;#########################################################################
Func TimeTrackerSettings()
    $left=20
    $top=30
    $FormTimeTrackerSettings= GUICreate("Time Tracker Settings", 340, 340, -1, -1)
    GUICtrlCreateLabel("",$left, $top-8, 290, 1,$SS_BLACKFRAME)
    ;------
    $lado=12
    GUICtrlCreateLabel("AM", 1, $top-3, 17, 17)
    GUICtrlCreateLabel("PM", 310, $top-3, 17, 17)
    For $i=0 To 12
        If  Mod ($i,2)=0 Then
            $f=0
            If $i<5 Then $f=1
            GUICtrlCreateLabel($i, $left+($i*($lado+$f)), $top, $lado, $lado)
        endif
    next
    For $i=1 To 11
        If  Mod ($i,2)=0 Then
            $f=0
            If $i<5 Then $f=0
            GUICtrlCreateLabel($i, $left+(($i+12)*($lado+$f)), $top, $lado, $lado)
        endif
    next

    For $i=0 To 23
        For $j=1 To 7
            $B_TT_SCH[$j][$i]= GUICtrlCreateLabel("", $left+($i*$lado), ($top)+($lado*$j), $lado, $lado,$SS_SUNKEN)
            If $TimeTrackerActive[$j][$i]=1 Then
                GuiCtrlSetBkColor($B_TT_SCH[$j][$i], 0x00ff00)
            Else
                GuiCtrlSetBkColor($B_TT_SCH[$j][$i], 0xAAAAAA)
            endif
        next
    next

    Local $week[7]=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]
    $font = "Arial"
    $top=$top+10
    for $i=0 To 6
        GUICtrlCreateLabel($week[$i], 310, ($top)+($lado*$i), 20, 10)
        GUICtrlSetFont(-1, 8, 400, 4, $font)

    next

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    $top=155
    GUICtrlCreateLabel("",$left, $top-5, 290, 1,$SS_BLACKFRAME)

    $B_TT_Save= GUICtrlCreateButton("Save", 175, $top+80, 57, 25)
    $buttonClose = GUICtrlCreateButton("Close", 255, $top+80, 57, 25)

    GUISetState(@SW_SHOW)
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND_2")


    While 1
        sleep(200)
        If $fFlag = True Then
            $fFlag = False
            GUISetState(@SW_HIDE,$FormTimeTrackerSettings)
            GUIDelete($FormTimeTrackerSettings)
            ExitLoop
        EndIf
    WEnd

endfunc
;#########################################################################
Func TT_createTimeArray()
    $TTA[1]=IniRead($ConfigFileINI, "TimeTracker", "TimeTrackerActive1", "0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0")
    $TTA[2]=IniRead($ConfigFileINI, "TimeTracker", "TimeTrackerActive2", "0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|0|0|0|0|0")
    $TTA[3]=IniRead($ConfigFileINI, "TimeTracker", "TimeTrackerActive3", "0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|0|0|0|0|0")
    $TTA[4]=IniRead($ConfigFileINI, "TimeTracker", "TimeTrackerActive4", "0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|0|0|0|0|0")
    $TTA[5]=IniRead($ConfigFileINI, "TimeTracker", "TimeTrackerActive5", "0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|0|0|0|0|0")
    $TTA[6]=IniRead($ConfigFileINI, "TimeTracker", "TimeTrackerActive6", "0|0|0|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|1|0|0|0|0|0")
    $TTA[7]=IniRead($ConfigFileINI, "TimeTracker", "TimeTrackerActive7", "0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0")
    For $i=1 To 7
        $TTC=StringSplit($TTA[$i],"|",2)
        For $j=0 To 23
            $TimeTrackerActive[$i][$j]=$TTC[$j]
        next
    next
endfunc
;#########################################################################
Func WM_COMMAND_2($hWnd, $iMsg, $iwParam, $ilParam)  ; Handle WM_COMMAND messages
    #forceref $hWnd, $iMsg, $ilParam

    Local $nNotifyCode = _HiWord($iwParam)
    Local $nID = _LoWord($iwParam)

    Switch $nID
        Case $buttonClose
            $fFlag = True
            Return $GUI_RUNDEFMSG
        Case $GUI_EVENT_CLOSE
            $fFlag = True
            Return $GUI_RUNDEFMSG
;-- save to INI file
        Case $B_TT_Save
            ; --- hours
            For $j=1 To 7
                $TTA[$j]=""
                For $i=0 To 23
                    $TTA[$j]=$TTA[$j]& "|" & $TimeTrackerActive[$j][$i]
                next
                $saved=IniWrite($ConfigFileINI, "TimeTracker", "TimeTrackerActive" & $j, $TTA[$j])
            next

            if $saved=true then
                MsgBox(4096, "Settings save", "The new settings were saved" ,10)
            Else
                MsgBox(4096, "Settings save", "Error saving the new settings." ,10)
            endif

        Case $B_TT_SCH[1][0] To $B_TT_SCH[7][23]
            Local $aGetCursor = GUIGetCursorInfo($FormTimeTrackerSettings)
            For $i=0 To 23
                For $j=1 To 7
                    If  $aGetCursor[4] = $B_TT_SCH[$j][$i]  Then
                        If $TimeTrackerActive[$j][$i]=1 Then
                            GUICtrlSetBkColor($aGetCursor[4], 0xaaaaaa)
                            $TimeTrackerActive[$j][$i]=0
                        Else
                            GUICtrlSetBkColor($aGetCursor[4], 0x00ff00)
                            $TimeTrackerActive[$j][$i]=1
                        endif
                    EndIf
                next
            next
    EndSwitch
EndFunc
;#########################################################################
Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc

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  
Followers 0