From: JCO on 21 May 2010 15:25 I had to write a subclass for the CEdit control because I wanted it to handle floating point numbers only. The code below is what I've done however, it allows for multiple '.' (points). Therefore, 1...25 ends up being valid. How can I ensure the decimal is only done one time? The issue is that I validate each input but I can't validate the entire value to see if the decimal was already used. Is the only way to do this ... to create a local variable in this class so I can track the total amount? I have 30 of these CEditNum (EditBox) in my application. Code Below: void CEditNum::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { //Allowed inputs are passed on to the base class if( (nChar >= '0' && nChar <= '9') || nChar == '.' || nChar == VK_BACK ) { CEdit::OnChar(nChar, nRepCnt, nFlags); } }
From: Seetharam on 21 May 2010 15:37 In your OnChar(), you can get the text previously entered by calling GetWindowText(). -Seetharam
From: JCO on 21 May 2010 18:12 WOW!.. That was to easy. I will try to come up with a harder question next time. Ha. Thanks "Seetharam" <smisro(a)gmail.com> wrote in message news:b3cb6117-66d0-4bfd-91a9-b3ff5bca72d5(a)z17g2000vbd.googlegroups.com... > In your OnChar(), you can get the text previously entered by calling > GetWindowText(). > > -Seetharam
From: David Lowndes on 21 May 2010 19:00 >I had to write a subclass for the CEdit control because I wanted it to >handle floating point numbers only. The code below is what I've done >however, it allows for multiple '.' (points). Don't forget that some locale's use the comma rather than '.' Dave
From: Joseph M. Newcomer on 22 May 2010 05:40 Use my control from my MVP Tips site! It already handles this. joe On Fri, 21 May 2010 14:25:27 -0500, "JCO" <someone(a)somewhere.com> wrote: >I had to write a subclass for the CEdit control because I wanted it to >handle floating point numbers only. The code below is what I've done >however, it allows for multiple '.' (points). Therefore, 1...25 ends up >being valid. How can I ensure the decimal is only done one time? The issue >is that I validate each input but I can't validate the entire value to see >if the decimal was already used. Is the only way to do this ... to create a >local variable in this class so I can track the total amount? I have 30 of >these CEditNum (EditBox) in my application. > >Code Below: >void CEditNum::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) >{ > //Allowed inputs are passed on to the base class > if( (nChar >= '0' && nChar <= '9') || nChar == '.' || nChar == VK_BACK ) > { > CEdit::OnChar(nChar, nRepCnt, nFlags); > } >} Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
|
Pages: 1 Prev: socket OnReceive function not called Next: sdi: recevie on_message without a cwnd class |