Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VC ++ Very easy question

Posted on 1999-01-28
5
Medium Priority
?
220 Views
Last Modified: 2010-04-02
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
Comment
Question by:genuinegenius
  • 3
5 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 400 total points
ID: 1185432
here...

CString MyStr;

GetDlgItem(IDC_EDIT1)->GetWindowText(MyStr);

MessageBox(MyStr);

This would also display the message...

-Viktor
--Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1185433
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
 
LVL 3

Expert Comment

by:SuperMario
ID: 1185434
Do what Viktor says. It works.
0
 

Author Comment

by:genuinegenius
ID: 1185435
Cheers. Look here for more questions. I could be needing some help!
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1185436
ok, no problem....
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question