CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    3

    show text in CView

    Hi I would like to open a text file and display it's contents in a View? I can get to the stage where i get the path of the file I'd like to open then what?

    Thanks in advance


  2. #2
    Join Date
    Apr 1999
    Posts
    306

    Re: show text in CView

    Get the reference help of:
    Serialize();
    CArchive class
    try ReadString() of it and then pDC->TextOut()
    or use the overloaded << and >>
    In general read the related help about the above
    and you will manage with this hard problem!


  3. #3
    Join Date
    Apr 1999
    Posts
    16

    Re: show text in CView

    You should use the CEditView, not the CView.
    After that,just do it as following:
    CStdioFile stdfile(filename,CFile::modeRead);
    CString str1="";
    CString str2="\r\n";
    while(stdfile.ReadString(str1))
    str2+=str1+"\r\n";
    YourView->GetEditCtrl()->SetWindowText(str2);
    Try it,hope it works.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured