Solved

Accessing text of an edit box

Posted on 1998-10-29
2
251 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 88
Expand data scrubbing tool 13 31
Expand to include initial dialog with two choices. 9 59
noX challenge 17 77
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

20 Experts available now in Live!

Get 1:1 Help Now