CRichEditCtrl读取RTF文件问题 高手请进,高分求助!

df8327 2010-05-04 05:55:28
使用StreamIn读取RTF文件,可以获得由格式的文本,但是无法获得RTF中包括的图片,而是用word打开rtf文件就没问题
最让我崩溃的是
在RichEditView中就没问题,彻底无语了
下面是CRiceeditView里可用的代码

oid CRichEgView::OnReadin()
{
CString sWriteText; //Where the text will be streamed from

sWriteText="";
CFileDialog cFileDlg(TRUE,NULL,NULL,OFN_READONLY,"rtf file (*.rtf)|*.rtf");
if(cFileDlg.DoModal()==IDOK)
{
CFile cFile(cFileDlg.GetPathName(), CFile::modeRead);
UINT len= cFile.GetLength()+10;

cFile.Read(sWriteText.GetBufferSetLength(len),len);
EDITSTREAM es;

es.dwCookie = (DWORD)&sWriteText; // Pass a pointer to the CString to the callback function
es.pfnCallback = MEditStreamInCallback; // Specify the pointer to the callback function
GetRichEditCtrl().StreamIn(SF_RTF,es); // Perform the streaming
}
}
下面是richeditctrl中不可用的代码
CStringA strRTF(strRTFW.GetString()) ;
EDITSTREAM es;
es.dwError = 0;
es.pfnCallback = CStringFormatToRTF;
es.dwCookie = (DWORD) &strRTF;
StreamIn(SF_RTF|SFF_SELECTION, es);
两个回调函数名字不同代码完全一致
DWORD CALLBACK CYMsgRichEditCtrl::CStringFormatToRTF(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CStringA *psBuffer = (CStringA *)dwCookie;

if (cb > psBuffer->GetLength()) cb = psBuffer->GetLength();

for (int i=0;i<cb;i++) {
*(pbBuff+i) = psBuffer->GetAt(i);
}

*pcb = cb;

*psBuffer = psBuffer->Mid(cb);

return 0;
}
我就不明白了
为什么使用dialog就不能显示图像呢? 这个问题困扰我好几天了,哪位大哥帮我搞定,再开贴给200分都没问题!
...全文
164 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Eleven 2010-05-04
  • 打赏
  • 举报
回复
wuhuwy 2010-05-04
  • 打赏
  • 举报
回复
帮顶,看看

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧