Click to See Complete Forum and Search --> : Getting a number from an Edit box


Mrafcho001
September 23rd, 2005, 10:15 PM
I know you can use GetDlgItemInt(hwnd, int, bool, bool); but it only retrieves an int, i need something that will retrieve a float or a double, something with more percision.

Any ideas?

Niels_Boar
September 23rd, 2005, 10:40 PM
You can retrieve the number from the edit control as text and then convert it to a double with strtod.


int len = GetWindowTextLength(GetDlgItem(hWnd, IDC_EDIT_CONTROL));
char * buf,* stopString;
buf = new char[len + 1];;
GetDlgItemText(hWnd, IDC_EDIT_CONTROL, buf, len+1);
double dNumber = strtod(buf,&stopString);
delete [] buf;

Mrafcho001
September 24th, 2005, 10:36 AM
Thanks man