CRichEditCtrl::StreamIn

使用所指定輸入資料流的文字取代此 CRichEditCtrl 物件的文字。

long StreamIn(
   int nFormat,
   EDITSTREAM& es 
);

參數

  • nFormat
    指定輸入資料格式的旗標。如需詳細資訊,請參閱「備註」一節。

  • es
    指定輸入資料流的EDITSTREAM 結構。如需詳細資訊,請參閱「備註」一節。

傳回值

從輸入資料流讀取的字元數。

備註

nFormat 的值必須是下列其中一項:

  • SF_TEXT 表示只讀取文字。

  • SF_RTF 表示讀取文字和格式。

這些值的其中一個可以結合 SFF_SELECTION。如果 SFF_SELECTION 指定, StreamIn 以輸入資料流的內容取代目前的選取範圍。如果未指定, StreamIn 取代這個 CRichEditCtrl 物件的整個內容。

EDITSTREAM 參數 es,您指定的文字來填滿緩衝區的回呼函式。這個回呼函式,重複呼叫,直到輸入資料流已用盡。

如需詳細資訊,請參閱 EM_STREAMIN 訊息和 EDITSTREAM 結構在 Windows SDK。

範例

// My callback procedure that reads the rich edit control contents
// from a file.
static DWORD CALLBACK 
MyStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
   CFile* pFile = (CFile*) dwCookie;

   *pcb = pFile->Read(pbBuff, cb);

   return 0;
}
// The example code.

// The file from which to load the contents of the rich edit control.
CFile cFile(TEXT("My_RichEdit_InFile.rtf"), CFile::modeRead);
EDITSTREAM es;

es.dwCookie = (DWORD) &cFile;
es.pfnCallback = MyStreamInCallback; 
m_myRichEditCtrl.StreamIn(SF_RTF, es);

需求

Header: afxcmn.h

請參閱

參考

CRichEditCtrl 類別

階層架構圖

CRichEditCtrl::StreamOut