本文整理汇总了C++中CComQIPtr::GetDispID方法的典型用法代码示例。如果您正苦于以下问题:C++ CComQIPtr::GetDispID方法的具体用法?C++ CComQIPtr::GetDispID怎么用?C++ CComQIPtr::GetDispID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComQIPtr
的用法示例。
在下文中一共展示了CComQIPtr::GetDispID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NavigateComplete
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
void CBrowserEvents::NavigateComplete(CComPtr<IWebBrowser2> browser, CString & szUrl)
{
#ifndef PAGETEST_EXE
if( active && browser && webpagetestDom )
{
CComPtr<IDispatch> spDoc;
if( SUCCEEDED(browser->get_Document(&spDoc)) && spDoc )
{
CComQIPtr<IHTMLDocument2> doc = spDoc;
CComPtr<IHTMLWindow2> spWindow;
if( doc && SUCCEEDED(doc->get_parentWindow(&spWindow)) && spWindow )
{
CComQIPtr<IDispatchEx> spWndEx = spWindow;
if( spWndEx )
{
DISPID dispid;
if( SUCCEEDED(spWndEx->GetDispID(L"webpagetest", fdexNameEnsure, &dispid) ) )
{
IDispatch * ptr;
if( SUCCEEDED(webpagetestDom->QueryInterface(IID_IDispatch, (void**)&ptr)) && ptr )
{
VARIANT dispatch;
dispatch.vt = VT_DISPATCH;
dispatch.pdispVal = ptr;
DISPPARAMS disp;
disp.rgvarg = &dispatch;
disp.cArgs = 1;
disp.cNamedArgs = 0;
disp.rgdispidNamedArgs = NULL;
HRESULT hr = spWndEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &disp, NULL, NULL, NULL);
if( SUCCEEDED(hr) )
{
ATLTRACE(_T("[Pagetest] - Attached webpagetest object to the window"));
}
}
}
}
}
}
}
#endif
}
示例2: var
void
CFrameTable::SetFrameId(CComPtr<IHTMLDocument2> document, TFrameId frameId, bool bImportant)
{
// retrieve document's window object
CComPtr<IHTMLWindow2> window;
CHECK_COM(document->get_parentWindow(&window), _T("Cannot retrieve parent window"));
if (!window)
{
TRACE_E(_T("Cannot retrieve parent window for document"));
ATLASSERT(0);
return;
}
// cast window object to IDispatchEx
CComQIPtr<IDispatchEx> windowDispEx = window;
if (!windowDispEx)
{
TRACE_E(_T("Cannot retrieve IDispatchEx on parent window of document"));
ATLASSERT(0);
return;
}
// add FrameId property to window object
DISPID dispid;
DISPPARAMS dispparams;
HRESULT hr = windowDispEx->GetDispID(CComBSTR(JAVASCRIPT_FRAMEID_VARIABLE), fdexNameEnsure|fdexNameCaseSensitive, &dispid);
if (!bImportant && hr==E_ACCESSDENIED) return;
CHECK_COM(hr, FS(_T("GetDispID for window.%s has failed"), JAVASCRIPT_FRAMEID_VARIABLE));
DISPID putid = DISPATCH_PROPERTYPUT;
CComVariant var(frameId);
dispparams.rgvarg = &var;
dispparams.rgdispidNamedArgs = &putid;
dispparams.cArgs = 1;
dispparams.cNamedArgs = 1;
VARIANT temp;
CHECK_COM(windowDispEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &dispparams, &temp, NULL, NULL), _T("Failed to add property to window object"));
ATLASSERT(GetFrameId(document)==frameId);
DT(TRACE_I(FS(_T("CFrameTable::SetFrameId(doc=%08X, id=%d) OK"), document, frameId)));
}
示例3: FS
TFrameId
CFrameTable::GetFrameId(CComPtr<IHTMLDocument2> document, bool bImportant)
{
// get frame id from window.<JAVASCRIPT_FRAMEID_VARIABLE>
// retrieve document's window object
CComPtr<IHTMLWindow2> window;
CHECK_COM(document->get_parentWindow(&window), _T("Cannot retrieve parent window"));
if (!window)
{
TRACE_E(_T("Cannot retrieve parent window for document"));
ATLASSERT(0);
return NULL_FRAME;
}
// cast window object to IDispatchEx
CComQIPtr<IDispatchEx> windowDispEx = window;
if (!windowDispEx)
{
TRACE_E(_T("Cannot retrieve IDispatchEx on parent window of document"));
ATLASSERT(0);
return NULL_FRAME;
}
// read FrameId property to window object
DISPID dispid;
DISPPARAMS dispparams = { NULL, NULL, 0, 0 };
HRESULT hr = windowDispEx->GetDispID(CComBSTR(JAVASCRIPT_FRAMEID_VARIABLE), fdexNameCaseSensitive, &dispid);
if (hr==DISP_E_UNKNOWNNAME) return NULL_FRAME;
if (!bImportant && hr==E_ACCESSDENIED) return NULL_FRAME;
CHECK_COM(hr, FS(_T("GetDispID for window.%s has failed"), JAVASCRIPT_FRAMEID_VARIABLE));
CComVariant res;
CHECK_COM(windowDispEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &dispparams, &res, NULL, NULL), _T("Failed to read property from window object"));
ATLASSERT(res.vt==VT_UI4);
return res.ulVal;
}