Solved

Need to show whole text file in a edit box.

Posted on 1998-08-02
6
182 Views
Last Modified: 2013-11-19
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 )
            return;

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

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

      //Close the archive
      ar.Close();

      //Close the file.
      f.Close();

      //Update screen with the Numbers information
      UpdateData(FALSE);
}
0
Comment
Question by:fredmastro
  • 3
  • 2
6 Comments
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1320126
Have you set the dialog box to be multi-lined?  And is the variable m_NumbersEdit a CString?
0
 
LVL 2

Author Comment

by:fredmastro
ID: 1320127
The Dialog box is multi-lined and the the variable is CSting. (I mentioned that in the original question).
0
 

Accepted Solution

by:
slicer earned 100 total points
ID: 1320128
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)
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Expert Comment

by:slicer
ID: 1320129
Second method is tested one....
0
 
LVL 2

Author Comment

by:fredmastro
ID: 1320130
Too complicated for a newbie like me.
0
 
LVL 2

Author Comment

by:fredmastro
ID: 1320131
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.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Whole sheet autoscrub still needed 19 44
sameEnds challenge 3 107
sum13 challenge 24 77
has77  challenge 9 68
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

746 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

14 Experts available now in Live!

Get 1:1 Help Now