Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Accessing text of an edit box

Posted on 1998-10-29
2
Medium Priority
?
291 Views
Last Modified: 2013-11-20
I have an edit box named IDCTextFormula in a window. Is this the easiest way to change its text?:

CEdit* formula = (CEdit*)GetDlgItem(IDCTextFormula);
formula->SetWindowText("test");

Likewise, with any control, do you have to go through all that work just to access a method?
0
Comment
Question by:TylerRick
[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
2 Comments
 
LVL 4

Accepted Solution

by:
pagladasu earned 160 total points
ID: 1324027
If you do not want to use GetDlgItem, you can try member variables.
Using class wizard, let us say you associate a member variable of type CString
with the edit control IDCTextFormula. Let us say the name of this variable is
m_edit_textformula.
In your code where you want to change the contents of the edit control, you write
m_edit_textformula="test";
UpdateData(FALSE);

The other method could be by using class wizard and associating a control type
of variable (of type CEdit) with the edit control IDCTextFormula. Let us this is called m_editctrl. Then in your code you write:
m-editctrl.SetWindowText("test");

Hope you will find this an easier method.

Thanks.
Pagladasu

0
 

Expert Comment

by:aasif
ID: 1324028
It all depend on your choice. You can define a variable for it (with the help of Class Wizard) or access it through GetDlgItem method. Usually I use Class Wizard for such type of controls which I access number of times, where as I have to access a control in my application only few time I use

(CEdit* GetDlgItem(IDCTextFormula))->SetWindowText("Test");

In your case, you can also define a CString type varaiable with your CEdit control through Class Wizard, and after moving new value just call UpdateData(FALSE). This will update your Edit Box with new value.



0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

636 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