CRichEditCtrl::StreamIn

long StreamIn( int nFormat**, EDITSTREAM&** es );

Return Value

Number of characters read from the input stream.

Parameters

nFormat

Flags specifying the input data formats. See the Remarks section for more information.

es

structure specifying the input stream. See the Remarks section for more information.

Remarks

Call this function to replace text in this CRichEditCtrl object with text from the specified input stream.

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 which fills a buffer with text. This callback function is called repeatedly, until the input stream is exhausted.

For more information, see message and structure in the Win32 documentation.

Example

// My callback procedure that writes the rich edit control contents
// to 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 pointer to my rich edit control.
   extern CRichEditCtrl* pmyRichEditCtrl;
   // The file from which to load the contents of the rich edit control.
   CFile cFile(TEXT("myfile.rtf"), CFile::modeRead);
   EDITSTREAM es;

   es.dwCookie = (DWORD) &cFile;
   es.pfnCallback = MyStreamInCallback;
   pmyRichEditCtrl->StreamIn(SF_RTF, es);

CRichEditCtrl OverviewClass MembersHierarchy Chart

See Also   CRichEditCtrl::StreamOut