VC ++ Very easy question

I am using MFC. Can someone give me some code which I can put in a function mapped to a button click event that will return the text in an edit box call IDC_EDIT1 to a CString variable
genuinegeniusAsked:
Who is Participating?
 
viktornetCommented:
here...

CString MyStr;

GetDlgItem(IDC_EDIT1)->GetWindowText(MyStr);

MessageBox(MyStr);

This would also display the message...

-Viktor
--Ivanov
0
 
viktornetCommented:
YOu could also do it like this which is a better way than the previous...

CString MyStr;
((CEdit *)GetDlgItem(IDC_EDIT1))->GetWindowText(MyStr);
MessageBox(MyStr);

or even this...

CString MyStr;
CEdit *pMyEdit = (CEdit *)GetDlgItem(IDC_EDIT1);

pMyEdit->GetWindowText(MyStr);

MessageBox(MyStr);

Hope this helps...

-Viktor
--Ivanov
0
 
SuperMarioCommented:
Do what Viktor says. It works.
0
 
genuinegeniusAuthor Commented:
Cheers. Look here for more questions. I could be needing some help!
0
 
viktornetCommented:
ok, no problem....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.