CDateTimeCtrl - preventing 'focus' change when setting date
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 u开发者_StackOverflow中文版ser 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?
Not sure, but one possible workaround:
keybd_event(VK_RIGHT, 0, 0, NULL);
keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, NULL);
精彩评论