INTRODUCTION AND RELATED INFORMATION:
I have edit controlone that should only accept signed decimal numbers (something like -12.35).
I decided to implement this through subclassing.
The handler WM_CHARseems to work well, and I need to process a few other messages to completely protect the user from entering invalid text. One such message is WM_PASTE.
So far, I managed to correctly get the text from clipboardand discard or send a message depending on whether the copied string is really a decimal number.
The Edit control has a limited input of 12 characters. This is done using a message EM_SETLIMITTEXT.
I use pure Winapiand C++. The use of libraries such as boostetc. is not allowed .
Problem:
So far, I am checking the case where the edit control is empty, and I refuse to paste if the content is invalid. However, the user can select a portion of the text in the edit control and then paste. Something like this (gray characters represent a choice):
Text in edit control: 123 45678.9
Clipboard text: -1A
The resulting string, if I allow the insert, will be 123-1A78.9, which is invalid.
This is the part I need help with:
, , , .
:
. , " ", ?
:
, std::, / /etc, , , . , , string:: insert(...), , .
, std:: strtod, StackOverflow , , . , , , , .
, , .
.
, .
.