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

    Reading Text into a CStatic

    Hello. I am attempting to read a standard ASCII text file into a CStatic.
    So far, i use this type of method:

    CViewDlg dlg;
    CString szNfo;
    FILE *f;
    f = fopen("tt.txt", "r");
    if(f == NULL)
    {
    MessageBox("Couldent open tt.txt!", "Error", MB_ICONERROR);
    return;
    }

    byte buf[1];
    while(fread(&buf[0],1,1,f))
    {
    CString na = "\r";
    CString nb = "\n";
    if(buf[0] == na)
    szNfo+="\n";
    else
    szNfo += buf[0];
    }
    fclose(f);
    dlg.m_szNfo = szNfo;
    dlg.DoModal();

    But when the CStatic comes up, it has the text, but all the line returns "\n" are replaced with Blocks! If you can give me some help i would be very appreciative.
    thanks,
    jason



  2. #2
    Guest

    Re: Reading Text into a CStatic

    You should use CString strCrLf = CString( char(13) ) + CString( char(10) );
    and use strCrLf instead of \n.


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