CFile file("d:\\新建文件夹\\shen0.mpg",CFile::modeRead);
char pbuf[2048];
file.Read(pbuf,2048);
GetDlgItem(IDC_EDIT1)->SetWindowText(pbuf);
这是我的程序,为什么文本框中什么也没有?

解决方案 »

  1.   

    要讲你的字符串变为CString
    在SetWindowText前加上,最好在你的缓冲区里加上'\0'
    CString str;
    str.Format("%s",pbuf);
      

  2.   

    要讲你的字符串变为CString
    在SetWindowText前加上,最好在你的缓冲区里加上'\0'
    CString str;
    str.Format("%s",pbuf);
      

  3.   

    char pbuf[2048];
    file.Read(pbuf,2048);
    GetDlgItem(IDC_EDIT1)->SetWindowText(pbuf);碰到不可显示字符和\0了,所以什么也没有,
    。mepg里很多0x00的。跟UpdateData和字符串变为CString无关。你打开一个文本文件就可以看到了。
      

  4.   

    可能是读取不成功,另外最好在pbuf加上'\0'因为有的时候读出来的
    不一定就是2028个字节.
      

  5.   

    我想打开的是mpg文件,应该怎样显示?