怎么保存CRichEditView中的数据(包括图片)

sb3day 2009-10-22 04:48:04
怎么把CRichEditView中的数据保存到数据库
...全文
166 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
MoXiaoRab 2009-10-23
  • 打赏
  • 举报
回复
不知道你想把其中的数据按怎么样的格式,逐条放进数据库中
liumenghappy 2009-10-23
  • 打赏
  • 举报
回复
帮顶
sb3day 2009-10-23
  • 打赏
  • 举报
回复
我现在可以保存了,但是不知道怎么从数据库中读取到CRichEditView
DWORD CALLBACK MyStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)//读取
{
ADO* myado=(ADO*)dwCookie;//theApp.m_Ado;
CString str_sql;
myado->OnInitADO();
CMainFrame* m_pMf=(CMainFrame*)AfxGetApp()->GetMainWnd();
str_sql.Format("Select D_CONTENT FROM T_TREE WHERE d_TREEID=%ld",m_pMf->m_wndTree.GetCurTreeID());
myado->m_pRecordset=myado->GetRecordSet((_bstr_t)str_sql);
pbBuff=(LPBYTE)(TCHAR*)(_bstr_t)myado->m_pRecordset->GetCollect("D_CONTENT");
*pcb=0;
return 0;
}
void CENBView::SetRtf(ADO ado)//CFile* pInputFile )
{
ADO &myado=theApp.m_Ado;
EDITSTREAM es;
es.dwError = 0;
es.pfnCallback = MyStreamInCallback;
es.dwCookie = (DWORD)&myado;//(DWORD)pRs;//pInputFile;
CRichEditCtrl &m_edit = GetRichEditCtrl();
m_edit.StreamIn(SF_RTF, es); // Do it.
// Read the text in
}
whs1980 2009-10-22
  • 打赏
  • 举报
回复
CRichEditCtrl::StreamOut
Parameters
nFormat
Flags specifying the output data formats. See the Remarks section for more information.

es
EDITSTREAM structure specifying the output stream. See the Remarks section for more information.

Return Value
Number of characters written to the output stream.

Remarks
The value of nFormat must be one of the following:

SF_TEXT Indicates writing text only.

SF_RTF Indicates writing text and formatting.

SF_RTFNOOBJS Indicates writing text and formatting, replacing OLE items with spaces.

SF_TEXTIZED Indicates writing text and formatting, with textual representations of OLE items.

Any of these values can be combined with SFF_SELECTION. If SFF_SELECTION is specified, StreamOut writes out the current selection into the output stream. If it is not specified, StreamOut writes out 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 output stream is exhausted.

For more information, see EM_STREAMOUT message and EDITSTREAM structure in the Windows SDK.

Example
Visual C++ Copy Code
// My callback procedure that writes the rich edit control contents
// to a file.
static DWORD CALLBACK
MyStreamOutCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CFile* pFile = (CFile*) dwCookie;

pFile->Write(pbBuff, cb);
*pcb = cb;

return 0;
}


sb3day 2009-10-22
  • 打赏
  • 举报
回复
怎么得到RTF的数据?[Quote=引用 1 楼 toperray 的回复:]
可以先保存成RTF,然后把RTF数据转换成数据库的内容
[/Quote]
ToperRay 2009-10-22
  • 打赏
  • 举报
回复
可以先保存成RTF,然后把RTF数据转换成数据库的内容

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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