I'm using a CEdit control sub classed to my dialog box.
I would like to filter the input allowing only certain characters to be entered.
Here's a convoluted approach I came up with..
void ARIntRate::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
// TODO: Add your message handler code here and/or call default
CEdit::OnChar(nChar, nRepCnt, nFlags);
UINT testchar = nChar; // to isolate the character entered
// get the edit control contents
// Check validity of character entered
if (! ( testchar>45 && testchar < 58 ) || ( testchar == 46 && decimal == true ) )// digits 0 - 9 or decimal
//strip of this character
before.Remove( nChar );
// reset window contents with character removed
if (testchar == 46)
decimal = true;
This does seem to work but when the text is restored the cursor is placed at the front of the text rather than at the location of the incorrect entry.(the right side).
Is there a more elegant way of trapping the last character entered and verifying it prior to the edit window being updated??