DickG Posted July 20, 2010 Share Posted July 20, 2010 I need to set a specific date on the date control so it starts out with a certain date. I can manually change it by clicking the control, but I want it to start out with a specific date. But so far, it only shows today's date when the GUI opens. I researched this forum, and found that I should use GuiCtrlSendMsg() to set the date. But it always shows today's date. I also tried using GuiCtrlSetData(), with and without GuiCtrlSendMsg(), and before/after it too. But it always opens with today's date. I must be missing something. Can anyone show me how to make the control show a specific date when I display the GUI? I am using this code to test it. #Include <DateTimeConstants.au3> #Include <GuiConstantsEx.au3> ;Create GUI. $GUI = GuiCreate("Date control", 200, 150, 50, 50) $Date = GUICtrlCreateDate("", 20, 40, 150, 20, $DTS_SHORTDATEFORMAT) $Cancel = GuiCtrlCreateButton("Cancel", 60, 75, 50, 20) GUISetState(@SW_SHOW, $GUI) ;This does NOT set date to specified date. GUICtrlSendMsg($Date, $DTS_SHORTDATEFORMAT, "M/d/yyyy", "6/1/2010") MsgBox(0, "test", "Date should be set to 6/1/2010") ;Loop While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop Case $Cancel GUIDelete($GUI) ExitLoop EndSwitch WEnd Dick Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 20, 2010 Moderators Share Posted July 20, 2010 DickG, Just set the requried date when you create the control as it suggests in the Help file: #Include <DateTimeConstants.au3> #Include <GuiConstantsEx.au3> ;Create GUI $GUI = GuiCreate("Date control", 200, 150, 50, 50) ;This does set date to specified date of 17/03/1986. $Date = GUICtrlCreateDate("1986/03/17", 20, 40, 150, 20, $DTS_SHORTDATEFORMAT) $Cancel = GuiCtrlCreateButton("Cancel", 60, 75, 50, 20) GUISetState(@SW_SHOW, $GUI) ;Loop While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop Case $Cancel GUIDelete($GUI) ExitLoop 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
DickG Posted July 20, 2010 Author Share Posted July 20, 2010 Aha! I knew I was missing something. I think I misinterpreted " ... when you create the control" to mean that I could set it with GuiCtrlSetData() or GuiCtrlSendMsg() right after I create the control. Now I understand what that really meant. Thanks much for the fast reply ... Dick DickG, Just set the requried date when you create the control as it suggests in the Help file: #Include <DateTimeConstants.au3> #Include <GuiConstantsEx.au3> ;Create GUI $GUI = GuiCreate("Date control", 200, 150, 50, 50) ;This does set date to specified date of 17/03/1986. $Date = GUICtrlCreateDate("1986/03/17", 20, 40, 150, 20, $DTS_SHORTDATEFORMAT) $Cancel = GuiCtrlCreateButton("Cancel", 60, 75, 50, 20) GUISetState(@SW_SHOW, $GUI) ;Loop While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE ExitLoop Case $Cancel GUIDelete($GUI) ExitLoop EndSwitch WEnd M23 Link to comment Share on other sites More sharing options...
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