• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

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
0
genuinegenius
Asked:
genuinegenius
  • 3
1 Solution
 
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now