MFC - incrementing values
-
I am having a difficult time trying to get a value to increment. What I mean is if I have a static control for example called CValue that each time a button is pressed it will increase the value by one. So if CValue = 10 and the button is pressed, I want it to change the value of CValue to 11. Each time I try to do this, the compiler says some crap about converting CString to an int is impossible or something. I cannot remember because I just got out of bed to write this so that I may have a reply by the morning. Can someone please help me. I know this is easy 'i think' but it has me tickled pink. Thankyou Ashman :confused:
-
I am having a difficult time trying to get a value to increment. What I mean is if I have a static control for example called CValue that each time a button is pressed it will increase the value by one. So if CValue = 10 and the button is pressed, I want it to change the value of CValue to 11. Each time I try to do this, the compiler says some crap about converting CString to an int is impossible or something. I cannot remember because I just got out of bed to write this so that I may have a reply by the morning. Can someone please help me. I know this is easy 'i think' but it has me tickled pink. Thankyou Ashman :confused:
Have you tried something like:
CString strValue;
CValue.GetWindowText(strValue);
int nValue = atoi(strValue) + 1;
CValue.SetWindowText(strValue);
A rich person is not the one who has the most, but the one that needs the least.
-
Have you tried something like:
CString strValue;
CValue.GetWindowText(strValue);
int nValue = atoi(strValue) + 1;
CValue.SetWindowText(strValue);
A rich person is not the one who has the most, but the one that needs the least.
DavidCrow wrote:
CString strValue;
CValue.GetWindowText(strValue);
int nValue = atoi(strValue) + 1;
CValue.SetWindowText(strValue);Whoops!
CString strValue;
CValue.GetWindowText(strValue);
int nValue = atoi(strValue) + 1;
strValue.Format(_T("%d"), nValue);
CValue.SetWindowText(strValue);INTP
-
DavidCrow wrote:
CString strValue;
CValue.GetWindowText(strValue);
int nValue = atoi(strValue) + 1;
CValue.SetWindowText(strValue);Whoops!
CString strValue;
CValue.GetWindowText(strValue);
int nValue = atoi(strValue) + 1;
strValue.Format(_T("%d"), nValue);
CValue.SetWindowText(strValue);INTP
No, BIG whoops! Thanks.
A rich person is not the one who has the most, but the one that needs the least.
-
No, BIG whoops! Thanks.
A rich person is not the one who has the most, but the one that needs the least.
What about GetDlgItemInt()? SetDlgItemInt(IDC_MYCONTROL,MyCtrl.GetDlgItemInt(IDC_MYCONTROL) + 1); onwards and upwards...