I have an edit box. I need to know how to getan int from the box. I know GetDlgItemInt is only for Dialog Boxes. I can't find a GetWindowInt cause I don't think there is one. What function gets an int from an EDIT box?
I have an edit box. I need to know how to getan int from the box. I know GetDlgItemInt is only for Dialog Boxes. I can't find a GetWindowInt cause I don't think there is one. What function gets an int from an EDIT box?
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
If you're absolutely sure the user will enter an integer, you could fetch the data as you regularly would with GetWindowText() and convert the resulting text to a number with _atoi().
"Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C
Set the property on the EDIT to number only to ensure only numbers are entered.
If using VC resource editor, get the properties of the EDIT, select STYLES. Find the NUMBER check box, should be near the MULTILINE.
>>I know GetDlgItemInt is only for Dialog Boxes
No it's not. It will work with any edit or static control just as GetDlgItemText() will. Validate the input with isdigit()
Sir,
I have tried GetDlgItemInt(int j) to get the data as integer from the dialog box but it is not working. I am using Microsoft VC++.
Help
juhi
GetDlgItemInt takes 4 parameters -
GetDlgItemInt(YourWindowHWND,EditBoxID,successBOOL ,signBOOL);
and returns the integer if successful.
zen
As Zen says
iEditContents= GetDlgItemInt(hWndofDialog, ID_OF_EDIT, bGoodRead, bSignedInt);
'hWndofDialog' is the HWND returned when you created the dialog or window.
ID_OF_EDIT is the int ID you gave the edit control when you made it in the resource editor or the element cast as the hmenu if you created it on the fly ie (HMENU)ID_OF_EDIT
bGoodRead is only needed if you are testing for errors.
bSignedInt will be FALSE unless you need negative values from the edit. eg if bSignedInt==FALSE then iEditContents must be >=0
"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