Ok, in the Win32 Enviroment, you can get two things from an Edit Box: a string, and an int (GetDlgItemText() & GetDlgItemInt()). How would you get a double or a float? Im pretty sure you have to do something like extract a string and convert it somehow but I have not been able to figure it out yet.
zac@qisfl.net
Snowsoft Online
I don't pretend to know anything.
Edited by - Smack0007 on 8/26/00 1:15:08 PM
Edited by - Smack0007 on 8/26/00 1:16:23 PM
String Manipulation Question
if you can get a string of your number, all you need it the ATO family
Just look in your help files for the ato* functions.
atoi converts alpha to integer (hence the ATOI)
atof should convert from alpha to float, if I am not totally mistaken ?
youpla :-P
Just look in your help files for the ato* functions.
atoi converts alpha to integer (hence the ATOI)
atof should convert from alpha to float, if I am not totally mistaken ?
youpla :-P
I am going to try that, I think one of the main problems is that the GetDlgItemText() function puts the text into a LPTSTR. I need to convert that to a char somehow.
zac@qisfl.net
Snowsoft Online
I don't pretend to know anything.
zac@qisfl.net
Snowsoft Online
I don't pretend to know anything.
actually a "LPSTR" is the same thing as "const char *". long pointer to string which: a string is an array of char''s. which is the same thing as "char *". just explicitly cast it.
I think I follow you, but could you give me a short example?
zac@qisfl.net
Snowsoft Online
I don't pretend to know anything.
zac@qisfl.net
Snowsoft Online
I don't pretend to know anything.
Someone please help me. Everytime I run this thing it crashes.
zac@qisfl.net
Snowsoft Online
I don't pretend to know anything.
zac@qisfl.net
Snowsoft Online
I don't pretend to know anything.
How r u doing the code?
I would do:
char * afloat;
float float;
int length;
//Can''t remeber off hand all the params to the functions
length= GetWindowTextLength(GetDlgItem(MAKEINTRESOURCE(TEXT_BOX))
//or sominthing, just get the length of the text
afloat = (char *)malloc(sizeof(char)*length+1));
GetDlgItemText(TEXT_BOX, afloat, length);
//once again can''t remeber params
afloat[length+1] = ''\0'';
float = atof(afloat);
//-------------------
Thats off the top of my head, and with out anything
to look up its acuracy.
Evan,
evan@achaia.dircon.co.uk
I would do:
char * afloat;
float float;
int length;
//Can''t remeber off hand all the params to the functions
length= GetWindowTextLength(GetDlgItem(MAKEINTRESOURCE(TEXT_BOX))
//or sominthing, just get the length of the text
afloat = (char *)malloc(sizeof(char)*length+1));
GetDlgItemText(TEXT_BOX, afloat, length);
//once again can''t remeber params
afloat[length+1] = ''\0'';
float = atof(afloat);
//-------------------
Thats off the top of my head, and with out anything
to look up its acuracy.
Evan,
evan@achaia.dircon.co.uk
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement