Solved

VC ++ Very easy question

Posted on 1999-01-28
5
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 100 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

Industry Leaders: 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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

622 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