有熟悉CRichEditCtrl 控件的吗?如何获取GetSel的光标区域之内的rtf数据?

cxdnnew 2019-07-08 07:40:24
有熟悉CRichEditCtrl 控件的吗?如何获取GetSel的光标区域之内的rtf数据?
不要使用copy和paste,要直接获取
因为使用copy函数会被监视剪贴板的程序干扰
...全文
107 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxdnnew 2019-07-10
  • 打赏
  • 举报
回复
引用 7 楼 schlafenhamster 的回复:
没看到 // get all ; "|SFF_SELECTION"// get all ; "|SFF_SELECTION" 吗?


啊,感谢感谢!
这么写吗?

LONG cselect = m_RichEdit.StreamOut( SF_RTF | SFF_SELECTION, es);

return TRUE;
schlafenhamster 2019-07-10
  • 打赏
  • 举报
回复
没看到 // get all ; "|SFF_SELECTION"// get all ; "|SFF_SELECTION" 吗?
cxdnnew 2019-07-10
  • 打赏
  • 举报
回复
引用 3 楼 schlafenhamster 的回复:
调用
CString sRTF;
GetRTF(sRTF);

不是这样的,你提供的这个函数无法控制输出的区域,用了CString 之后,获取的数据没有格式信息,包括字体信息,实际我需要获取GetSel的光标之内的数据,比如鼠标选择的一个区域内部的数据,类似于鼠标框选的数据 ,但是不能用copy函数和paste函数
cxdnnew 2019-07-10
  • 打赏
  • 举报
回复
引用 2 楼 schlafenhamster 的回复:
参考
// function to stream the RTF string out of the rich edit control.
DWORD CALLBACK CBStreamOut(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
// Address of our string var is in psEntry
CString *pStr = (CString*) dwCookie;
*pStr += CString(pbBuff).Left(cb);
return 0;
}
//SF_TEXT SF_RTF
BOOL CPeekCommDlg::GetRTF(CString &str)
{
// Return the RTF string of the text in the control.
EDITSTREAM es;
es.dwError = 0;
es.pfnCallback = CBStreamOut;// Set the callback
es.dwCookie = (DWORD) &str; // receives the string
// get all ; "|SFF_SELECTION"
LONG all=m_RichEdit.StreamOut(SF_RTF, es);
// afxDump << all <<"\r\n";
return TRUE;
}

不是这样的,你提供的这个函数无法控制输出的区域,我需要获取GetSel的光标之内的数据,比如鼠标选择的一个区域内部的数据,类似于鼠标框选的数据 ,但是不能用copy函数和paste函数
cxdnnew 2019-07-10
  • 打赏
  • 举报
回复
引用 2 楼 schlafenhamster 的回复:
参考
// function to stream the RTF string out of the rich edit control.
DWORD CALLBACK CBStreamOut(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
// Address of our string var is in psEntry
CString *pStr = (CString*) dwCookie;
*pStr += CString(pbBuff).Left(cb);
return 0;
}
//SF_TEXT SF_RTF
BOOL CPeekCommDlg::GetRTF(CString &str)
{
// Return the RTF string of the text in the control.
EDITSTREAM es;
es.dwError = 0;
es.pfnCallback = CBStreamOut;// Set the callback
es.dwCookie = (DWORD) &str; // receives the string
// get all ; "|SFF_SELECTION"
LONG all=m_RichEdit.StreamOut(SF_RTF, es);
// afxDump << all <<"\r\n";
return TRUE;
}

不是这样的,你提供的这个函数无法控制输出的区域,我需要获取GetSel的光标之内的数据,比如鼠标选择的一个区域内部的数据,类似于鼠标框选的数据
schlafenhamster 2019-07-09
  • 打赏
  • 举报
回复
调用
CString sRTF;
GetRTF(sRTF);
schlafenhamster 2019-07-09
  • 打赏
  • 举报
回复
参考
// function to stream the RTF string out of the rich edit control.
DWORD CALLBACK CBStreamOut(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
// Address of our string var is in psEntry
CString *pStr = (CString*) dwCookie;
*pStr += CString(pbBuff).Left(cb);
return 0;
}
//SF_TEXT SF_RTF
BOOL CPeekCommDlg::GetRTF(CString &str)
{
// Return the RTF string of the text in the control.
EDITSTREAM es;
es.dwError = 0;
es.pfnCallback = CBStreamOut;// Set the callback
es.dwCookie = (DWORD) &str; // receives the string
// get all ; "|SFF_SELECTION"
LONG all=m_RichEdit.StreamOut(SF_RTF, es);
// afxDump << all <<"\r\n";
return TRUE;
}
zgl7903 2019-07-09
  • 打赏
  • 举报
回复

15,979

社区成员

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

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