Solved

Read Only Edit Box Won't Update

Posted on 2006-10-22
5
728 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
[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
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

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

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…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 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