-
win32 API EDIT BOX
Programming in win32 and im just kinda playing around. What i want to do is enter a number into a edit box, and i hit a button, and it calulates and the result gets put into the second edit box......mainly this is for a radius math problem program i am making.
Code:
case IDB_BUTTON:{
if(HIWORD(wParam) == BN_CLICKED){
}
}
break;
inside there is where i put my code,....GETDLGITEMTEXT maybe work....and setDLGITEMTEXT...but i dont know how to calucate something...I WANT TO enter 12 into the first edit box.....i will calculate 2*PI*12.....and it goes into the second edit box after a button click
tankyou
-
Well, when the button is clicked, grab the text from the first box, convert it to a value (sscanf() perhaps?), do the math, print to a buffer, and set item text.
You listed your formula there, do you mean you can't figure out how to enter that in a program?
-
Ok thx for that information, expespecially the SSCANF fucntion. I got it to work.
Instead of storing it into a buffer, i made a variable of the float type and stored the getdlgitemtext API FUNCTION into the variable. then used the senddlgitemint to set the edit box to the result
-
Code:
int iNumber=0;
double dResult=0;
char szBuffer[MAX_PATH]={0};
//get the value in the first edt
iNumber = GetDlgItemInt(hWnd, IDC_EDIT1, NULL, TRUE);
//do the math
dResult = iNumber * 3.1 * 2;
//put in a text buffer
_snprintf(szBuffer, MAX_PATH-1, "%f", dResult);
//set the second edit
SetDlgItem(hWnd, IDC_EDIT2, szBuffer);