• Advertisement
Sign in to follow this  

Retreiving edit box info?

This topic is 4399 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
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++):

#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;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement