Click here to Skip to main content
16,006,605 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Converting a CString to CInt Pin
Joe Woodbury17-Mar-04 6:30
professionalJoe Woodbury17-Mar-04 6:30 
GeneralRe: Converting a CString to CInt Pin
Antti Keskinen17-Mar-04 6:37
Antti Keskinen17-Mar-04 6:37 
GeneralRe: Converting a CString to CInt Pin
HAHAHA_NEXT17-Mar-04 6:52
HAHAHA_NEXT17-Mar-04 6:52 
GeneralRe: Converting a CString to CInt Pin
Blue Pyre17-Mar-04 10:52
Blue Pyre17-Mar-04 10:52 
GeneralRe: Converting a CString to CInt Pin
MeterMan17-Mar-04 10:58
MeterMan17-Mar-04 10:58 
GeneralRe: Converting a CString to CInt Pin
Blue Pyre17-Mar-04 11:38
Blue Pyre17-Mar-04 11:38 
GeneralRe: Converting a CString to CInt Pin
Prakash Nadar17-Mar-04 14:55
Prakash Nadar17-Mar-04 14:55 
GeneralRe: Converting a CString to CInt Pin
MeterMan17-Mar-04 14:57
MeterMan17-Mar-04 14:57 
Just curious why are you using a string to begin with when your dealing with Integers? What I would do is this

you have your buttons number0-number9.

I would make an edit box which I assume you have done and give it a control variable of m_outvalue of type CEdit.

Also make you some variables:
bool minus; // true or false for minus button pushed
bool plus; // true or false for plus button pushed
int m_total; // integer value to hold the calculated value

Then click on the button say button 1 and it will make OnButton1();

void CCalculatorDlg::Onnumber1()
{
if (!minus && !plus)
m_total=1; // if neither the plus or the minus is pressed you add 1

if (plus)
{
m_total=m_total+1; // if plus was pressed add one to total
plus=false; // set the bool back to false

}
if (minus)
{
m_total=m_total-1; // if minus was pressed deduct one from total
minus=false; // set the bool back to false

}
CString TempString; // your temp string holder
TempString.Format("%d",m_total); // converts int to string
m_outvalue.SetWindowText(TempString); // outputs string to edit box
}

void CCalculatorDlg::Onplus()
{
plus=true; // turn the plus bool on for addition

m_outvalue.SetWindowText("+"); // display the plus sign in your edit box
}

void CCalculatorDlg::Onminus()
{
minus=true; // turn the minus bool on for subtraction

m_outvalue.SetWindowText("-"); // display the minus sign in your edit box
}

void CCalculatorDlg::Onnumber2()
{
if(!minus && !plus)
m_total=2; // if the minus or plus is not pressed make total 2

if (plus)
{
m_total=m_total+2; // if plus was pressed add two to the value
plus=false; // set plus bool to false
}

if (minus)
{
m_total=m_total-2; // if minus was pressed deduct two from value
minus=false; // set the minus bool to false
}
CString TempString; // temp string holder
TempString.Format("%d",m_total); // convert int to a string
m_outvalue.SetWindowText(TempString); // display string in edit box
}

void CCalculatorDlg::Onequals()
{
CString TempString; // temp holder for string
TempString.Format("%d",m_total); // convert int to a string
m_outvalue.SetWindowText(TempString); // display string in edit box

}

I hope this helps you.


Win32newb
"Making windows programs worse than they already are"
GeneralC++ .NET Forms Shutdown application Pin
Neoankt17-Mar-04 6:09
Neoankt17-Mar-04 6:09 
GeneralRe: C++ .NET Forms Shutdown application Pin
Antti Keskinen17-Mar-04 7:05
Antti Keskinen17-Mar-04 7:05 
GeneralNeed a Good COM Tutorial !!! Pin
HAHAHA_NEXT17-Mar-04 6:06
HAHAHA_NEXT17-Mar-04 6:06 
GeneralSecondary display dimension winxp Pin
Bernardo Faria17-Mar-04 6:04
sussBernardo Faria17-Mar-04 6:04 
GeneralSend F5 or left arrow message Pin
Tomaz Rotovnik17-Mar-04 5:33
Tomaz Rotovnik17-Mar-04 5:33 
GeneralRe: Send F5 or left arrow message Pin
gUrM33T17-Mar-04 14:50
gUrM33T17-Mar-04 14:50 
GeneralRe: Send F5 or left arrow message Pin
Tomaz Rotovnik18-Mar-04 7:25
Tomaz Rotovnik18-Mar-04 7:25 
GeneralHelp With Control Focus Pin
Jack Reed17-Mar-04 4:44
Jack Reed17-Mar-04 4:44 
GeneralRe: Help With Control Focus Pin
David Crow17-Mar-04 4:53
David Crow17-Mar-04 4:53 
GeneralRe: Help With Control Focus Pin
Jack Reed19-Mar-04 9:38
Jack Reed19-Mar-04 9:38 
Questionwhat does "rhs" mean? Pin
Bash17-Mar-04 4:23
Bash17-Mar-04 4:23 
AnswerRe: what does "rhs" mean? Pin
TFrancis17-Mar-04 4:27
TFrancis17-Mar-04 4:27 
AnswerRe: what does "rhs" mean? Pin
hph17-Mar-04 4:28
hph17-Mar-04 4:28 
GeneralIncluding project files from library Pin
Cedric Moonen17-Mar-04 4:19
Cedric Moonen17-Mar-04 4:19 
GeneralOpenProcess Pin
hph17-Mar-04 4:03
hph17-Mar-04 4:03 
GeneralRe: OpenProcess Pin
gUrM33T17-Mar-04 14:57
gUrM33T17-Mar-04 14:57 
GeneralWindows NT Device Driver and PCI Bus access on Windows NT Pin
BhaskarBora17-Mar-04 3:57
BhaskarBora17-Mar-04 3:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.