jdicerch Posted August 7, 2013 Share Posted August 7, 2013 The date picker didn't seem to do too much for me, so I am trying to tweak it to suit my needs. Currently when you use the date picker and choose to type in the date, you must type in "MM" (press right-arrow), "DD" (press right-arrow), "YYYY". I want the user to just be able to fluidly type in the date and as you type it automatically inserts the slashes. So after I type in, for example, 08 it will automatically show the slash and will automatically move to the next item (the day). Is this possible? Suggestions on how to do this? If I am not clear as to what I am asking please let me know, I really appreciate any help. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 7, 2013 Moderators Share Posted August 7, 2013 jdicerch,You could do it like this: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 200, 200, 800, 200) $cDate = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20) GUISetState() $DTM_SETFORMAT_ = 0x1032 ; $DTM_SETFORMATW GUICtrlSendMsg($cDate, $DTM_SETFORMAT_, 0, "dd/MM/yyyy") GUIRegisterMsg($WM_NOTIFY, "_WM_Notify") Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE Func _WM_Notify($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local Const $DTN_FIRST = -760 Local Const $DTN_DATETIMECHANGE = $DTN_FIRST + 1 Local $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return If DllStructGetData($tagNMHDR, 3) = $DTN_DATETIMECHANGE Then ControlSend($hGUI, "", $cDate, "{RIGHT}") EndIf EndFunc ;==>_WM_NotifyBut I less than convinced that what you are trying to do is a good idea. It works fine if the date is correctly entered, but can lead to all sorts of problems if not. I would suggest to leave it well alone - the "right-arrow to move on" event was no doubt put there for a reason. 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...
jdicerch Posted August 7, 2013 Author Share Posted August 7, 2013 HA THAT IS PERFECT. Thank you very much and I ask the user to confirm the date before I continue with anything! Thanks again, that is great. Link to comment Share on other sites More sharing options...
jdicerch Posted August 7, 2013 Author Share Posted August 7, 2013 Now the default of the date is the current date, is there anyway to default the text to MM/DD/YYYY (so they actually see it as that) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 7, 2013 Moderators Share Posted August 7, 2013 jdicerch,This line sets the displayed date format:GUICtrlSendMsg($cDate, $DTM_SETFORMAT_, 0, "dd/MM/yyyy")Just adjust the string to "MM/dd/yyyy" - if you really must use that awful format. 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...
jdicerch Posted August 7, 2013 Author Share Posted August 7, 2013 You are just helping me out all over the place today And I wasn't very clear. I have that line in, but on the actual GUI itself I want to actually see the letters MM/DD/YYYY in the date picker. Not a date. Can I set strings in there or is this not very feasible. Link to comment Share on other sites More sharing options...
FireFox Posted August 7, 2013 Share Posted August 7, 2013 @Melba23Nice example, I didn't know that Link to comment Share on other sites More sharing options...
BrewManNH Posted August 7, 2013 Share Posted August 7, 2013 jdicerch, This line sets the displayed date format: GUICtrlSendMsg($cDate, $DTM_SETFORMAT_, 0, "dd/MM/yyyy") Just adjust the string to "MM/dd/yyyy" - if you really must use that awful format. M23 You know, it wasn't all that long ago that the UK used the same format for dates. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 7, 2013 Moderators Share Posted August 7, 2013 BrewManNH,Just as well we changed then! 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...
jdicerch Posted August 7, 2013 Author Share Posted August 7, 2013 So that's a no then on showing MM/DD/YYYY as default If I can't do that, after they press the add button how can I reset the date picker to the current date with your WM_NOTIFY. Will this work or no? GUICtrlSetData($date, @MON & "/" & @MDAY & "/" & @YEAR) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 7, 2013 Moderators Share Posted August 7, 2013 jdicerch, So that's a no then on showing MM/DD/YYYY as defaultNot at all - just how fast do you think we work? I am not at all sure that it can be done - but as I have been busy modifying my ExtMsgBox to respond to yet another of your many threads, I have not really had time to look at it properly. Be patient, my good man - even miracles take a little time! 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...
jdicerch Posted August 7, 2013 Author Share Posted August 7, 2013 I'm sorry Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted August 7, 2013 Moderators Solution Share Posted August 7, 2013 jdicerch, This is the best I can do. You need to click on the mask to activate the Date control, which always shows the current date - pressing "Add" replaces the mask: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Date.au3> $hGUI = GUICreate("Test", 200, 200, 800, 200) $cDate = GUICtrlCreateDate(_NowCalc(), 10, 10, 185, 20) GUICtrlSetState($cDate, $GUI_HIDE) $cEdge = GUICtrlCreateLabel("", 10, 10, 185, 20) GUICtrlSetState($cEdge, $GUI_DISABLE) GUICtrlSetBkColor($cEdge, 0) $cMask = GUICtrlCreateLabel("MM/DD/YYYY", 11, 11, 183, 18, $SS_CENTERIMAGE) $cAdd = GUICtrlCreateButton("Add", 10, 100, 80, 30) GUICtrlSetState($cAdd, $GUI_FOCUS) GUISetState() $DTM_SETFORMAT_ = 0x1032 ; $DTM_SETFORMATW GUICtrlSendMsg($cDate, $DTM_SETFORMAT_, 0, "MM/dd/yyyy") GUIRegisterMsg($WM_NOTIFY, "_WM_Notify") GUICtrlSetState($cDate, $GUI_FOCUS) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cAdd GUICtrlSetState($cDate, $GUI_HIDE) GUICtrlSetState($cMask, $GUI_SHOW) GUICtrlSetState($cEdge, $GUI_SHOW) GUICtrlSetData($cDate, _NowCalc()) Case $cMask GUICtrlSetState($cEdge, $GUI_HIDE) GUICtrlSetState($cMask, $GUI_HIDE) GUICtrlSetState($cDate, BitOr($GUI_SHOW, $GUI_FOCUS)) EndSwitch WEnd Func _WM_Notify($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local Const $DTN_FIRST = -760 Local Const $DTN_DATETIMECHANGE = $DTN_FIRST + 1 Local $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return Switch DllStructGetData($tagNMHDR, 3) Case $DTN_DATETIMECHANGE ControlSend($hGUI, "", $cDate, "{RIGHT}") EndSwitch EndFunc ;==>_WM_Notify How does that suit? 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...
jdicerch Posted August 7, 2013 Author Share Posted August 7, 2013 haha very interesting way to go about it! Thanks for your input (thumbs-up) 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