使用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分都没问题!
最让我崩溃的是
在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分都没问题!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货