negative numbers in a edit box

This is a discussion on negative numbers in a edit box within the Windows Programming forums, part of the Platform Specific Boards category; I have a edit box in a modal dialog box. It needs to accept negative numbers tho it wont let ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    202

    negative numbers in a edit box

    I have a edit box in a modal dialog box. It needs to accept negative numbers tho it wont let you use the " - " key. How can I reverse this behaviour? also if I want it to keep the number negative if it is to begin with what should I set bsigned to?(TRUE or FALSE?)

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    Well I dunno if there's a simpler way, but you'd just have to take off the option for making it a number-only boxy (it slips my mind what it is...ES_NUMBER?) then every time the stuff in the edit box changes, parse what comes through to make sure it's not anything but '-' or '.' like...
    Code:
    for(x=0;buff[x]=='\0';x++)
    {
          if(isdigit(buff[x]) || buff[x] == '-' || buff[x] == '.')
                 continue; //keep going, this one's OK.
          else
          {
                  buff[x] = ' ';
                  SetWindowText(hEdit, buff); //or SetDlgItemText()
                  //you could put a break here, becuase anything else should have been flushed out already
          }
    }

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Using SetDlgItemInt() and need signed, set bSigned=TRUE;
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can we input negative numbers in the output windiw
    By hitesh1511 in forum C Programming
    Replies: 1
    Last Post: 08-22-2006, 01:07 AM
  2. WS_HSCROLL in ES_READONLY edit box error
    By Homunculus in forum Windows Programming
    Replies: 4
    Last Post: 02-13-2006, 08:46 AM
  3. Multiline Edit Box Parser
    By The Brain in forum Windows Programming
    Replies: 6
    Last Post: 11-01-2005, 07:15 PM
  4. setting fixed floats in edit box
    By WaterNut in forum Windows Programming
    Replies: 4
    Last Post: 08-13-2004, 10:13 AM
  5. Edit controls and numbers
    By DominicTrix in forum Windows Programming
    Replies: 5
    Last Post: 04-13-2003, 01:16 PM

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