Originally Posted by
codenewbie
Hi I'm hoping someone can help me with this. I've been searching google for several hours and I can't find a satisfactory answer to make my code work.
I'm trying to create an edit box within a dialog window that will recieve a double input from a user and then display that double value in a different edit box when a button is pressed. I've seen the use of the GetDlgItemText() function to get the information as a string and then using the atof() function to convert it to double, but when I try this I get 0 every time. For some reason, visual c++ 2008 makes me typecast my char arrays to LPWSTR in order for it to compile properly. (Not sure why or if I'm just not setting them up correctly to begin with). Can someone suggest a different way to do this or tell me what is wrong with my code so I can fix it?
Here is my code:
//global variables
double AccountBalance;
char temp[MAX_PATH];
//this code is within my button case in my switch statement.char buffer[MAX_PATH];
GetDlgItemText(AccountDialog,IDC_ACCOUNTBALANCE,(L PWSTR)buffer,MAX_PATH);
AccountBalance = atof(buffer);
AccountBalance = AccountBalance*2;
char temp2[100];
wsprintf((LPWSTR)temp2,L"%d",AccountBalance);
SetDlgItemText(AccountDialog,IDC_EDIT1,(LPWSTR)tem p2);