Retreiving edit box info?
Hi. I was wondering how to get the information from an edit box.
I know how to get it as an array of chars, but not as a float (which is what I need).
Thanks in advance!
If you can retrieve an array of characters, you can convert this into a float (using atof, or stringstreams).
One way is (assuming you're using C++):
One way is (assuming you're using C++):
#include<cstdlib>#include<windows.h>#include<windowsx.h>...float floatValue(HWND editbox){ unsigned int length = Edit_GetTextLength(editbox); char* str = 0; float value; try{ str = new char[length + 1]; Edit_GetText(editbox, str, length) value = atof(str); }catch(std::bad_alloc&){ throw; }catch(...){ delete str; throw; //Re-throw exceptions etc while not leaking memory } delete str; return value;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement