Re: Dropping Something On Webbrowser Control
- From: liangrf@xxxxxxxxx
- Date: 27 Feb 2006 17:08:29 -0800
Code snippet as following.
Invoke::(...)
{
if ( dispidMember==DISPID_ONDROP )
{
CComQIPtr<IHTMLEventObj2> pEvent2;
CComQIPtr<IHTMLEventObj> pEvent;
CComQIPtr<IHTMLWindow> pWin;
// Get IHTMLWindow interface by IHTMLDocument2;
......
HRESULT hr;
hr = pWin->get_event( &pEvent );
pEvent2 = pEvent;
CComQIPtr<IHTMLDataTransfer> pData;
hr = pEvent2->get_dataTransfer( &pData );
if ( SUCCEEDED( hr ) && pData )
{
CComQIPtr<IServiceProvider> pSP;
hr = pData->QueryInterface( IID_IServiceProvider, (LPVOID*)&pSP
); // you may "pSP = pData" too;
CComQIPtr<IDataObject> pDataObj;
hr = pSP->QueryService( IID_IDataObject, IID_IDataObject,
(LPVOID*)&pDataObj );
CString strClipHTML;
STGMEDIUM medium;
if ( SUCCEEDED( hr ) && pDataObj )
{
// Register HTML Clipboard Format
const UINT uFormat=::RegisterClipboardFormat(_T("HTML Format"));
UINT iFormat=uFormat;
STGMEDIUM medium;
FORMATETC Formatetc = {iFormat, 0, DVASPECT_CONTENT, -1, DWORD(-1)};
hr = pDataObj->GetData(&Formatetc, &medium);
// Get clipBoard content;
strClipHTML = (char*)GlobalLock( medium.hGlobal );
// You may tidy up clipBoard HTML's content
......
GlobalUnlock(medium.hGlobal);
}
// Paste strHTMLClip to Browser
CComQIPtr<IHTMLTxtRange> pRange;
// Search group, will get IHTMLTxtRange from Select object;
......
pRange->pasteHTML( strClipHTML.AllocSysString() );
// Cancel bubble
pEventObj->put_cancelBubble( VARIANT_TRUE );
......
}
}
}
.
- References:
- Dropping Something On Webbrowser Control
- From: ILAZAR
- Re: Dropping Something On Webbrowser Control
- From: liangrf
- Re: Dropping Something On Webbrowser Control
- From: ILAZAR
- Dropping Something On Webbrowser Control
- Prev by Date: Re: asynchronous pluggable protocol info
- Next by Date: Double Click to Select Text
- Previous by thread: Re: Dropping Something On Webbrowser Control
- Next by thread: How to catch ActiveX Install or Excute using BHO?
- Index(es):