当然肯定是要实现IRichEditOleCallback这个接口,网上很多文章有这个介绍,
HRESULT STDMETHODCALLTYPE TRichEditOleCallback::QueryAcceptData(LPDATAOBJECT lpdataobj, CLIPFORMAT FAR *lpcfFormat,
DWORD reco, BOOL fReally, HGLOBAL hMetaPict)
{
HRESULT result=S_OK;
if (TRUE==fReally)
{
FORMATETC tFormat={ 0xC007/*FileNameW*/, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
STGMEDIUM tSTGMEDIUM;
ZeroMemory(&tSTGMEDIUM, sizeof(STGMEDIUM));
if (S_OK==lpdataobj->GetData(&tFormat,&tSTGMEDIUM))
{
LPOLESTR pstrData =(LPOLESTR)GlobalLock(tSTGMEDIUM.lpszFileName); //GlobalLock(tSTGMEDIUM.lpszFileName);
/*
USES_CONVERSION;
CString strFileName =OLE2T(pstrData);
HYPERLINKINFO linkInfo;
NMHDR header;
header.hwndFrom = m_RichEditCtrl->m_hWnd ;
header.idFrom = m_RichEditCtrl->GetDlgCtrlID();
header.code = 0xFFFF;
m_RichEditCtrl->GetParent()->SendMessage(WM_NOTIFY,(WPARAM)strFileName.GetBuffer(0),(LPARAM)&header);
*/
GlobalUnlock(tSTGMEDIUM.lpszFileName);
ReleaseStgMedium(&tSTGMEDIUM);
return S_FALSE;
}
}
return S_OK;
}