4 Replies - 7187 Views - Last Post: 21 June 2008 - 04:09 PM Rate Topic: -----

#1 captainhampton  Icon User is offline

  • Jawsome++;
  • member icon

Reputation: 13
  • View blog
  • Posts: 548
  • Joined: 17-October 07

MFC Calculator

Post icon  Posted 21 June 2008 - 09:15 AM

Hey all, I'm making a GUI calculator interface in MFC, just starting out with it actually. My question would be if I have a text box and a button, lets say the button outputs "1" to the text box. Now this I can do with something close to the following code:

UpdateData(true);
m_var = 1;
UpdateData(false);



This outputs 1 to the screen fine, but it only outputs once, how would I go about everytime the person pushes the button for 1 to keep getting output? Thanks again any help in the right direction or possibly other projects of the same style would be much appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: MFC Calculator

#2 perfectly.insane  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 70
  • View blog
  • Posts: 644
  • Joined: 22-March 08

Re: MFC Calculator

Posted 21 June 2008 - 01:36 PM

Well now, you can't simply set the variable...

If someone clicks on the 1 button, you have to append a one. Mathematically, this would be achieved by:

m_var = m_var * 10 + 1;
Was This Post Helpful? 0
  • +
  • -

#3 captainhampton  Icon User is offline

  • Jawsome++;
  • member icon

Reputation: 13
  • View blog
  • Posts: 548
  • Joined: 17-October 07

Re: MFC Calculator

Posted 21 June 2008 - 01:58 PM

View Postperfectly.insane, on 21 Jun, 2008 - 01:36 PM, said:

Well now, you can't simply set the variable...

If someone clicks on the 1 button, you have to append a one. Mathematically, this would be achieved by:

m_var = m_var * 10 + 1;


Great thank you so much, this works for ints, floats, and doubles, but what about cstrings? Would there be some type of equivalent form?

Thanks again in advance
Was This Post Helpful? 0
  • +
  • -

#4 perfectly.insane  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 70
  • View blog
  • Posts: 644
  • Joined: 22-March 08

Re: MFC Calculator

Posted 21 June 2008 - 04:00 PM

View Postcaptainhampton, on 21 Jun, 2008 - 01:58 PM, said:

View Postperfectly.insane, on 21 Jun, 2008 - 01:36 PM, said:

Well now, you can't simply set the variable...

If someone clicks on the 1 button, you have to append a one. Mathematically, this would be achieved by:

m_var = m_var * 10 + 1;


Great thank you so much, this works for ints, floats, and doubles, but what about cstrings? Would there be some type of equivalent form?

Thanks again in advance


The + operator.

m_var = m_var + _T("some str");

This post has been edited by perfectly.insane: 21 June 2008 - 04:00 PM

Was This Post Helpful? 0
  • +
  • -

#5 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1382
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: MFC Calculator

Posted 21 June 2008 - 04:09 PM

Just to add, you could also use an operator such as the following:
+= -= /= *=
So, instead of writingm_var = m_var + _T("some str"); you could use m_var += _T("some str");

This post has been edited by gabehabe: 21 June 2008 - 04:09 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1