qwert Posted January 10, 2017 Share Posted January 10, 2017 I've used guictrlcreatedate and have an entry field on my GUI with the correct appearance. Try as I might, I can't get the down arrow calendar to actually update the field. The only way it changes is when I use GUICtrlSendMsg to directly post a date. I haven't been able to find an example of how to manage a simple date field (i.e., without time). Then I found this suggestion from a couple of years ago: Quote Whenever I have that kind of need I create an input and the date control next to it, resized to show only drop-down arrow. When user selects date I then copy date selected to input. This allows me to have blanks or whatever other value the situation dictates. It sounds like just the kind of thing I need. But it doesn't give an example of the code and I can't figure the proper structure. Does anyone know of an example of the above? What I have is shown below. Thanks in advance. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 10, 2017 Moderators Share Posted January 10, 2017 qwert, The Help file example for GUICtrlCreateDate updates the date in the input with every selection - so why does that not satisfy your requirement? 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...
qwert Posted January 10, 2017 Author Share Posted January 10, 2017 That's a good question. I think the answer is somehow tied up in the date formatting (from another thread I started). Here's the method: $fromDate = guictrlcreatedate("", 220, 76, 160, 26, $DTS_SHORTDATEFORMAT) $hWndDate = ControlGetHandle($hGui, "", $fromDate) _GUICtrlDTP_SetFormat($hWndDate, "MM/dd/yyyy") GUICtrlSendMsg($fromDate, $DTM_SETFORMATW, 0, $iniDate) ; set initial date Any suggestions? Link to comment Share on other sites More sharing options...
anthonyjr2 Posted January 10, 2017 Share Posted January 10, 2017 (edited) 27 minutes ago, qwert said: That's a good question. I think the answer is somehow tied up in the date formatting (from another thread I started). Here's the method: $fromDate = guictrlcreatedate("", 220, 76, 160, 26, $DTS_SHORTDATEFORMAT) $hWndDate = ControlGetHandle($hGui, "", $fromDate) _GUICtrlDTP_SetFormat($hWndDate, "MM/dd/yyyy") GUICtrlSendMsg($fromDate, $DTM_SETFORMATW, 0, $iniDate) ; set initial date Any suggestions? I don't see a problem with the function. I just threw together some code to test it out, I'm not sure why you're using _GUICTRLDTP_SetFormat? It changes fine in this script: #include <ButtonConstants.au3>;Start GUI includes #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <DateTimeConstants.au3> $hGUI = GUICreate("window", 500, 500, 300, 300) $fromDate = GUICtrlCreateDate("", 220, 76, 160, 26,$DTS_SHORTDATEFORMAT) ;$hWndDate = ControlGetHandle($hGui, "", $fromDate) ;_GUICtrlDTP_SetFormat($hWndDate, "MM/dd/yyyy") GUICtrlSendMsg($fromDate, $DTM_SETFORMATW, 0, 0) ; set initial date GUISetState(@SW_SHOW) While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited January 10, 2017 by anthonyjr2 UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI= Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 10, 2017 Moderators Share Posted January 10, 2017 qwert, This works for me: #include <GUIConstantsEx.au3> #include <GuiDateTimePicker.au3> Example() Func Example() GUICreate("My GUI get date", 200, 200, 800, 200) Local $idDate = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20) _GUICtrlDTP_SetFormat(GUICtrlGetHandle($idDate), "MM/dd/yyyy") GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd MsgBox($MB_SYSTEMMODAL, "Date", GUICtrlRead($idDate)) GUIDelete() EndFunc ;==>Example 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...
qwert Posted January 10, 2017 Author Share Posted January 10, 2017 @anthonyjr2: the reason is to avoid having blanks in the date field. @melba23: indeed, that works ... and thanks for the clear example. Now I just have to run through my real script to see what's inhibiting the update. That shouldn't be hard now that I have a good "go by" example. Link to comment Share on other sites More sharing options...
anthonyjr2 Posted January 10, 2017 Share Posted January 10, 2017 Ah, didn't even notice that. Just another reason I shouldn't ever challenge Melba! UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI= Link to comment Share on other sites More sharing options...
qwert Posted January 10, 2017 Author Share Posted January 10, 2017 I'm completely perplexed. I've moved and removed every element I can think of. Here's what's left ... and it fails: ; ; replication script for date failure ; #include <WindowsConstants.au3> #include <GuiDateTimePicker.au3> $hGUI = GUICreate("Date Test", 400, 300, -1, -1, $WS_POPUP, $WS_EX_TOPMOST) $initDate = "08/07/2016" MsgBox(0, "Initial Date:", $initDate) $fromDate = guictrlcreatedate($initDate, 220, 20, 160, 26) _GUICtrlDTP_SetFormat(GUICtrlGetHandle($fromDate), "MM/dd/yyyy") GUICtrlSetData($fromDate, $initDate) GUISetState() MsgBox(0, "Date Still:", $initDate, 0, $hGui) Exit I can't see the problem. Anyone? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 10, 2017 Moderators Share Posted January 10, 2017 qwert, Perhaps if you read the actual content of the DTP rather then the initial date that you set? #include <WindowsConstants.au3> #include <GuiDateTimePicker.au3> $hGUI = GUICreate("Date Test", 400, 300, -1, -1, $WS_POPUP, $WS_EX_TOPMOST) $initDate = "08/07/2016" MsgBox(0, "Initial Date:", $initDate) $fromDate = guictrlcreatedate($initDate, 220, 20, 160, 26) _GUICtrlDTP_SetFormat(GUICtrlGetHandle($fromDate), "MM/dd/yyyy") GUICtrlSetData($fromDate, $initDate) GUISetState() MsgBox(0, "Date Now:", GUICtrlRead($fromDate) , 0, $hGui) Exit 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...
qwert Posted January 10, 2017 Author Share Posted January 10, 2017 The second message was just to confirm that something hadn't changed $initDate. Now I'm staring are both sets of code and I don't see a difference. Mine still fails. And so does your example code when run on my PC. Is it somehow the Gui Date Time Picker? The file date on the copy I have is 9/17/15. I'm running v3.3.14.2 on Win 7 Pro 32-bit. Suggestions? Link to comment Share on other sites More sharing options...
qwert Posted January 11, 2017 Author Share Posted January 11, 2017 Found it! The create date has only one acceptable format ... and doesn't bother to notify of a reject. Using 2016/08/07 solves it. Thanks, again, for each response. 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