?
Solved

Need to show whole text file in a edit box.

Posted on 1998-08-02
6
Medium Priority
?
230 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
[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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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. …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

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