qwert

Need example of date selection

11 posts in this topic

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.

Does Not Update.png

 

Share this post


Link to post
Share on other sites



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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by anthonyjr2

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@anthonyjr2: the reason is to avoid having blanks in the date field.

Blanks in date.PNG

 

@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.

 

Share this post


Link to post
Share on other sites

Ah, didn't even notice that. Just another reason I shouldn't ever challenge Melba!


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

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?

Still Fails.PNG

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

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?

 

Confirm Fail.PNG

Share this post


Link to post
Share on other sites

#11 ·  Posted

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.

Found It.png

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now