How to insert a realplayer G2 control into a rich edit control?
I try to insert a realplayer G2 control into a rich edit control
but failed. There is only a blank rectangle. Please help here.
+++++++++++++++code begin+++++++++++++++
CTestEmbedActiveXView *pView=(CTestEmbedActiveXView *)GetActiveView();
pView->GetRichEditCtrl().ReplaceSel(_T("begin insert a realplayer activex
control.\n"));
LPSTORAGE lpStorage=NULL;
LPOLEOBJECT lpObject=NULL;
LPVIEWOBJECT2 lpViewObject=NULL;
LPDATAOBJECT lpDataObject=NULL;
RECT rc;
rc.left=0;
rc.right=300;
rc.top=0;
rc.bottom=100;
BOOL bResult=m_realplayer.Create(NULL,_T("realplayer wnd"),WS_CHILD
,rc,this,IDC_REALPLAYER);
ASSERT(bResult!=0);
// Initialize a Storage Object
IUnknown* punk = (IUnknown *)m_realplayer.GetControlUnknown();
ASSERT(punk!=NULL);
punk->QueryInterface(IID_IOleObject, (void **)&lpObject);
ASSERT(lpObject!=NULL);
lpObject->QueryInterface(IID_IStorage, (void **)&lpStorage);
//ASSERT(lpStorage!=NULL);
punk->Release();
lpObject->QueryInterface(IID_IDataObject, (void**)&lpDataObject);
ASSERT(lpDataObject!=NULL);
LPOLECLIENTSITE lpClientSite;
pView->GetRichEditCtrl().GetIRichEditOle()->GetClientSite(&lpClientSite);
ASSERT(lpClientSite!=NULL);
lpObject->QueryInterface(IID_IViewObject2, (void **)&lpViewObject);
ASSERT(lpViewObject!=NULL);
LPADVISESINK lpAdviseSink=NULL;
lpObject->QueryInterface(IID_IAdviseSink, (void**)&lpAdviseSink);
//ASSERT(lpAdviseSink!=NULL);
OleSetContainedObject(lpObject, TRUE);
REOBJECT reo;
memset( &reo, 0, sizeof( reo ) );
reo.cbStruct = sizeof( reo );
CLSID classID;
if ( lpObject->GetUserClassID( &classID ) != S_OK)
classID = CLSID_NULL;
reo.clsid = classID;
reo.cp = REO_CP_SELECTION;
reo.poleobj = lpObject;
reo.pstg = lpStorage;
reo.polesite = lpClientSite;
SIZEL sizel;
sizel.cx = sizel.cy = 0; // let richedit determine initial size
reo.sizel = sizel;
reo.dvaspect = DVASPECT_CONTENT;
reo.dwFlags =REO_BELOWBASELINE;
reo.dwUser = 0;
pView->GetRichEditCtrl().ReplaceSel(_T("\n"));
HRESULT
hResult=pView->GetRichEditCtrl().GetIRichEditOle()->InsertObject(&reo);
ASSERT(hResult==S_OK);
pView->GetRichEditCtrl().ReplaceSel(_T("\n"));
pView->GetRichEditCtrl().ReplaceSel(_T("\n"));
//pView->GetRichEditCtrl().ReplaceSel(_T("\n\n end insert a realplayer
activex control.\n\n"));
if(lpObject)
{
lpObject->Release();
lpObject=NULL;
}
if(lpStorage)
{
lpStorage->Release();
lpStorage=NULL;
}
if(lpDataObject)
{
lpDataObject->Release();
lpDataObject=NULL;
}
if(lpViewObject)
{
lpViewObject->Release();
lpViewObject=NULL;
}
+++++++++++++++code end+++++++++++++++++
--
Best Regards,
Wang Kebo
http://www.huihoo.org/~mep