cannot retrieve dialog user inputs
-
i have a query: i use a dialog to take in user input for a rect dimensions but i tested it using AfxMessagebox and encounter assertion error, may i know where is the problem? i have a variable m_length of float type. void Dialog :: OnOK { UpdateData(TRUE); float length=m_length; AfxMessageBox(length); }
-
i have a query: i use a dialog to take in user input for a rect dimensions but i tested it using AfxMessagebox and encounter assertion error, may i know where is the problem? i have a variable m_length of float type. void Dialog :: OnOK { UpdateData(TRUE); float length=m_length; AfxMessageBox(length); }
Hi, this could occur due to several problems: 1) look in the DDX method of the class that the m_length is defined there. if it is not than the UpdataData(TRUE) will not be valid for m_length. 2) use format string for the float variable as follows:
CString szLength;
szLength.Format(_T("%d"),m_length);
AfxMessageBox(length);hope this helps ya Yaron Ask not what your application can do for you, Ask what you can do for your application
-
Hi, this could occur due to several problems: 1) look in the DDX method of the class that the m_length is defined there. if it is not than the UpdataData(TRUE) will not be valid for m_length. 2) use format string for the float variable as follows:
CString szLength;
szLength.Format(_T("%d"),m_length);
AfxMessageBox(length);hope this helps ya Yaron Ask not what your application can do for you, Ask what you can do for your application
the DDX method shows: DDX_Text(pDX, IDC_LENGTH, m_length); does that mean that the UpDateData(TRUE) is unable to take in the float m_length? i need my member variables to be float preferably because i am using it for OpenGL rendering and as i encountered problems putting my variables into OpenGl that why i was testing to check whether my function can take in the float values.... is there a better way?
-
the DDX method shows: DDX_Text(pDX, IDC_LENGTH, m_length); does that mean that the UpDateData(TRUE) is unable to take in the float m_length? i need my member variables to be float preferably because i am using it for OpenGL rendering and as i encountered problems putting my variables into OpenGl that why i was testing to check whether my function can take in the float values.... is there a better way?
ok, i see the problem now... open the class wizard (CTRL+W) and go to the definition of IDC_LENGTH and delete the m_str_length member. add a new member called m_length which will be not from CString type but from float type. then you should see an entry in the DDX as follows:
DDX_Text(pDX, IDC_LENGTH, m_length);
now the update data will hold the number within the m_length...and all u have to do is convert it to string and display it.... hope this helps ya Yaron Ask not what your application can do for you, Ask what you can do for your application
-
ok, i see the problem now... open the class wizard (CTRL+W) and go to the definition of IDC_LENGTH and delete the m_str_length member. add a new member called m_length which will be not from CString type but from float type. then you should see an entry in the DDX as follows:
DDX_Text(pDX, IDC_LENGTH, m_length);
now the update data will hold the number within the m_length...and all u have to do is convert it to string and display it.... hope this helps ya Yaron Ask not what your application can do for you, Ask what you can do for your application
-
erm okie thanx but actually i made a typo error in my earlier message, it is really DDX_Text(pDX, IDC_LENGTH, m_length) already.. so that means AfxMessageBox cannot display a float directly? need to convert to String?
-
i have a query: i use a dialog to take in user input for a rect dimensions but i tested it using AfxMessagebox and encounter assertion error, may i know where is the problem? i have a variable m_length of float type. void Dialog :: OnOK { UpdateData(TRUE); float length=m_length; AfxMessageBox(length); }
You cannot use AfxMessageBox with a float variable. You need a CString with the float variable this way:
void Dialog :: OnOK { UpdateData(TRUE); float length=m_length; CString my_string; my_string.Format("%f", length); AfxMessageBox(my_string); }
That's all, hope it helped.
Rafael Fernández López.
I didn't fail hundred times, I found hundred ways that didn't work.
No fallé cien veces, encontré cien maneras de que no funcionara.
-
erm okie thanx but actually i made a typo error in my earlier message, it is really DDX_Text(pDX, IDC_LENGTH, m_length) already.. so that means AfxMessageBox cannot display a float directly? need to convert to String?
coda_x wrote: so that means AfxMessageBox cannot display a float directly? Correct. Check the docs and the function prototypes.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?