Extracting the user input from Edit Box
-
Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.
-
Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.
Use
UpdateData(TRUE)
beforeline = m_WORD
Appu.. "If you judge people, you have no time to love them." -
Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.
vinaycool wrote:
CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line;
char * str=new char[MAX]; UpdateData(); lstrcpy(str,m_test.GetBuffer(m_test.GetLength())); The code copies the data from the edit box into the str variable. Knock out 't' from can't, You can if you think you can :cool:
-
Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.
vinaycool wrote:
I have created a variable m_WORD of CString type ,
Have you called GetWindowText in that Function or UpdateData(FALSE) !
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV
-
vinaycool wrote:
CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line;
char * str=new char[MAX]; UpdateData(); lstrcpy(str,m_test.GetBuffer(m_test.GetLength())); The code copies the data from the edit box into the str variable. Knock out 't' from can't, You can if you think you can :cool:
A_Laxman wrote:
vinaycool wrote: CString line;line = m_WORD;char * w =(char *) (LPCTSTR) line;
nope this code will also work well, have a try!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV
-
A_Laxman wrote:
vinaycool wrote: CString line;line = m_WORD;char * w =(char *) (LPCTSTR) line;
nope this code will also work well, have a try!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV
ThatsAlok wrote:
nope this code will also work well, have a try!
Yes buddy, I have tried the code and works fine. as well tried another to do same and posted in my previous post.;P Knock out 't' from can't, You can if you think you can :cool:
-
Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.
Use:
GetDlgItem(IDC_WORD)->GetWindowText(m_WORD);
"The largest fire starts but with the smallest spark." - David Crow
-
Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.
use UpDateData then m_youret.GetWindowText( m_WORD);_**
**_
whitesky
-
Hi, I have a dialog window in which user has to enter some text in the IDC_WORD after clicking on search button i want the value to be stored in a variable line, I have created a variable m_WORD of CString type , CString line; line = m_WORD; char * w =(char *) (LPCTSTR) line; word = w; but the value is not getting stored in line I used F5 and checked value of m_WORD is empty "" what will be cause ..?? can anyone help me with this…. Regards, Vinay Charan.
There is another way to do it :)
- Assign a "Control" variable to your edit box (CEdit m_textEdit).
- Use the method
GetWindowText()
for retrieving the results
void CDemo::OnBnClickedSearchButton()
{
...
CString userResponseText;
m_textEdit.GetWindowText(userResponseText);// userResponseText now contains user response.. ...
}
Here you don't need to worry about
UpdateData
that usually has side effects. Just wanted to give you another way to do it.-- **Ricky Marek** (_AKA: rbid_)
-- "Things are only impossible until they are not" --- Jean-Luc Picard My articles