Thread: formulas & edit boxes, c++ on MSVC++ 5

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    2

    Question formulas & edit boxes, c++ on MSVC++ 5

    I've been trying to put a few formulas into a program, but the only one I've started referencing won't put a value into an edit box. Here's the code I think is important to the problem:




    bool CCombinedGasLawDlg::CalcGasLaw()
    {
    if(counter == 5){
    switch(flag){
    case 63:
    return(FALSE);

    case 62:
    m_Pr1 = (m_Tm1 / m_Vl1) * ((m_Pr2 * m_Vl2) /m_Tm2);
    break;

    case 61:
    m_Pr2 = ((m_Vl1 * m_Pr1) /m_Tm1) * (m_Tm2 / m_Vl2);
    break;

    case 59:
    m_Vl1 = (m_Tm1 / m_Pr1) * ((m_Pr2 * m_Vl2) / m_Tm2);
    break;

    case 55:
    m_Vl2 = ((m_Vl1 * m_Pr1) / m_Tm1) * (m_Tm2 / m_Pr2);
    break;

    case 47:
    m_Tm1 = (m_Pr1 * m_Vl1) * (m_Tm2 / (m_Pr2 * m_Vl2));
    break;

    case 31:
    m_Tm2 = ((m_Pr1 * m_Vl1) / m_Tm1) * (m_Pr2 * m_Vl2);
    break;

    default:
    counter = 0;

    if(flag & 32 == 32){
    counter += 1;
    }
    if(flag & 16 == 16){
    counter += 1;
    }

    if(flag & 8 == 8){
    counter += 1;
    }
    if(flag & 4 == 4){
    counter += 1;
    }

    if(flag & 2 == 2){
    counter += 1;
    }
    if(flag & 1 == 1){
    counter += 1;
    }

    return(FALSE);
    }
    UpdateData(FALSE);
    }

    return(TRUE);
    }

    void CCombinedGasLawDlg::OnChangePreassure1()
    {
    UpdateData(TRUE);

    if(m_Pr1 != 0){
    counter += 1;
    flag|=1;
    }
    else{
    MessageBox(m_ErrLowValue);
    }

    if(counter == 5){
    if((CalcGasLaw() == FALSE)){
    MessageBox(m_ErrFewValue);
    }
    }
    }

    void CCombinedGasLawDlg::OnChangeVolume1()
    {
    UpdateData(TRUE);

    if(m_Vl1 != 0){
    counter += 1;
    flag|=4;
    }
    else{
    MessageBox(m_ErrLowValue);
    }

    if(counter == 5){
    if((CalcGasLaw() == FALSE)){
    MessageBox(m_ErrFewValue);
    }
    }
    }

    void CCombinedGasLawDlg::OnChangeVolume2()
    {
    UpdateData(TRUE);

    if(m_Vl2 != 0){
    counter += 1;
    flag|=8;
    }
    else{
    MessageBox(m_ErrLowValue);
    }

    if(counter == 5){
    if((CalcGasLaw() == FALSE)){
    MessageBox(m_ErrFewValue);
    }
    }
    }

    void CCombinedGasLawDlg::OnChangeTemperature2()
    {
    UpdateData(TRUE);

    if(m_Tm1 != 0){
    counter += 1;
    flag|=16;
    }
    else{
    MessageBox(m_ErrLowValue);
    }

    if(counter == 5){
    if((CalcGasLaw() == FALSE)){
    MessageBox(m_ErrFewValue);
    }
    }
    }

    void CCombinedGasLawDlg::OnChangeTemperature1()
    {
    UpdateData(TRUE);

    if(m_Tm1 != 0){
    counter += 1;
    flag|=32;
    }
    else{
    MessageBox(m_ErrLowValue);
    }

    if(counter == 5){
    if((CalcGasLaw() == FALSE)){
    MessageBox(m_ErrFewValue);
    }
    }
    }

    void CCombinedGasLawDlg::OnChangePreassure2()
    {
    UpdateData(TRUE);

    if(m_Pr2 != 0){
    counter += 2;
    flag|=2;
    }
    else{
    MessageBox(m_ErrLowValue);
    }

    if(counter == 5){
    if((CalcGasLaw() == FALSE)){
    MessageBox(m_ErrFewValue);
    }
    }
    }




    Each of the OnChange functions is a message handler for one of six dialog boxes. m_Pr1, m_Pr2, m_Vl1, m_Vl2, m_Tm1 and m_Tm2 are variables to hold the values in said boxes. Each of the OnChange functions is supposed to be called after the value in the box is changed by the user. These functions then send an error if the value is too low, or set a flag and increment a counter if the value is appropriate. If the counter is set to 5 these functions call the Calculation function to get the final value. This value should then be placed into it's edit box. This never happens, and I don't know why. I don't recieve any programing errors in the compiler or when running the program. Help would be appreciated.

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    25

    text boxes

    I had a hell of a time trying to read your code... try using the code tags next time [ CODE] foo()...[ /CODE] to make your code readible....
    Anyway any updates to textboxes must meet the following criteria..

    The variables must be mapped to the control in the DDX function...
    Use the class wizard to map these variables....

    Code:
    void CMyClass::OnUpdate1()
    {
            UpdateData( TRUE );
    
             m_myMapVar = someValue;
    
           UpdateData( FALSE );
    }
    inZane
    --true programmer's don't comment--
    --programmer wannabes complain about it--

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Edit box(es), and specialized onmouseover
    By Lurker in forum Windows Programming
    Replies: 7
    Last Post: 05-25-2003, 04:13 PM
  2. Edit Boxes, I need specifics..
    By MrWizard in forum Windows Programming
    Replies: 4
    Last Post: 06-30-2002, 04:42 PM
  3. Edit Boxes Question
    By Ruben in forum Windows Programming
    Replies: 2
    Last Post: 09-14-2001, 12:06 AM
  4. Edit Boxes Question
    By RubenJ in forum Windows Programming
    Replies: 1
    Last Post: 09-12-2001, 08:01 PM
  5. Password Edit Boxes
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2001, 02:40 PM