Thread: Edit Box

  1. #1
    Registered User ski6ski's Avatar
    Join Date
    Aug 2001
    Posts
    133

    Edit Box

    I am using an Edit Box to "modify" numbers on static text. The only problem is that I want the numbers to be between 1 & 20. I am using a member named m_eName with a type of CEdit. I know you can set value if you use type int, but what about CEdit?
    C++ Is Powerful
    I use C++
    There fore I am Powerful

  2. #2
    Registered User headexplodes's Avatar
    Join Date
    Aug 2001
    Posts
    26
    I think you'd have to write some simple code to check the range of the number entered and warn the user (or just put the number in range again) if they type a number over 20 or below 0.
    /* MSN and E-Mail - head_explodeshotmail.com */
    If Bill Gates got a dollar for every time windows crahsed... oh... he does.
    I always use MSVC++6.0

  3. #3
    Registered User ski6ski's Avatar
    Join Date
    Aug 2001
    Posts
    133
    Ok, I was just wandering if there was a function or anything. Thx.
    C++ Is Powerful
    I use C++
    There fore I am Powerful

  4. #4
    Registered User Chemanuel's Avatar
    Join Date
    Aug 2001
    Posts
    13
    There's no special function for that but you can implement one easy.

    What you need to do is trap the EN_UPDATE notification message (is received through the WM_COMMAND) from the edit box. This means that the user changed the contents.

    Then get the value with GetDlgItemInt() and check whether the value is valid or not.
    Chemanuel

    Lo bueno si breve dos veces bueno (Baltasar Gracián 1601-1658)

  5. #5
    Registered User ski6ski's Avatar
    Join Date
    Aug 2001
    Posts
    133
    Ok I must have not understood this quite right. I tried doing it the way that headexplodes suggested (I don't know how to do it your way Chemanual I use MFC). Anyways here is what I tried and didn't work.

    CString nValue;
    CString nValue2="20"; //Test value
    m_edValue.GetWindowText(nValue); //member var for edit

    //Check to see if the nValue is <20
    if(nValue<=nValue2)
    &nbsp;&nbsp;{
    &nbsp;&nbsp;&nbsp;......do the necesary updat on static text.....
    &nbsp;&nbsp;}
    //Popup message that nValue is grater than 20!
    else if(nValue>nValue2)
    &nbsp;&nbsp;{
    &nbsp;&nbsp;&nbsp;MessageBox("Your value of "+nValue+" is grater than "+nValue2+"!","Allert!",MB_OK);
    &nbsp;&nbsp;&nbsp;nValue=" ";
    &nbsp;&nbsp;}

    The problem is that it always (ALWAYS) pops the message box up saying the your value is grater than that of 20. Any suggestions???
    C++ Is Powerful
    I use C++
    There fore I am Powerful

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. edit box
    By beene in forum Windows Programming
    Replies: 3
    Last Post: 11-11-2006, 04:40 AM
  3. edit box affecting displaying of text?
    By algi in forum Windows Programming
    Replies: 4
    Last Post: 05-04-2005, 03:28 PM
  4. How to program a "back" button with MFC
    By 99atlantic in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2005, 08:34 PM
  5. display a file in dropdown edit box
    By sunburnbyRA in forum Windows Programming
    Replies: 2
    Last Post: 03-10-2004, 01:58 PM