Jump to content

Attempting to implement Null Dates in my script


randym
 Share

Go to solution Solved by Nine,

Recommended Posts

I have a user request to be able to optionally leave a date field blank or otherwise null it out ... Research led me to the $DTS_SHOWNONE style that looks promising ... I created a test script and implemented it, but perhaps I don't have the usage exactly right ... I get the checkbox that seems to enable and disable the field, but the contents remain the same .... Am I missing something? 

My test script is included below.

TIA - Randy

Date_Test.au3

And the sign said 'Long Hairded Creepy People Need Not Apply' ... So I stuffed my hair up under my hat and I went in to ask him why?

Link to comment
Share on other sites

For reading state of checkbox inside Date control (with DTS_SHOWNONE style)

generally you have to use GUICtrlSendMsg($P_VPOREFDATE, $DTM_GETDATETIMEPICKERINFO, ...)

And then read value of stateCheck in DATETIMEPICKERINFO structure ...

This message and structure is not declared in standard AutoIt's include file <DateTimeConstants.au3> so you have to do it yourself.

See here for official MSDN DOC:

https://docs.microsoft.com/en-us/windows/win32/controls/dtm-getdatetimepickerinfo

https://docs.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-datetimepickerinfo

See here example for DTM_GETDATETIMEPICKERINFO message (in C) on stackoverflow:

https://stackoverflow.com/questions/43576035/is-there-a-way-to-get-the-handle-of-the-entry-field-in-a-date-time-picker-dtp

 

Edited by Zedna
Link to comment
Share on other sites

  • Solution

Or you can use this :

While 1
  $nMsg = GUIGetMsg()
  Switch $nMsg
    Case $GUI_EVENT_CLOSE
      Exit
    Case $P_VPOREFDATE
      _GUICtrlDTP_GetSystemTimeEx(GUICtrlGetHandle($P_VPOREFDATE))
      $test_dt = @error = $GDT_NONE ? "" : GUICtrlRead($P_VPOREFDATE)
      ConsoleWrite("<" & $test_dt & ">" & @CRLF)
  EndSwitch
WEnd

 

Link to comment
Share on other sites

Thanks for the responses to this topic .... Nine - your suggestion works perfectly for me and fits well with my existing code. Again, thanks!

And the sign said 'Long Hairded Creepy People Need Not Apply' ... So I stuffed my hair up under my hat and I went in to ask him why?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...