C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 10-25-2009, 01:55 PM   #1
Registered User
 
Join Date: Oct 2009
Posts: 2
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
acce55 is offline   Reply With Quote
Old 10-26-2009, 03:30 AM   #2
Registered User
 
Join Date: Aug 2006
Posts: 76
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?
rdrast is offline   Reply With Quote
Old 10-26-2009, 10:18 AM   #3
Registered User
 
Join Date: Oct 2009
Posts: 2
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
acce55 is offline   Reply With Quote
Old 10-29-2009, 11:02 PM   #4
train spotter
 
Join Date: Aug 2001
Location: near a computer
Posts: 3,359
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);
__________________
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche

"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best

"If you are going through hell....keep going."
Winston Churchill
novacain is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
WS_HSCROLL in ES_READONLY edit box error Homunculus Windows Programming 4 02-13-2006 08:46 AM
Multiline Edit Box Parser The Brain Windows Programming 6 11-01-2005 07:15 PM
setting fixed floats in edit box WaterNut Windows Programming 4 08-13-2004 09:13 AM
pthread api vs win32 thread api Unregistered Windows Programming 1 11-20-2001 08:55 AM
Rich edit control example Win API Echidna Windows Programming 1 09-17-2001 02:12 AM


All times are GMT -6. The time now is 05:17 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22