Click here to Skip to main content
15,889,691 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: No more DSP but DSW and SLN in VC6.0 Pin
H.Brydon30-Apr-13 18:58
professionalH.Brydon30-Apr-13 18:58 
GeneralRe: No more DSP but DSW and SLN in VC6.0 Pin
Vaclav_1-May-13 9:38
Vaclav_1-May-13 9:38 
QuestionHelp with KB Q147578 Pin
ForNow29-Apr-13 8:33
ForNow29-Apr-13 8:33 
QuestionRe: Help with KB Q147578 Pin
David Crow29-Apr-13 9:41
David Crow29-Apr-13 9:41 
AnswerRe: Help with KB Q147578 Pin
ForNow29-Apr-13 9:56
ForNow29-Apr-13 9:56 
QuestionAdvise / patterns on modeling data and business components Pin
Fernando A. Gomez F.29-Apr-13 4:50
Fernando A. Gomez F.29-Apr-13 4:50 
QuestionHow to make an edit box accept only digits from 0 - 9 in mfc.? Pin
mbatra3128-Apr-13 21:15
mbatra3128-Apr-13 21:15 
AnswerRe: How to make an edit box accept only digits from 0 - 9 in mfc.? Pin
Freak3028-Apr-13 22:10
Freak3028-Apr-13 22:10 
You could overwrite the OnChange Handler (I think it was EN_CHANGED or something like that) and manually get the text, check for any non-digit and remove it. Then set the corrected Text with SetWindowText(), or ReplaceSel().

There are however several pitfalls you need to avoid. First, setting the text programmatically also calls the event handler, and you need some status variable to prevent "recursive" calls.

Second, You need to take the cursor position into account. When you call SetWindowText(), usually the whole edit control content is selected. You could set the cursor position to the end with SetSel() (IIRC you need two calls, one to mark everything and at the same time set the cursor to the end, a second one to mark nothing and leave the cursor where it is.) Since the user may have entered something in the middle you may want to get the cursor position before changing anything (with GetSel()) and set it back to that position later.

I usually avoided these issues by letting the user enter the wrong values and checking them when the control lost focus, unless where was a strong argument against this approach.
GeneralRe: How to make an edit box accept only digits from 0 - 9 in mfc.? Pin
mbatra3128-Apr-13 22:35
mbatra3128-Apr-13 22:35 
GeneralRe: How to make an edit box accept only digits from 0 - 9 in mfc.? Pin
Vaclav_29-Apr-13 6:11
Vaclav_29-Apr-13 6:11 
GeneralRe: How to make an edit box accept only digits from 0 - 9 in mfc.? Pin
mbatra3129-Apr-13 18:54
mbatra3129-Apr-13 18:54 
GeneralRe: How to make an edit box accept only digits from 0 - 9 in mfc.? Pin
Vaclav_30-Apr-13 3:47
Vaclav_30-Apr-13 3:47 
GeneralRe: How to make an edit box accept only digits from 0 - 9 in mfc.? Pin
mbatra3130-Apr-13 19:27
mbatra3130-Apr-13 19:27 
AnswerRe: How to make an edit box accept only digits from 0 - 9 in mfc.? Pin
Rolf Kristensen29-Apr-13 4:18
Rolf Kristensen29-Apr-13 4:18 
Questionproblem in clips programming Pin
a.fatemeh28-Apr-13 2:02
a.fatemeh28-Apr-13 2:02 
AnswerRe: problem in clips programming Pin
NotPolitcallyCorrect28-Apr-13 2:13
NotPolitcallyCorrect28-Apr-13 2:13 
GeneralRe: problem in clips programming Pin
a.fatemeh28-Apr-13 2:19
a.fatemeh28-Apr-13 2:19 
GeneralRe: problem in clips programming Pin
Richard MacCutchan28-Apr-13 2:29
mveRichard MacCutchan28-Apr-13 2:29 
GeneralRe: problem in clips programming Pin
a.fatemeh28-Apr-13 2:51
a.fatemeh28-Apr-13 2:51 
GeneralRe: problem in clips programming Pin
NotPolitcallyCorrect28-Apr-13 2:31
NotPolitcallyCorrect28-Apr-13 2:31 
AnswerMy Vote of 1 Pin
Keith Barrow28-Apr-13 7:45
professionalKeith Barrow28-Apr-13 7:45 
GeneralRe: My Vote of 1 Pin
a.fatemeh28-Apr-13 22:46
a.fatemeh28-Apr-13 22:46 
GeneralRe: My Vote of 1 Pin
H.Brydon30-Apr-13 19:02
professionalH.Brydon30-Apr-13 19:02 
QuestionHow to make a EXE in windows Pin
OmarSH27-Apr-13 7:10
OmarSH27-Apr-13 7:10 
AnswerRe: How to make a EXE in windows Pin
NotPolitcallyCorrect27-Apr-13 16:50
NotPolitcallyCorrect27-Apr-13 16:50 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.