sowas ähnliches hatte ich während meiner Azubi-Zeit mal gebaut.
Ja, schön, das kann man sicher auch gut gebrauchen... hier eine etwas erweiterte Version, die nicht nur auf Mausklick, sondern auch auf Tastatur (Pfeiltasten/PageUp/PageDown) und Mausrad reagiert.
AutoIt
;-- TIME_STAMP 2020-11-27 20:08:41 v 0.1
#include <GUIConstantsEx.au3>
#include <GuiMonthCal.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
Global $g_hMonthCal, $g_idKW, $g_iYear = @YEAR, $g_iMonth = @MON, $g_iDay = @MDAY, $g_iKW = _WeekNumberISO($g_iYear, $g_iMonth, $g_iDay)
Example()
Func Example()
Local $hGUI
; Create GUI
$hGUI = GUICreate("KW_Anzeiger 3.0", 400, 170)
$g_hMonthCal = _GUICtrlMonthCal_Create($hGUI, 4, 4, $WS_BORDER)
$g_idKW = GUICtrlCreateLabel(StringFormat('%02d', $g_iKW), 192, 4, 188, 162)
GUICtrlSetFont(-1, 128)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
; Loop until the user exits.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>Example
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $wParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $g_hMonthCal
Switch $iCode
Case $MCN_GETDAYSTATE ; Sent by a month calendar control to request information about how individual days should be displayed
$tInfo = DllStructCreate($tagNMDAYSTATE, $lParam)
_DebugPrint("$MCN_GETDAYSTATE" & @CRLF & _
"--> hWndFrom : " & $hWndFrom & @CRLF & _
"--> IDFrom : " & $iIDFrom & @CRLF & _
"--> Code : " & $iCode & @CRLF & _
"--> Year : " & DllStructGetData($tInfo, "Year") & @CRLF & _
"--> Month : " & DllStructGetData($tInfo, "Month") & @CRLF & _
"--> DOW : " & DllStructGetData($tInfo, "DOW") & @CRLF & _
"--> Day : " & DllStructGetData($tInfo, "Day") & @CRLF & _
"--> Hour : " & DllStructGetData($tInfo, "Hour") & @CRLF & _
"--> Minute : " & DllStructGetData($tInfo, "Minute") & @CRLF & _
"--> Second : " & DllStructGetData($tInfo, "Second") & @CRLF & _
"--> MSecond : " & DllStructGetData($tInfo, "MSecond") & @CRLF & _
"--> DayState : " & DllStructGetData($tInfo, "DayState") & @CRLF & _
"--> pDayState : " & DllStructGetData($tInfo, "pDayState"))
; Address of an array of MONTHDAYSTATE (DWORD bit field that holds the state of each day in a month)
; Each bit (1 through 31) represents the state of a day in a month. If a bit is on, the corresponding day will
; be displayed in bold; otherwise it will be displayed with no emphasis.
; No return value
Case $MCN_SELCHANGE ; Sent by a month calendar control when the currently selected date or range of dates changes
$tInfo = DllStructCreate($tagNMSELCHANGE, $lParam)
$g_iYear = DllStructGetData($tInfo, "BegYear")
$g_iMonth = DllStructGetData($tInfo, "BegMonth")
$g_iDay = DllStructGetData($tInfo, "BegDay")
Local $iKW = _WeekNumberISO($g_iYear, $g_iMonth, $g_iDay)
If $iKW <> $g_iKW Then
$g_iKW = $iKW
GUICtrlSetData($g_idKW, StringFormat('%02d', $g_iKW))
EndIf
_DebugPrint("$MCN_SELCHANGE" & @CRLF & _
"--> hWndFrom : " & $hWndFrom & @CRLF & _
"--> IDFrom : " & $iIDFrom & @CRLF & _
"--> Code : " & $iCode & @CRLF & _
"--> BegYear : " & DllStructGetData($tInfo, "BegYear") & @CRLF & _
"--> BegMonth : " & DllStructGetData($tInfo, "BegMonth") & @CRLF & _
"--> BegDOW : " & DllStructGetData($tInfo, "BegDOW") & @CRLF & _
"--> BegDay : " & DllStructGetData($tInfo, "BegDay") & @CRLF & _
"--> BegHour : " & DllStructGetData($tInfo, "BegHour") & @CRLF & _
"--> BegMinute : " & DllStructGetData($tInfo, "BegMinute") & @CRLF & _
"--> BegSecond : " & DllStructGetData($tInfo, "BegSecond") & @CRLF & _
"--> BegMSeconds : " & DllStructGetData($tInfo, "BegMSeconds") & @CRLF & _
"--> EndYear : " & DllStructGetData($tInfo, "EndYear") & @CRLF & _
"--> EndMonth : " & DllStructGetData($tInfo, "EndMonth") & @CRLF & _
"--> EndDOW : " & DllStructGetData($tInfo, "EndDOW") & @CRLF & _
"--> EndDay : " & DllStructGetData($tInfo, "EndDay") & @CRLF & _
"--> EndHour : " & DllStructGetData($tInfo, "EndHour") & @CRLF & _
"--> EndMinute : " & DllStructGetData($tInfo, "EndMinute") & @CRLF & _
"--> EndSecond : " & DllStructGetData($tInfo, "EndSecond") & @CRLF & _
"--> EndMSeconds : " & DllStructGetData($tInfo, "EndMSeconds") & @CRLF & _
">-> $g_iYear : " & $g_iYear & @CRLF & _
">-> $g_iMonth : " & $g_iMonth & @CRLF & _
">-> $g_iDay : " & $g_iDay & @CRLF & _
">-> $g_iKW : " & $g_iKW)
; No return value
Case $MCN_SELECT ; Sent by a month calendar control when the user makes an explicit date selection within a month calendar control
$tInfo = DllStructCreate($tagNMSELCHANGE, $lParam)
_DebugPrint("$MCN_SELECT" & @CRLF & _
"--> hWndFrom : " & $hWndFrom & @CRLF & _
"--> IDFrom : " & $iIDFrom & @CRLF & _
"--> Code : " & $iCode & @CRLF & _
"--> BegYear : " & DllStructGetData($tInfo, "BegYear") & @CRLF & _
"--> BegMonth : " & DllStructGetData($tInfo, "BegMonth") & @CRLF & _
"--> BegDOW : " & DllStructGetData($tInfo, "BegDOW") & @CRLF & _
"--> BegDay : " & DllStructGetData($tInfo, "BegDay") & @CRLF & _
"--> BegHour : " & DllStructGetData($tInfo, "BegHour") & @CRLF & _
"--> BegMinute : " & DllStructGetData($tInfo, "BegMinute") & @CRLF & _
"--> BegSecond : " & DllStructGetData($tInfo, "BegSecond") & @CRLF & _
"--> BegMSeconds : " & DllStructGetData($tInfo, "BegMSeconds") & @CRLF & _
"--> EndYear : " & DllStructGetData($tInfo, "EndYear") & @CRLF & _
"--> EndMonth : " & DllStructGetData($tInfo, "EndMonth") & @CRLF & _
"--> EndDOW : " & DllStructGetData($tInfo, "EndDOW") & @CRLF & _
"--> EndDay : " & DllStructGetData($tInfo, "EndDay") & @CRLF & _
"--> EndHour : " & DllStructGetData($tInfo, "EndHour") & @CRLF & _
"--> EndMinute : " & DllStructGetData($tInfo, "EndMinute") & @CRLF & _
"--> EndSecond : " & DllStructGetData($tInfo, "EndSecond") & @CRLF & _
"--> EndMSeconds : " & DllStructGetData($tInfo, "EndMSeconds"))
; No return value
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @CRLF & _
"+======================================================" & @CRLF & _
"-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
"+======================================================" & @CRLF)
EndFunc ;==>_DebugPrint
Alles anzeigen
Hier noch eine überarbeitete Version aus #Post 1, die alle Wochentage anzeigt. Nicht benötigte Spalten/Wochentage können mit _ArrayExtract/_ArrayColDelete entfernen werden.
AutoIt: _GetKalenderwochen_Example.au3
;-- TIME_STAMP 2020-11-28 15:49:47 v 0.1
#include <Debug.au3>
#include '_GetKalenderwochen.au3'
Local $aKW = _GetKalenderwochen(@YEAR)
_DebugArrayDisplay($aKW, '$aKW ' & @YEAR, '', 0, Default, 'KW|Mo.|Di.|Mi.|Do.|Fr.|Sa.|So.')
;~ Row|KW|Mo.|Di.|Mi.|Do.|Fr.|Sa.|So.
;~ Row 0|01|30.12.2019|31.12.2019|01.01.2020|02.01.2020|03.01.2020|04.01.2020|05.01.2020
;~ Row 1|02|06.01.2020|07.01.2020|08.01.2020|09.01.2020|10.01.2020|11.01.2020|12.01.2020
;~ Row 2|03|13.01.2020|14.01.2020|15.01.2020|16.01.2020|17.01.2020|18.01.2020|19.01.2020
;~ ...
;~ Row 50|51|14.12.2020|15.12.2020|16.12.2020|17.12.2020|18.12.2020|19.12.2020|20.12.2020
;~ Row 51|52|21.12.2020|22.12.2020|23.12.2020|24.12.2020|25.12.2020|26.12.2020|27.12.2020
;~ Row 52|53|28.12.2020|29.12.2020|30.12.2020|31.12.2020|01.01.2021|02.01.2021|03.01.2021
$aKW = _ArrayExtract($aKW, -1, -1, -1, 5)
_DebugArrayDisplay($aKW, '$aKW ' & @YEAR, '', 0, Default, 'KW|Mo.|Di.|Mi.|Do.|Fr.')
;~ Row|KW|Mo.|Di.|Mi.|Do.|Fr.
;~ Row 0|01|30.12.2019|31.12.2019|01.01.2020|02.01.2020|03.01.2020
;~ Row 1|02|06.01.2020|07.01.2020|08.01.2020|09.01.2020|10.01.2020
;~ Row 2|03|13.01.2020|14.01.2020|15.01.2020|16.01.2020|17.01.2020
;~ ...
;~ Row 50|51|14.12.2020|15.12.2020|16.12.2020|17.12.2020|18.12.2020
;~ Row 51|52|21.12.2020|22.12.2020|23.12.2020|24.12.2020|25.12.2020
;~ Row 52|53|28.12.2020|29.12.2020|30.12.2020|31.12.2020|01.01.2021
_ArrayColDelete($aKW, 2)
_ArrayColDelete($aKW, 2)
_ArrayColDelete($aKW, 2)
_DebugArrayDisplay($aKW, '$aKW ' & @YEAR, '', 0, Default, 'KW|Mo.|Fr.')
;~ Row|KW|Mo.|Fr.
;~ Row 0|01|30.12.2019|03.01.2020
;~ Row 1|02|06.01.2020|10.01.2020
;~ Row 2|03|13.01.2020|17.01.2020
;~ ...
;~ Row 50|51|14.12.2020|18.12.2020
;~ Row 51|52|21.12.2020|25.12.2020
;~ Row 52|53|28.12.2020|01.01.2021
Alles anzeigen