• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

Need to show whole text file in a edit box.

I have code below which loads a text file into an edit box on a dialog window.  Only it only show the first 100 or so characters.  I have scroll boxes etx, but how can I get it to show the whole text file in any length.  That way I can scroll down the text file in the edit box in the dialog window.  Am I using the wrong kind of variable.  It's set as a value and then CString.  I use ClassWizrad.

Please speak in laymens terms, I'm a newbie and will get lost easy if you use crazy words.

Here's my code.

void CNumbersDlg::OnLoadNumbers()
      // TODO: Add your control notification handler code
        // here

      //Will Load the Numbers.TXT File

      CFile f;
      if ( f.Open("E:\\Numbers.txt", CFile::modeRead)== FALSE )

      //Creare an archive odject
      CArchive ar( &f, CArchive::load );

      //Serialzie data from the archive into m_NumbersEdit
      ar >> m_NumbersEdit;

      //Close the archive

      //Close the file.

      //Update screen with the Numbers information
  • 3
  • 2
1 Solution
Have you set the dialog box to be multi-lined?  And is the variable m_NumbersEdit a CString?
fredmastroAuthor Commented:
The Dialog box is multi-lined and the the variable is CSting. (I mentioned that in the original question).
There are two ways of doing this.......

for both the method add variable for  the edit box--> as control  
a) Using Messages

1) See whether the string you r loading have linefeed or not... linefeed as ascii value 10
2) if not u have to send WM_KEYDOWN message to edit box after each line end encountered in cstring.
3)and then use setwindowtext.

b) using Drawtext....
1) Get the Dc of edit box.
2) calculate the text height..... using GettextMetrics
3)use Drawtext for eachine and specify correct rectangle... (u have to use loop)
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Second method is tested one....
fredmastroAuthor Commented:
Too complicated for a newbie like me.
fredmastroAuthor Commented:
Too complicated for me.  I did other researhing and found that you can't add all those characters to an edit box unless I change it's buffer somehow.  I have to use a richedit box.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now