Solved

Read Only Edit Box Won't Update

Posted on 2006-10-22
5
717 Views
Last Modified: 2013-11-20
I have a read only edit box that I'm trying to use to display a file-count in a dialog box when the dialog box opens.

As part of the initialization of the dialog box, some files are counted and I know that's working but I can't get the count-value to display in an edit box (either as an integer or as a string).

I even tried adding a button to manually force the program-calculated value into the dialog box.  But the dialog box remains blank.

Articles on the subject seemed to break down into two categories:

1.  Those which warn against using GetDlgItem, but then don't tell you how to use an alternative.
2.  Those which warn against using UpdateData, but then don't tell you how to use an alternative.

I tried both methods, get no errors, and nothing displays in the edit box.  Right now, I'm just trying to display:  "test".  Can't even do that.

Googling the subject is an exercise in bizarro world help, where the help exists only at the very beginning levels and what seems to me to be the much more advanced levels, with nothing in between.

And what's really bizarre is I actually solved this problem several years ago (I don't do all that much MFC programming) and the program I wrote actually worked using GetDlgItem, using a single parameter, but when I try to use GetDlgItem in my new program I get an error saying GetDlgItem doesn't take only one parameter.    In both cases I was using Visual C++6.0.  In fact, using the same installation of it on the same computer and it works in one program and not in another.  

I'm not against using two parameters (the first one being a handle), but I have no idea how to do it, or how to find help with it, since all help on the subject seems to assume that the reader already knows as much about handles as everybody else, or why I need it in one program and not in another.

Any help would be greatly appreciated.
0
Comment
Question by:gateguard
5 Comments
 

Author Comment

by:gateguard
ID: 17783051
Correction:

This:

I even tried adding a button to manually force the program-calculated value into the dialog box.  But the dialog box remains blank.

Should be:

I even tried adding a button to manually force the program-calculated value into the EDIT BOX.  But the EDIT BOX remains blank.
0
 
LVL 48

Assisted Solution

by:AlexFM
AlexFM earned 100 total points
ID: 17783106
Can you show your code?
If you do this in MFC CDialog-derived class, it should be:

GetDlgItem(ID_TEXT)->SetWindowText(_T("test"));

ID_TEXT - resource ID of textbox.
0
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 300 total points
ID: 17783213
I am not sure why you need GetDlgItem in your application if its MFC application.

If your application is MFC application, then you may create a member variable for your editbox using classwizard of CEdit or CString type.

In your resource editor after adding Editbox to your dialog, invoke classwizard either by pressing CTRL+W or right click on dialog and select classwizard. Class Wizard dialog will open.. click on 2nd tab 'Member Variables'. Select CONTROL ID from list and click on 'Add Variable' button. Now in add variable dialog type variable name whatever u want like m_Editrw and select variable type as 'Control' from Category combobox and click OK. Now you have control variable m_Editrw associated with your editbox which is CEdit type.

Now you can access directly CEdit class members for your edit control and you dont need to use GetDlgItem etc.

to set text to your editbox you can now directly use  m_Editrw.SetWindowText("45");

However in classwizard while adding member variable if you have selected 'Control' under Category as variable type then you may set text like :

m_Edit = "45";
UpdateData(false);

Hope this helps
-MAHESH
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17783227
*Correction in above:

However in classwizard while adding member variable if you have selected 'VALUE' under Category as variable type then you may set text like :

m_Edit = "45";
UpdateData(false);

-MAHESH
0
 
LVL 5

Assisted Solution

by:Nass89
Nass89 earned 100 total points
ID: 17783320
Hi,
You wrote, you are counting a file, are you writing in the EditBox in a while-loop?
If you have a loop then use the following codes!

for(.......){
          m_ctrlEdit.SetWindowText("Your Text"r);
          m_ctrlEdit.UpdateWindow();

          ....//your codes
          ....
          ....
          ....
}

Good luck
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
Need a Shell script to start a service checking the port 6 48
Tab names are off by one 5 53
maven archtype selection in eclipse 1 53
Change to event 1 103
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

863 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

23 Experts available now in Live!

Get 1:1 Help Now