Having problem getting number until decimal is entered
Posted by efultz
on 12/23/2004 04:19pm
I am having a problem. If I enter 34 I only get returned by the GetValue function 3. If I enter 341 I am returned 34. BUT, if I press the decimal then I am returned the full 341.
Any suggestions on how to fix this? It makes the control far less useful - to the point where I might have to remove it. I don't want to do that because it provides lots of other good things.
I have successfully implemented your code and it works very much with the ease but there is one bug in it. that i am not able to solve i.e. when i try typeing "22" in the decimal place it gives me an output of "12" in the decimal places. also the same thing happens when i try to type "77"
it gives me "67" on the display. please infrom me about the solution for this bug.
Another interesting thing about this control is that how do we set the maximum limit of the decimal places and the actual no. supposing i want the control to accept something like "12.23" how do i go about doing this things.
This was a great control thanks for doing this kind of work.
Please carry on the good work.
I found a somewhat strange behavior with the control. The thing is that say, the current value is ".000" and I try to change it to "-5.000". I did this by moving cursor to the very beginning and enter negative sign, "-", and then "5". Rather than display "-5.000" as I would expect, the control shows ".500." Anthor related and interesting behavior is that is there is non-zero fraction number like ".100", then the value will come out correctly. I tried to fix this problem but couldn't. Any idea how to fix it?
because the SetWindowText sends a EN_CHANGE event.
In your version, if you use at this point the GetValue member in the handler of the EN_CHANGE you have an unsyncronized value because the event arrive before the m_dblCurrentValue member is correctly setted. So moving the code
It handles rounding correctly (maybe not in Italy... :-)
The second suspicious place is a call to atof(), according to MS "...The output value is affected by
the setting of the LC_NUMERIC category in the current locale. ..." -
it's not secure to replace a decimal point character with a hardcoded '.'...