Solved

Need to show whole text file in a edit box.

Posted on 1998-08-02
6
202 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Get filename and folder into excel 7 74
modThree challenge 4 90
Sed question 2 84
Problem to App 4 80
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 …

776 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