感谢版主的提醒,原来可以这么简单….
在demo中新增接口
class CMainDlg : public SHostWnd
{
boolOnPopupLinkText(EventArgs* pEvt); };
bool CMainDlg::OnPopupLinkText(EventArgs* pEvt)
{
EventRENotify*pEvtNotify = sobj_cast<EventRENotify>(pEvt);
SChatEdit*pEdit = reinterpret_cast<SChatEdit*>(pEvtNotify->sender);
ENLINK* pnml= reinterpret_cast<ENLINK*>(pEvtNotify->pv);
if (pnml&& pnml->msg == WM_LBUTTONDOWN)//link文字有click响应
{
SStringTstrTxt;//存放link 文字
TEXTRANGEtxtRng;
txtRng.chrg.cpMin= pnml->chrg.cpMin;
txtRng.chrg.cpMax= pnml->chrg.cpMax;
txtRng.lpstrText= (LPTSTR)strTxt.GetBufferSetLength(txtRng.chrg.cpMax - txtRng.chrg.cpMin);
//向RichEdit取得文字范围
pEdit->SSendMessage(EM_GETTEXTRANGE,0, (LPARAM)&txtRng);
strTxt.ReleaseBuffer();
//popup 结果
SMessageBox(NULL,L"URL: \"" + strTxt + L"\"", L"test",MB_OK);
}
return true;
}
LRESULT CMainDlg::OnInitDialog( HWND hWnd, LPARAMlParam )
{
//大约在321行地方
SRichEdit*pEdit = FindChildByName2<SRichEdit>(L"re_gifhost");
if(pEdit)
{
SetSRicheditOleCallback(pEdit,CreateSource2);
pEdit->SetAttribute(L"rtf",L"rtf:rtf_test");
//**********订阅SOUI的一个事件 **********//
pEdit->GetEventSet()->subscribeEvent(EVT_RE_NOTIFY,Subscriber(&CMainDlg::OnPopupLinkText, this));
//***********************************//
}
}
结果图
|