Jump to content

Getting the day of week from GUICtrlCreateMonthCal


 Share

Recommended Posts

Hello,

I'm looking for a way to get the day of week (numeric or in words) from the return-value of the GUICtrlCreateMonthCal-control.
Is such a function present in autoit?
Has anyone already written such a function? 
Or do I have to create this function?

Thanks a lot ...
Guido

Link to comment
Share on other sites

Just an example :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Date.au3>

Global $sSelectedDate = _CalendarDaySeletion("2022/05/11")
Global $iWeekday = _DateToDayOfWeek(StringMid($sSelectedDate, 1, 4), _
                                    StringMid($sSelectedDate, 6, 2), _
                                    StringMid($sSelectedDate, 9, 2))

MsgBox(0, "Selected", "Date = " & $sSelectedDate & @CRLF & _
                      "Day  = " & $iWeekday & @CRLF & _
                      "Name = " & _DateDayOfWeek($iWeekday)) ; *** just info

Func _CalendarDaySeletion($sDate)
    Local $hGUI   = GUICreate("Select Date", 260, 300)
    Local $idDate = GUICtrlCreateMonthCal($sDate, 10, 10, 230, 240)
    Local $idQuit = GUICtrlCreateButton("Quit", 10, 260, 230, 30)
    Local $sSelected
    GUISetState(@SW_SHOW)
    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idQuit
                ExitLoop
        EndSwitch
    WEnd
    $sSelected = GUICtrlRead($idDate)
    GUIDelete($hGUI)
    Return $sSelected
EndFunc   ;==>_CalendarDaySeletion

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

  • Moderators

Something like this perhaps, using the help file example as a start:

 

#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
        GUICreate("Get date", 210, 190)

        Local $idDate = GUICtrlCreateMonthCal(_NowDate(), 10, 10)
        GUISetState(@SW_SHOW)

        While 1
                Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE
                            ExitLoop
                    Case $idDate
                        $dateSplit = StringSplit(GUICtrlRead($idDate), "/")
                        MsgBox($MB_SYSTEMMODAL, "Date", GUICtrlRead($idDate) & " is a " & _DateDayOfWeek(_DateToDayOfWeek($dateSplit[1], $dateSplit[2], $dateSplit[3])))
                EndSwitch
        WEnd
EndFunc   ;==>Example

 

Edit: Too slow :)

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

2 minutes ago, JLogan3o13 said:

Edit: Too slow :)

Now the OP has more than one option ;)

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

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...