Solved

VC ++ Very easy question

Posted on 1999-01-28
5
203 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

808 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