Re: Programmatically uncheck CDateTimeCtrl?
Hmmm. Sorry about that. It seems they went out of their way to keep you from manipulating the
checkbox independently, even with the new GetDateTimePickerInfo in Vista+.
When you "tried simulating a mouse-click", did you do that via SendInput?
Why is this really important to do?
"znakeeye" <kdn01003@student.mdh.se> wrote in message
news:9dff6cb9-fc94-4c21-bf1a-01cf7e0e1b93@v15g2000yqn.googlegroups.com...
On Apr 21, 11:14 am, "Scot T Brennecke" <Sc...@MVPs.spamhater.org>
wrote:
Although the CDateTimeCtrl is in use here, it's not really an MFC problem. This is fundamental to
the design of the date-time picker control. See the Windows message which is wrapped by the
SetTime
method: DTM_SETSYSTEMTIME Message ():http://msdn.microsoft.com/en-us/library/bb761782.aspx
When the checkbox is emptied, it implies the time is not valid. So why do you care if the old
invalid time is restored from the registry?
The way to handle this, if you really must, is to find the checkbox control which is a child
window
of the DTP control. Send a BM_SETCHECK
message:http://msdn.microsoft.com/en-us/library/bb775989(VS.85).aspx) with BST_UNCHECKED.
"znakeeye" <kdn01...@student.mdh.se> wrote in message
news:8fbd175b-3fff-47fa-bb27-eaa9d1fe0330@3g2000yqk.googlegroups.com...
If you create a CDateTimeCtrl with the DTS_SHOWNONE style, the control
will have a checkbox where you can choose "no time".
This check can be checked using SetTime(&stValidTime) and unchecked
with SetTime(NULL). When you click it manually, the time value is NOT
changed even though "no time" is unchecked. When doing this
programmatically with SetTime() the time is reset (NULL = no time).
This yields a problem when serializing the state of the control from a
given source (like the Registry).
Q: How do you set a valid time AND uncheck the control
programmatically?
(I've tried simulating a mouse-click, but that yields weird effects.)- Hide quoted text -
- Show quoted text -
Thanks for your reply. Your idea seems nice, but after playing a bit
with Spy++ I'm quite sure the checkbox is not a real checkbox window.
At least, it's not a child of the date time control!