floating point variables in edittext controls

This is a discussion on floating point variables in edittext controls within the Windows Programming forums, part of the Platform Specific Boards category; Hi, after a long google searching session, i'm not entirely clear as to how to go about making an edittext ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    6

    Question floating point variables in edittext controls

    Hi, after a long google searching session, i'm not entirely clear as to how to go about making an edittext control in a dialog box accept a floating variable, then do some numerical things with that number and be able to display it in floating variable form in another edittext control.

    At the moment i'm using the style ES_NUMBER for the boxes, but as i realise that won't accept a decimal point in the control, i figure i'd have to get rid of that style. But how would i keep the dialog box from having letters and other characters typed in when i only want numbers and a decimal point?

    Most of the google searchs popped up MFC, is this nessecary to learn to be able to do this? I only really know the basic Win32 API.

    Thanks for any potential clarification...

  2. #2
    Registered User
    Join Date
    Mar 2004
    Posts
    6
    Okay, as far as the barrage of replies has gone, ive kinda figured i'd have to make my own controls, which would be great seeing as i didn't like the way the others looked.

    Would someone like to suggest/recall a way they could/did go about learning how to do such a thing (creating their own customizable controls)?

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Subclassing.

    I'll attach a program which subclasses an edit box. What this program does is intercepts and processes Esc, Tab and Cr. It passes anything else to the default windows handler.

    If you change this and only pass the numerics, the point and maybe the minus sign, then the user will only be able to enter the components of a floating point number. With a little extra work, you could detect, for example people entering 123.456.789 thus validating the input as they were making it.

    This is a very useful technique that can be employed in many diverse situations.
    Attached Files Attached Files
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    6
    Thank you, thats exactly the reply i was looking for

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Decimal places on Floating point number
    By manutdfan in forum C Programming
    Replies: 1
    Last Post: 10-29-2006, 11:56 AM
  2. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 11:07 AM
  3. Floating point exceptions
    By Boris in forum C++ Programming
    Replies: 8
    Last Post: 11-19-2001, 07:32 AM
  4. Floating point faster than fixed-point
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 11-08-2001, 10:34 PM
  5. Replies: 2
    Last Post: 09-10-2001, 12:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21