CDateTimeCtrl - preventing 'focus' change when setting date
Posted
by WalderFrey
on Stack Overflow
See other posts from Stack Overflow
or by WalderFrey
Published on 2010-04-23T13:55:46Z
Indexed on
2010/04/23
14:03 UTC
Read the original article
Hit count: 195
mfc
I'd like to use a CDateTimeCtrl
to allow the user to select a non-weekend date. So, if the user increments the day (via a keypress) - and the resulting day is found to fall on a weekend - then the control should skip forward to the following Monday (don't let issues about month changes distract you, it's not relevant).
Usually it's not a problem: when I handle the DTN_DATETIMECHANGE
notification I can check the new date/time and if it's found to be a weekend then I can call SetTime
on the control to update the date. However, if I set the style to DTS_SHOWNONE
, this call to SetTime
causes the control to shift the input 'focus' (term used loosely) to the 'none' checkbox, e.g. away from the day field. This prevents the user from using keyboard input to continue incrementing the date unless they subsequently use the right arrow key to reset the 'focus', which is just nasty.
I would dearly like to prevent this focus shift from occurring. Is it even possible?
© Stack Overflow or respective owner