Kalender

  • Guten Tag ;P

    Hab mal ne Frage...
    Wie bekommt man es hin bei einem erstellten Moinatskalender nach dem klicken auf ein Datum die Hintergrundfarbe des
    gewählten datums zu ändern?
    Ich habs mit _GUICtrlMonthCal_SetColor versuch aber es klappt einfach net.
    Bitte hilft mir jemand :)


    lg


    Einmal editiert, zuletzt von zwockel (22. Mai 2011 um 19:52)

  • Hab's gerade bei mir ausprobiert. _GUICtrlMonthCal_SetColor hat null Effekt, egal welcher Bereich umgefärbt werden soll.
    Windows 7 64 Bit, AutoIt 3.6.6.1.
    Aber dieser Link funktioniert. Wenn ich es richtig verstehe, dann muss mit Funktion _ThemeLevel das Thema angepasst werden.

    • Offizieller Beitrag

    Ändern der Hintergrundfarbe ist meines Wissens nicht möglich. Du kannst aber Tage markieren, indem sie fett geschrieben werden.
    Standardmäßig ist das recht umständlich, da eine Maske erstellt werden muß, die die markierten Tage darstellt. Deshalb habe ich dazu die entsprechende Funktion (_GUICtrlMonthCal_SetDayState) umgearbeitet:

    Spoiler anzeigen
    [autoit]

    #include <GuiConstantsEx.au3>
    #include <GuiMonthCal.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt('MustDeclareVars', 1)

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("Month Calendar Set Day State", 400, 300)
    Local $hMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_DAYSTATE), 0x00000000)

    [/autoit] [autoit][/autoit] [autoit]

    __GUICtrlMonthCal_SetDayState($hMonthCal, '1,5,6,8,12,22,23,24,30', ',')

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Sleep(1500)
    __GUICtrlMonthCal_SetDayState($hMonthCal, '1,2,3,12,13,14,29,30', ',')
    Sleep(1500)
    __GUICtrlMonthCal_SetDayState($hMonthCal, '11', ',')
    Sleep(1500)
    __GUICtrlMonthCal_SetDayState($hMonthCal, '') ; unset all

    [/autoit] [autoit][/autoit] [autoit]

    ; same with array
    Sleep(1500)
    Local $a[9] = [1,5,6,8,12,22,23,24,30]
    __GUICtrlMonthCal_SetDayState($hMonthCal, $a)

    [/autoit] [autoit][/autoit] [autoit]

    Sleep(1500)
    Local $b[8] = [1,2,3,12,13,14,29,30]
    __GUICtrlMonthCal_SetDayState($hMonthCal, $b)

    [/autoit] [autoit][/autoit] [autoit]

    Sleep(1500)
    Local $c[1] = [11]
    __GUICtrlMonthCal_SetDayState($hMonthCal, $c)

    [/autoit] [autoit][/autoit] [autoit]

    Sleep(1500)
    Local $d[1] = ['']
    __GUICtrlMonthCal_SetDayState($hMonthCal, $d)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: __GUICtrlMonthCal_SetDayState
    ; Description ...: Sets the day states for all months that are currently visible
    ; Syntax.........: _GUICtrlMonthCal_SetDayState($hWnd, $sDays [, $sDelim = Default])
    ; Parameters ....: $hWnd - Handle to control
    ; $s_a_Days - An delimited string or an array of days, whose state to set, with '' unset all
    ; $sDelim - Delimiter in $sDays, by default char from Opt('GUIDataSeparatorChar')
    ; Return values .: Success - True
    ; Failure - False
    ; Author ........: Paul Campbell (PaulIA)
    ; Modified.......: Gary Frost (gafrost), BugFix
    ; Remarks .......: You must create the calendar control with the $MCS_DAYSTATE style if you want to use this function
    ; Related .......:
    ; Link ..........:
    ; Example .......: Yes
    ; ===============================================================================================================================
    Func __GUICtrlMonthCal_SetDayState($hWnd, $s_a_Days, $sDelim = Default)
    If $Debug_MC Then __UDF_ValidateClassName($hWnd, $__MONTHCALCONSTANT_ClassName)
    Local $iRet

    [/autoit] [autoit][/autoit] [autoit]

    Local $iMasks = _GUICtrlMonthCal_GetMonthRangeSpan($hWnd, True)
    Local $tBuffer = DllStructCreate("int;int;int")
    Local $pBuffer = DllStructGetPtr($tBuffer)
    ;==================================================== BugFix changes:
    Local $aMasks[$iMasks]
    If $sDelim = Default Then $sDelim = Opt('GUIDataSeparatorChar')
    If (( Not IsArray($s_a_Days) ) And ($s_a_Days = '') ) Or _
    (( IsArray($s_a_Days) ) And ($s_a_Days[0] = '') ) Then
    $aMasks[1] = '0x0'
    Else
    Local $aDays
    If (Not IsArray($s_a_Days)) Then
    $aDays = StringSplit($s_a_Days, $sDelim, 2)
    Else
    $aDays = $s_a_Days
    EndIf
    Local $aHex[8] = [0,0,0,0,0,0,0,0], $pos, $mask = ''
    For $i = 0 To UBound($aDays) -1
    Select
    Case $aDays[$i] < 5
    $pos = 0
    Case $aDays[$i] < 9
    $pos = 1
    Case $aDays[$i] < 13
    $pos = 2
    Case $aDays[$i] < 17
    $pos = 3
    Case $aDays[$i] < 21
    $pos = 4
    Case $aDays[$i] < 25
    $pos = 5
    Case $aDays[$i] < 29
    $pos = 6
    Case Else
    $pos = 7
    EndSelect
    $aDays[$i] -= $pos * 4
    $aHex[$pos] += 2 ^ ($aDays[$i]-1)
    Next
    For $i = 0 To UBound($aHex) -1
    $mask = Hex($aHex[$i], 1) & $mask
    Next
    $aMasks[1] = '0x' & $mask
    EndIf
    ;====================================================
    For $iI = 0 To $iMasks - 1
    DllStructSetData($tBuffer, $iI + 1, $aMasks[$iI])
    Next
    If IsHWnd($hWnd) Then
    If _WinAPI_InProcess($hWnd, $_mc_ghMCLastWnd) Then
    $iRet = _SendMessage($hWnd, $MCM_SETDAYSTATE, $iMasks, $pBuffer, 0, "wparam", "ptr")
    Else
    Local $iBuffer = DllStructGetSize($tBuffer)
    Local $tMemMap
    Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
    _MemWrite($tMemMap, $pBuffer)
    $iRet = _SendMessage($hWnd, $MCM_SETDAYSTATE, $iMasks, $pMemory, 0, "wparam", "ptr")
    _MemFree($tMemMap)
    EndIf
    Else
    $iRet = GUICtrlSendMsg($hWnd, $MCM_SETDAYSTATE, $iMasks, $pBuffer)
    EndIf
    Return $iRet <> 0
    EndFunc ;==>__GUICtrlMonthCal_SetDayState

    [/autoit]
  • Schön, dass es funktioniert!