Jump to content

Unable to uncheck a $DTS_SHOWNONE time

Recommended Posts

Consider the following time GUI box:

$my_time = GUICtrlCreateDate("", $x, $y, 85, 20, bitor($dts_timeformat,$DTS_SHOWNONE))

This is a standard Gui box showing just the time, but with a clever check/uncheck status to determine whether you actually want to use the contents of it or not.

Clicking on the checkbox works.

However, I'm completely unable to programatically check/uncheck the box. For instance:


doesn't unchecked it as expected.

I'm also unable to read the check status. Unchecking it doesn't seem to change the status nor data from a readable point of view.

How can I set and read this box?

Share this post

Link to post
Share on other sites


It is possible to have no date currently selected in the control. With this style, the control displays a check box that users can check once they have entered or selected a date. Until this check box is checked, the application will not be able to retrieve the date from the control because, in essence, the control has no date. This state can be set with the DTM_SETSYSTEMTIME message or queried with the DTM_GETSYSTEMTIME message.

...according to http://msdn.microsoft.com/library/default....time/styles.asp

Share this post

Link to post
Share on other sites

OK, that's great. Can someone possibly post a quick example of how this would work? I've not used GUICtrlSendMsg, and it doesn't seem obvious to me what to do.



Share this post

Link to post
Share on other sites

Hmm. After fiddling about with GUICtrlSend/RecvMsg a bit, I've come up with the following:

#include <GUIConstants.au3>
#include <Date.au3>

GUICreate ("Date Test")
$dateBox = GUICtrlCreateDate ("16/01/2006", 10, 10, 100, 20, $DTS_SHORTDATEFORMAT + $DTS_SHOWNONE)
$label = GUICtrlCreateLabel ("", 10, 40, 100, 20)
$btn = GUICtrlCreateButton ("get", 10, 70, 40, 20)
$Label2 = GUICtrlCreateLabel ("", 10, 100, 100, 20)
GUISetState (@SW_SHOW)

Const $DTM_GETSYSTEMTIME = 0x1001; (I googled for these since MSDN doesn't seem to tell you!)
Const $DTM_SETSYSTEMTIME = 0x1002;
    $msg = GUIGetMsg ()
    If $msg = $btn Then
        $lParam = GUICtrlRecvMsg ($dateBox, $DTM_GETSYSTEMTIME, 0, 1)
    ;$state = GUICtrlRead ($dateBox, 1)
        $asc = ""
        For $i = 1 To StringLen ($lParam)
            ConsoleWrite (Asc (StringMid ($lParam, $i, 1)) & " ")
        GUICtrlSetData ($label, $lParam)
        GUICtrlSetData ($Label2, GUICtrlRead ($dateBox))
until $msg = $GUI_EVENT_CLOSE

Click the 'get' button to fetch the checked state of the date picker using DTM_GETSYSTEMTIME. For me at least, it returns 0 when the box is ticked, and a byte string consisting of (255,15,1) when it's not. A bit weird but at least I can make it work.

Share this post

Link to post
Share on other sites


just had the same issue - wanted to uncheck the control. After some research and attempts, this is the only way which works for me:

$hControl= GUICtrlCreateDate("", 10, 10, 120, 22, $DTS_SHOWNONE)
GUICtrlSetState ($hControl,$GUI_FOCUS)

Basically you are sending a space bar key stroke to the CTRL do uncheck it.

Works for me so far.

Hope this helps



Share this post

Link to post
Share on other sites

You're responding to a 5 1/2 year old thread, I doubt the poster is still looking for an answer

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 Gude
How 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

Share this post

Link to post
Share on other sites

I'm pretty sure that people who run into the same problem will still appreciate it. I would have done so if I could have found a solution to this problem.

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...