Click here to Skip to main content
       

C / C++ / MFC

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionHow to stop typing in CDateTimeCtrl in MFCmemberrahul.kulshreshtha7 Nov '12 - 16:47 
I have a CDateTimeCtrl on my dialog. Through this I can choose any date in given range from drop down. But currently user is also allowed to press numeric keys to set the date. Is there any way to stop user from typing in it. I want, he should only be able to select the date from drop-down and I...
AnswerRe: How to stop typing in CDateTimeCtrl in MFCmemberJochen Arndt7 Nov '12 - 23:32 
You may derive a class from CDateTimeCtrl() and add a WM_CHAR / OnChar() handler that does nothing or calls the base class handler for non-digit chars only.   I've just tested it. It does not effect keys pressed in the drop down calendar and still allows cursor keys and TAB in the edit...
GeneralRe: How to stop typing in CDateTimeCtrl in MFCmemberrahul.kulshreshtha8 Nov '12 - 5:52 
Thanks Jochen, you are right. That way it will work. But for such a small requirement, I don't want to do big changes and also I don't want to go for pretranslate message. Is there any way to handle WM_CHAR/OnChar events for the date control on the same dialog class?
GeneralRe: How to stop typing in CDateTimeCtrl in MFCmemberJochen Arndt8 Nov '12 - 6:32 
You are using MFC, so you don't need to handle PreTranslateMessage(). Just use the wizard to derive a class, use the message properties to add the WM_CHAR handler, and comment the line calling CDateTimeCtrl::OnChar(). Done with a few mouse clicks. All you need to type in using the keyboard is...

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 18 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid