Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to put text file's data into CView.

Posted on 1999-07-20
2
Medium Priority
?
228 Views
Last Modified: 2013-11-20
I have a char pointer - char * lpData - with holds all the char data(including LF,CR) from a text file(for some reason, i can not directly load the data from file). Now I want to put these data into CView area like those text editor open a text file.
how would I implement this ?
I don't think it is a good idea to loop through lpData and print character by character, isn't it ?
0
Comment
Question by:eugeneng
[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
2 Comments
 
LVL 8

Accepted Solution

by:
VinExpert earned 80 total points
ID: 1310542
Hi,
You can do that using DrawText() function.
This is the code segment for your question.
Here you can specify the rectangle value or you can fill it using GetClientRect() function also

      CFile l_file;
      char *lpData = NULL;
      CClientDC dc(this);
      int l_Length = 0;

      if(!l_file.Open("d:\\temp\\list\\text1.txt",CFile::modeRead))
      {
            AfxMessageBox("not opened");
            return;
      }
      l_Length = l_file.GetLength();

      lpData = new char[l_Length+1];
      memset(lpData,0,l_Length+1);

      l_file.Read(lpData,l_Length);
      CRect rect(10,10,400,100);
      
      dc.DrawText(lpData,-1,rect,DT_EXPANDTABS);
      l_file.Close();
Take care to delete the character pointer.

Hope it helps you.

0
 

Author Comment

by:eugeneng
ID: 1310543
thanx VinExpert, you code work fine. Actually i just need this

dc.DrawText(lpData,-1,rect,DT_EXPANDTABS);

anyhow, thanx a lot man..
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

715 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