Thread: negative numbers in a edit box

  1. #1
    Registered User
    Join Date
    Nov 2001

    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
    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...
          if(isdigit(buff[x]) || buff[x] == '-' || buff[x] == '.')
                 continue; //keep going, this one's OK.
                  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
    near a computer
    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, 12: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, 09:13 AM
  5. Edit controls and numbers
    By DominicTrix in forum Windows Programming
    Replies: 5
    Last Post: 04-13-2003, 12:16 PM