我在对话框上放了一个RichEditControl控件,
而且使用了AfxInitRichEdit2()函数对其进行初始化,
并设置了该控件的一个对象,m_RichOutInfo。我如何才能将我磁盘上的另一个文件,比如test.txt的内容通过RichEditControl控件显示出来?谢谢高手指教!!

解决方案 »

  1.   


    CString Pathname = "test.txt"; // The file from which to load the contents of the rich edit control.
    CFile cFile(Pathname, CFile::modeRead);
    EDITSTREAM es; es.dwCookie =  (DWORD) &cFile;
    es.pfnCallback = (EDITSTREAMCALLBACK) MyStreamInCallback; m_RichOutInfo.StreamIn(SF_TEXT,es); // Perform the streaming
      

  2.   


    MyStreamInCallback函数该如何写呢???我也试过了,
    可是,解释却是:Replaces text in this CRichEditCtrl object with text from the specified input stream
      

  3.   


    DWORD CALLBACK MyStreamInCallback(CFile* dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
    {
    // Required for StreamIn
    CFile* pFile = (CFile*) dwCookie; *pcb = pFile->Read(pbBuff, cb); return 0;
    }
      

  4.   

    the demo code can easily get in msdn,
    but it does not work...