|
发表于 2020-1-11 08:36:01
|
显示全部楼层
static DWORD CALLBACK
MyStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CFile* pFile = (CFile*) dwCookie;
*pcb = pFile->Read(pbBuff, cb);
return 0;
}
static DWORD CALLBACK
MyStreamOutCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CFile* pFile = (CFile*) dwCookie;
//pbBuff就是你要的
return 0;
}
void CAboutDlg::OnButton1()
{
CFile cFile(TEXT("myfile.rtf"), CFile::modeRead);
EDITSTREAM esin, esout;
CRichEditCtrl m_richedit;
m_richedit.Create(
WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE,
CRect(10,10,100,200), this, 1);
esin.dwCookie = (DWORD) &cFile;
esin.pfnCallback = MyStreamInCallback;
m_richedit.StreamIn(SF_RTF, esin);
esout.dwCookie = (DWORD) &cFile;
esout.pfnCallback = MyStreamOutCallback;
m_richedit.StreamOut(SF_TEXT, esout);
}
|
|