ToyBoi Posted February 20, 2009 Posted February 20, 2009 Hello everyone. I was playing around with the examples in the Autoit help file for GUI Calendars and this example poped up this example is for the function _GUICtrlMonthCal_GetCurSelStr which retrieves the currently selected date in string format but when I tried it, whenever I select a date, the information does not updated in the bottom message box. Isn't this function supposed to retriever the date that has been selected. What I am trying to do is have a similar calendar and when a user selects a date I want autoit to be able to store that information in three separate variables, year, month and date. and then use that information to later interact with a website that has it's own calendar. Any help is appreciated expandcollapse popup#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GuiConstantsEx.au3> #include <GuiMonthCal.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) $Debug_MC = False; Check ClassName being passed to MonthCal functions, set to True and use a handle to another control to see it work Global $iMemo _Main() Func _Main() Local $hMonthCal ; Create GUI GUICreate("Month Calendar Get Cur Sel String", 400, 300) $hMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000) ; Create memo control $iMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState() ; Get current selection MemoWrite("Current selection : " & _GUICtrlMonthCal_GetCurSelStr($hMonthCal)) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main ; Write message to memo Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite
AdmiralAlkex Posted February 20, 2009 Posted February 20, 2009 (edited) Dude, look at the code, _GUICtrlMonthCal_GetCurSelStr() is only run after the gui is created, not when you press on anything. If you need that then make it yourself, see the example for _GUICtrlMonthCal_Create() on how to react when changing date Edited February 20, 2009 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
ToyBoi Posted February 23, 2009 Author Posted February 23, 2009 AdmiralAlkex said: Dude, look at the code, _GUICtrlMonthCal_GetCurSelStr() is only run after the gui is created, not when you press on anything. If you need that then make it yourself, see the example for _GUICtrlMonthCal_Create() on how to react when changing dateSorry but I'm still unable to figure it out, I tried read the example and changing some of the codes but just couldn't get it to work. could you please give me some more hints? thanks
Robjong Posted February 23, 2009 Posted February 23, 2009 Hey ToyBoi, post the code you have so far, then we can help you to make it work
jimollerhead Posted February 27, 2009 Posted February 27, 2009 It seems unfortunate that if you want the datepicker to present pretty wordy dates, you have to do any conversion yourself. It can often be easier to use your own function to do a conversion and then compare the integer values in order to do date arithmetic... here's an example from one of my recent programs (slightly adapted to give a standalone test): #include <GUIConstantsEx.au3> Dim $DateId Dim $DateInteger GUICreate ("Date reformat", 200, 100, -1, -1) GUICtrlCreateLabel("Choose Date", 10, 10) $DateId = GUICtrlCreateDate ("", 10, 40, 120) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd $DateInteger = DateToInt(GUICtrlRead($DateId)) MsgBox(0,"Converted Dates", "Date Integer: " & $DateInteger) Func DateToInt($InDate) Dim $DateArray Dim $MonthNum $DateArray = StringSplit($InDate, " ", 2) Switch $DateArray[1] Case "January" $MonthNum = "01" Case "February" $MonthNum = "02" Case "March" $MonthNum = "03" Case "April" $MonthNum = "04" Case "May" $MonthNum = "05" Case "June" $MonthNum = "06" Case "July" $MonthNum = "07" Case "August" $MonthNum = "08" Case "September" $MonthNum = "09" Case "October" $MonthNum = "10" Case "November" $MonthNum = "11" Case "December" $MonthNum = "12" EndSwitch Return Int($DateArray[2] & $MonthNum & $DateArray[0]) EndFunc
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now