richeditctrl StreamIn(SF_RTF,es) 失败
void myedc::setRTF(CString & instr)
{
EDITSTREAM es;
es.dwError=0;
es.dwCookie=(DWORD)&instr;
es.pfnCallback=edcstreamin;
int x=StreamIn(SF_RTF,es); //如果用SF_TEXT就可以 用SF_RTF 返回0
if(es.dwError!=0)
AfxMessageBox(itos(es.dwError));
}
用SF_RTF x值为0 es.dwError=-16
下面是edcstreamin函数
DWORD CALLBACK myedc::edcstreamin(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CString* pinstr=(CString*)dwCookie;
if(pinstr->GetLength()<=cb)
{
*pcb=pinstr->GetLength();
for (int i=0;i<*pcb;i++)
*(pbBuff+i) = pinstr->GetAt(i);
pinstr->Empty();
}
else
{
*pcb=cb;
for (int i=0;i<cb;i++)
*(pbBuff+i) = pinstr->GetAt(i);
*pinstr=pinstr->Right(pinstr->GetLength()-cb);
}
return 0;
}
困扰我很久了