Solved

Accessing text of an edit box

Posted on 1998-10-29
2
260 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
2 Comments
 
LVL 4

Accepted Solution

by:
pagladasu earned 40 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Powershell based monitoring system 2 140
GIF file bit manipulation for color change 5 107
repeatSeparator  java  challenge 13 56
dog bark java program 15 87
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now