本文整理汇总了C++中LPDISPATCH::QueryInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDISPATCH::QueryInterface方法的具体用法?C++ LPDISPATCH::QueryInterface怎么用?C++ LPDISPATCH::QueryInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDISPATCH
的用法示例。
在下文中一共展示了LPDISPATCH::QueryInterface方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetCustomDocUIHandler
HRESULT WebBrowserEventSinker::SetCustomDocUIHandler(LPDISPATCH lpDisp)
{
if(lpDisp == NULL)
return E_INVALIDARG;
IWebBrowser2Ptr pWebBrowser2;
HRESULT hr = lpDisp->QueryInterface(IID_IWebBrowser2, (void**)&pWebBrowser2);
if(SUCCEEDED(hr) && pWebBrowser2)
{
IDispatchPtr pDoc;
hr = pWebBrowser2->get_Document(&pDoc);
if(SUCCEEDED(hr) && pDoc)
{
ICustomDocPtr pCustDoc;
hr = pDoc->QueryInterface(IID_ICustomDoc, (void**)&pCustDoc);
if(SUCCEEDED(hr) && pCustDoc != NULL)
{
IDocHostUIHandler* pUIHandler;
CreateObjectInterface<CDocHostUIHandler, IDocHostUIHandler>(NULL, &pUIHandler);
if (pUIHandler)
pCustDoc->SetUIHandler(pUIHandler);
pUIHandler->Release();
}
}
}
return hr;
}
示例2: DocumentComplete
void CHTMLViewCapView::DocumentComplete(LPDISPATCH pDisp, VARIANT* URL)
{
UNUSED_ALWAYS(pDisp);
UNUSED_ALWAYS(URL);
HRESULT hr;
IUnknown* pUnkBrowser = NULL;
IUnknown* pUnkDisp = NULL;
// 这个 DocumentComplete 事件是否是顶层框架窗口的?
// 检查 COM 标识: 比较IUnknown 接口指针.
hr = m_pBrowserApp->QueryInterface(IID_IUnknown, (void**)&pUnkBrowser);
if ( SUCCEEDED(hr) ) {
hr = pDisp->QueryInterface(IID_IUnknown, (void**)&pUnkDisp);
if ( SUCCEEDED(hr) ) {
if ( pUnkBrowser == pUnkDisp ) {
TRACE("Top Document completely loaded!\n");
EndModalLoop(S_OK);
//::SetEvent(m_hDocCompleteEvent);
}
}
pUnkDisp->Release();
}
pUnkBrowser->Release();
}
示例3: SelectThing
void CThingTreeCtrl::SelectThing(LPDISPATCH Thing)
{
IThing *pCurrentThing = NULL;
HRESULT hr = S_OK;
long lCurrentID;
HTREEITEM htItem = NULL;
if (FAILED(hr = Thing->QueryInterface(IID_IThing, (void**)&pCurrentThing)))
goto exit;
if(pCurrentThing)
{
if (FAILED(hr = pCurrentThing->get_ID(&lCurrentID)))
goto exit;
// Search for the htreeitem that corresponds these ids
htItem = InTree(m_hRoom, lCurrentID);
// if we found the item, select it and exit
if(htItem)
{
// TODO - Make sure this doesn send a TVN_SELCHANGED notification!!!!
// It does, so we have to regulate it with a bool
m_bSelectedByMe = FALSE;
m_treeCtrl.SelectItem(htItem);
}
}
exit:
SAFERELEASE(pCurrentThing);
}
示例4: ExecCommand
//OLECMDID_PRINT = 6,
HRESULT CWtlHtmlView::ExecCommand( OLECMDID nCmdID, OLECMDEXECOPT nCmdExecOpt, VARIANTARG* pvarargIn, VARIANTARG* pvarargOut)
{
HRESULT hr=S_OK;
LPDISPATCH lpDispatch = NULL;
LPOLECOMMANDTARGET lpOleCommandTarget = NULL;
try {
m_spWebBrowser2->get_Document(&lpDispatch);
if(lpDispatch==NULL)
throw;
OLECMDF eQuery ; // 'return value type for QueryStatusWB
if(FAILED( m_spWebBrowser2->QueryStatusWB(OLECMDID_PRINT, &eQuery))) // 'get print command status
throw;
if(!( eQuery & OLECMDF_ENABLED) )
throw;
lpDispatch->QueryInterface(IID_IOleCommandTarget, (void**)&lpOleCommandTarget);
if(lpOleCommandTarget==NULL)
throw;
// Print contents of WebBrowser control.
hr=lpOleCommandTarget->Exec(NULL, nCmdID, nCmdExecOpt, pvarargIn, pvarargOut);
}
catch(...)
{
hr=E_FAIL;
}
if(lpDispatch)
lpDispatch->Release();
if(lpOleCommandTarget)
lpOleCommandTarget->Release();
return hr;
}
示例5: ExecuteScript
VARIANT CWebDlg::ExecuteScript(CString csCode, CString csLanguage)
{
COleVariant varRet;
IHTMLDocument2* pHTMLDocument2;
IHTMLWindow2* pHTMLWindow2;
LPDISPATCH lpDispatch;
lpDispatch = m_explore.GetDocument();
BSTR bstrCode = _bstr_t((const char *)csCode);
BSTR bstrLang = _bstr_t((const char *)csLanguage);
HRESULT hr;
if(lpDispatch)
{
hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (void**)&pHTMLDocument2);
if(hr == S_OK)
{
hr = pHTMLDocument2->get_parentWindow(&pHTMLWindow2);
if(hr == S_OK)
{
pHTMLWindow2->execScript(bstrCode, bstrLang, &varRet);
pHTMLWindow2->Release();
}
pHTMLDocument2->Release();
}
lpDispatch->Release();
}
return varRet;
}
示例6: acedGetIDispatch
void
addCircleThroughCom()
{
AutoCAD::IAcadApplication *pAcad;
AutoCAD::IAcadDocument *pDoc;
AutoCAD::IAcadModelSpace *pMSpace;
HRESULT hr = NOERROR;
LPUNKNOWN pUnk = NULL;
LPDISPATCH pAcadDisp = acedGetIDispatch(TRUE);
if(pAcadDisp==NULL)
return;
hr = pAcadDisp->QueryInterface(AutoCAD::IID_IAcadApplication,(void**)&pAcad);
pAcadDisp->Release();
if (FAILED(hr))
return;
hr = pAcad->get_ActiveDocument(&pDoc);
pAcad->Release();
if (FAILED(hr))
return;
hr = pDoc->get_ModelSpace(&pMSpace);
pDoc->Release();
if (FAILED(hr))
return;
SAFEARRAYBOUND rgsaBound;
rgsaBound.lLbound = 0L;
rgsaBound.cElements = 3;
long i;
SAFEARRAY* pStartPoint = NULL;
pStartPoint = SafeArrayCreate(VT_R8, 1, &rgsaBound);
i = 0;
double value = 4.0;
SafeArrayPutElement(pStartPoint, &i, &value);
i = 1;
value = 2.0;
SafeArrayPutElement(pStartPoint, &i, &value);
i = 2;
value = 0.0;
SafeArrayPutElement(pStartPoint, &i, &value);
VARIANT pt1;
pt1.vt = VT_ARRAY | VT_R8;
pt1.parray = pStartPoint;
AutoCAD::IAcadCircle *pCircle;
pMSpace->AddCircle(pt1, 2.0, &pCircle);
VariantClear(&pt1);
pMSpace->Release();
}
示例7: getAcadMenuGroup
bool getAcadMenuGroup(IAcadMenuGroup **pVal)
{
IAcadApplication *acadApp = NULL;
LPDISPATCH pDisp = NULL;
if (!getApplication(&pDisp))
return false;
HRESULT hr = S_OK;
hr = pDisp->QueryInterface(IID_IAcadApplication, (LPVOID*)&acadApp);
if (FAILED(hr))
return false;
LPDISPATCH pTempDisp = NULL;
IAcadMenuGroups *mnuGrps = NULL;
long cnt = 0;
//get the menu groups
hr = acadApp->get_MenuGroups(&mnuGrps);
if (FAILED(hr))
{
acadApp->Release();
return false;
}
mnuGrps->get_Count(&cnt);
//get AutoCAD menu group. say it is index 0.
IAcadMenuGroup *mnuGrp = NULL;
VARIANT vtName;
vtName.vt = VT_I4;
BSTR grpName;
bool found = false ;
for (long i=0; i < cnt; i++)
{
vtName.lVal = i;
hr = mnuGrps->Item(vtName, &mnuGrp);
if (FAILED(hr))
return false;
hr = mnuGrp->get_Name(&grpName);
CString cgrpName(grpName);
if (cgrpName.CompareNoCase("Acad")==0)
{
found = true;
*pVal = mnuGrp;
break;
}
}
acadApp->Release();
return found;
}
示例8: GetAcadApplication
bool ArxToolBar::GetAcadApplication( IAcadApplication*& pAcadApp )
{
LPDISPATCH pDisp = NULL;
if ( !GetAcadApplication( &pDisp ) )
return false;
HRESULT hr = S_OK;
hr = pDisp->QueryInterface( IID_IAcadApplication, ( LPVOID* )&pAcadApp );
if ( FAILED( hr ) )
return false;
return true;
}
示例9: GetContainer
// Get IHTMLDocument2
CComPtr<IHTMLDocument2> FW_HtmlCtrl::GetHTMLDocument2()
{
if(!m_spHTMLDocument2)
{
LPDISPATCH pDisp = GetContainer();
if(pDisp)
{
IHTMLDocument2* pHTMLDocument2 = NULL;
HRESULT hr = pDisp->QueryInterface(__uuidof(IHTMLDocument2), (void**)&pHTMLDocument2);
if(SUCCEEDED(hr))
m_spHTMLDocument2.Attach(pHTMLDocument2);
}
}
return m_spHTMLDocument2;
}
示例10: CreateUser
/* CreateUser() - Function for creating a basic User
Parameters
IDirectoryObject *pDirObject - Parent Directory Object for the new User
LPWSTR pwCommonName - Common Name for the new User
IDirectoryObject ** ppDirObjRet - Pointer to the Pointer which will receive the new User
int iUserType - Bitflags for new User:
ADS_User_TYPE_GLOBAL_User,
ADS_User_TYPE_DOMAIN_LOCAL_User,
ADS_User_TYPE_UNIVERSAL_User,
ADS_User_TYPE_SECURITY_ENABLED
*/
HRESULT CreateUser(IDirectoryObject *pDirObject, LPWSTR pwCommonName,LPWSTR pwSamAcctName,IDirectoryObject ** ppDirObjRet)
{
assert(pDirObject);
if (wcslen(pwSamAcctName) >20)
{
MessageBox(NULL,L"SamAccountName CANNOT be bigger than 20 characters",L"Error: CreateSimpleUser()",MB_ICONSTOP);
assert(0);
return E_FAIL;
}
HRESULT hr;
ADSVALUE sAMValue;
ADSVALUE classValue;
LPDISPATCH pDisp;
WCHAR pwCommonNameFull[1024];
ADS_ATTR_INFO attrInfo[] =
{
{ L"objectClass", ADS_ATTR_UPDATE,
ADSTYPE_CASE_IGNORE_STRING, &classValue, 1 },
{L"sAMAccountName", ADS_ATTR_UPDATE,
ADSTYPE_CASE_IGNORE_STRING, &sAMValue, 1},
};
DWORD dwAttrs = sizeof(attrInfo)/sizeof(ADS_ATTR_INFO);
classValue.dwType = ADSTYPE_CASE_IGNORE_STRING;
classValue.CaseIgnoreString = L"User";
sAMValue.dwType=ADSTYPE_CASE_IGNORE_STRING;
sAMValue.CaseIgnoreString = pwSamAcctName;
wsprintfW(pwCommonNameFull,L"CN=%s",pwCommonName);
hr = pDirObject->CreateDSObject( pwCommonNameFull, attrInfo,
dwAttrs, &pDisp );
if (SUCCEEDED(hr))
{
hr = pDisp->QueryInterface(IID_IDirectoryObject,(void**) ppDirObjRet);
pDisp->Release();
pDisp = NULL;
}
return hr;
}
示例11: SinkEvents
/******************************************************************
* CHandler::SinkEvents()
*
* Sets up the Click event sink and saves a pointer to the
* IConnectionPoint for the button. The sink should be freed before
* the application is released.
*
******************************************************************/
HRESULT CHandler::SinkEvents(LPDISPATCH pObject)
{
HRESULT hr;
// Get server's IConnectionPointContainer interface.
IConnectionPointContainer* pCPC;
hr = pObject->QueryInterface(IID_IConnectionPointContainer, (void **)&pCPC);
if (SUCCEEDED(hr)) {
// Find connection point for events we're interested in.
hr = pCPC->FindConnectionPoint(m_riid, &m_pConnection);
if (SUCCEEDED(hr)) {
hr = m_pConnection->Advise(static_cast<IDispatch*>(this), &m_dwCookie);
}
// Release the IConnectionPointContainer
pCPC->Release();
}
return hr;
}
示例12: SetSelectionList
void CPropMapCtrl::SetSelectionList(LPDISPATCH newValue)
{
IPropertyList *pPropList = NULL;
HRESULT hr = S_OK;
long iCount;
CComBSTR bstrItem;
int iListIndex;
long i;
if (FAILED( hr = newValue->QueryInterface( IID_IPropertyList, (LPVOID*)&pPropList) ) )
goto exit;
if (!pPropList)
goto exit;
if (FAILED(hr = pPropList->get_Count(&iCount)))
goto exit;
m_listCtrl.ClearSelections();
for (i = 0; i < iCount; i++)
{
if (NONSECURITYFAIL(hr = pPropList->get_String(i, &bstrItem.m_str)))
goto exit;
if (SUCCEEDED(hr))
{
// select the item
iListIndex = m_listCtrl.FindItemByName(CString(bstrItem));
if (iListIndex >= 0)
m_listCtrl.SelectItem(iListIndex, 0, FALSE);
}
}
SetModifiedFlag();
// display the last selection
m_listCtrl.ShowItemAndColumn(iListIndex, 0);
exit:
SAFERELEASE(pPropList);
}
示例13: LoadWebOCFromStream
//
// Function: LoadWebOCFromStream
//
// Description: Takes an IWebBrowser pointer and causes the stream to
// be loaded into the contained HTML Document Object.
//
HRESULT LoadWebOCFromStream(IWebBrowser *pWebBrowser, IStream *pStream)
{
HRESULT hr;
LPDISPATCH pHtmlDoc = NULL;
IPersistStreamInit *pPersistStreamInit = NULL;
// Test for valid pointers.
//
if (!pWebBrowser || !pStream)
return E_POINTER;
// Get to the document object's IDispatch pointer.
//
hr = pWebBrowser->get_Document(&pHtmlDoc);
if (hr)
goto CleanUp;
// Query for IPersistStreamInit
//
hr = pHtmlDoc->QueryInterface(IID_IPersistStreamInit,
(void**)&pPersistStreamInit);
if (hr)
goto CleanUp;
// Tell the document we'll be reinitializing it.
//
hr = pPersistStreamInit->InitNew();
if (hr)
goto CleanUp;
// Load the contents of the stream.
//
hr = pPersistStreamInit->Load(pStream);
CleanUp:
if (pHtmlDoc)
pHtmlDoc->Release();
if (pPersistStreamInit)
pPersistStreamInit->Release();
return hr;
}
示例14: OnDocumentComplete
void CChatView::OnDocumentComplete(LPCTSTR lpszURL)
{
// show html on first loading of document
if(m_bMemoryMode)
{
LPDISPATCH lpDispatch;
lpDispatch=GetHtmlDocument();
ASSERT(lpDispatch);
//get html document from IDispatch
HRESULT hr=lpDispatch->QueryInterface(IID_IHTMLDocument2, (void**)&m_pHtmlDoc2);
if( SUCCEEDED(hr))
ShowMemoryHtml();
// get the parent window
m_pHtmlDoc2->get_parentWindow( &m_pParentWindow );
}
CHtmlView::OnDocumentComplete(lpszURL);
}
示例15: Reload
void CGraphConstructionForm::Reload(GraphStudio::RenderParameters *params)
{
CString text;
GenerateHTML(text, params);
LPDISPATCH doc = browser_window.get_Document();
if (doc) {
CComPtr<IHTMLDocument2> html;
doc->QueryInterface(IID_IHTMLDocument2, (void**)&html);
if (html) {
CComBSTR bstrURL;
CComVariant varDummy;
html->open(bstrURL, CComVariant("_self"), varDummy, varDummy, NULL);
// Create a safearray to store the HTML text
SAFEARRAY *pSA = NULL;
SAFEARRAYBOUND saBound = {1, 0};
pSA = SafeArrayCreate(VT_VARIANT, 1, &saBound);
if (pSA) {
// Copy the HTML into the one and only element
VARIANT *pVar;
SafeArrayAccessData(pSA, (void**)&pVar); // Access safearray data
V_BSTR(pVar) = SysAllocString(text);
V_VT(pVar) = VT_BSTR;
SafeArrayUnaccessData(pSA); // Release access
// Write the HTML as the document's new text
html->write(pSA); // Overwrite HTML
SafeArrayDestroy(pSA); // Finished with the safearray
}
html->close();
}
doc->Release();
}
}