CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2003
    Posts
    8

    Question Help with text in a dialog

    hi does anybody know much about CFile? i have a problem, i can get text in a dialog box like i want but at the very end i get a funny looking character and i am using CFile heres what the code lookes like

    char szBuffer [5056];
    CFileException fileException;
    CString filename = "readme.txt";
    CFile myFile;

    if ( !myFile.Open( filename, CFile::modeReadWrite, &fileException ))
    {
    TRACE( "Can't open file %s, error = %u\n", filename, fileException.m_cause );
    }
    myFile.Read(szBuffer, sizeof(szBuffer));
    m_sEdit1 = szBuffer;
    myFile.Flush();
    UpdateData(0);


    and here is what the funny looking character looks like Ì*ù please help

  2. #2
    Join Date
    Aug 1999
    Location
    Wisconsin
    Posts
    507
    I am not sure what m_sEdit1 is, but I would guess
    you need to add a terminating zero to szBuffer
    before copying it to m_sEdit1.

  3. #3
    Join Date
    Nov 2003
    Posts
    8
    m_sEdit1 is the member varible for a edit box in a dialog could u post a example of what ur talking about terminating zero to szbuffer please or show me how to do it in my code

  4. #4
    Join Date
    Aug 1999
    Location
    Wisconsin
    Posts
    507
    Something like this:

    Code:
    UINT ui=myFile.Read(szBuffer, sizeof(szBuffer)-1);
    szBuffer[ui]=0;
    m_sEdit1 = szBuffer;

  5. #5
    Join Date
    Nov 2003
    Posts
    8
    thank you i put the code in and it works like a charm thanks

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