CRichEditCtrl::StreamIn
Replaces text in this CRichEditCtrl object with text from the specified input stream.
long StreamIn(
int nFormat,
EDITSTREAM& es
);
Parameters
nFormat
Flags specifying the input data formats. See the Remarks section for more information.es
EDITSTREAM structure specifying the input stream. See the Remarks section for more information.
Return Value
Number of characters read from the input stream.
Remarks
The value of nFormat must be one of the following:
SF_TEXT Indicates reading text only.
SF_RTF Indicates reading text and formatting.
Either of these values can be combined with SFF_SELECTION. If SFF_SELECTION is specified, StreamIn replaces the current selection with the contents of the input stream. If it is not specified, StreamIn replaces the entire contents of this CRichEditCtrl object.
In the EDITSTREAM parameter es, you specify a callback function that fills a buffer with text. This callback function is called repeatedly, until the input stream is exhausted.
For more information, see EM_STREAMIN message and EDITSTREAM structure in the Windows SDK.
Example
// 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);
Requirements
Header: afxcmn.h