LurchMan Posted October 15, 2014 Share Posted October 15, 2014 Hello Everyone - I'm trying to create a date control that is empty as the default value. I can't figure out how to accomplish this. I have tried setting the data to "" and I've tried using the $DTS_SHOWNONE and then setting the state to $GUI_UNCHECKED but to no avail. The end result I would like is to let the user select Date and time within the same control, however they could leave it blank. I'm building a searching application with multiple ways to search to items (date / time being one) but they do not have to use all search terms. Here's my sample script to show how I have it setup currently: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <DateTimeConstants.au3> Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Form1", 250, 200, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $hDate = GUICtrlCreateDate ("", 10, 10, -1, -1, $DTS_SHOWNONE) GUICtrlSetData (-1, "") GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func Form1Close() Exit EndFunc Thank you in advance for any help. Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted October 15, 2014 Moderators Solution Share Posted October 15, 2014 LurchMan,How about this - the picker is blank until you select a date in the dropdown: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <DateTimeConstants.au3> #include <StructureConstants.au3> Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Form1", 250, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") $cDate = GUICtrlCreateDate ("", 10, 10) GUICtrlSendMsg($cDate, $DTM_SETFORMATW, 0, " ") ; Format as a blank GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Sleep(10) WEnd Func _Close() Exit EndFunc Func _WM_NOTIFY($hWnd, $iMsg, $wPram, $lParam) $tStruct = DllStructCreate($tagNMHDR, $lParam) $cID = DllStructGetData($tStruct, "IDFrom") $iCode = DllStructGetData($tStruct, "Code") ; Wait until the date picker is opened and closed If $cID = $cDate And $iCode = $DTN_CLOSEUP Then GUICtrlSendMsg($cDate, $DTM_SETFORMATW, 0, "hh:mm:ss dd/MM/yyyy") ; Format as time and date EndIf EndFuncI set the format to include time as well as date as you wanted. 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...
LurchMan Posted October 15, 2014 Author Share Posted October 15, 2014 As usual Melba - Thank you for the spot on answer. This solves the problem. Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 15, 2014 Moderators Share Posted October 15, 2014 LurchMan,Glad I could help. 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...
gcue Posted July 7, 2016 Share Posted July 7, 2016 thanks Melba - just what i was looking for! 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