本文整理汇总了C++中IDispatchPtr::Detach方法的典型用法代码示例。如果您正苦于以下问题:C++ IDispatchPtr::Detach方法的具体用法?C++ IDispatchPtr::Detach怎么用?C++ IDispatchPtr::Detach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDispatchPtr
的用法示例。
在下文中一共展示了IDispatchPtr::Detach方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetActiveObject
HRESULT CMObject::GetActiveObject(const CLSID clsid)
{
HRESULT hr;
IDispatchPtr tmpobj;
Release();
hr=tmpobj.GetActiveObject(clsid);
if(SUCCEEDED(hr))
p=tmpobj.Detach();
return hr;
}
示例2: CreateObject
HRESULT CMObject::CreateObject(const CLSID clsid)
{
HRESULT hr;
IDispatchPtr tmpobj;
Release();
hr=tmpobj.CreateInstance(clsid);
if (SUCCEEDED(hr))
p=tmpobj.Detach();
return hr;
}
示例3: GetApplicationSettings
HRESULT STDMETHODCALLTYPE BrowserEvents2::Invoke(
/* [in] */ DISPID dispId,
/* [in] */ REFIID riid,
/* [in] */ LCID lcid,
/* [in] */ WORD wFlags,
/* [out][in] */ DISPPARAMS *pDispParams,
/* [out] */ VARIANT *pVarResult,
/* [out] */ EXCEPINFO *pExcepInfo,
/* [out] */ UINT *puArgErr) {
// When returning a result, you must check whether pVarResult
// is not NULL and initialize it using VariantInit(). If it's
// NULL then it doesn't expect a result.
if (riid != IID_NULL)
return DISP_E_UNKNOWNINTERFACE;
pExcepInfo = 0;
puArgErr = 0;
HRESULT hr;
json_value* settings = GetApplicationSettings();
if (dispId == DISPID_NEWWINDOW3) {
/* When calling window.open() you get an error "Class
not registered". Before this error appears
DWebBrowserEvents2::NewWindow3 event is dispatched,
you need to create the popup window in this event
and assign the dispatch interface of the new popup
browser to the first parameter of NewWindow3. */
LOG_DEBUG << "BrowserEvents2::NewWindow3()";
if (pDispParams->cArgs != 5) {
LOG_WARNING << "BrowserEvents2::NewWindow3() failed: "
"Expected 5 arguments";
_ASSERT(false);
return DISP_E_BADPARAMCOUNT;
}
// ppDisp
_ASSERT(pDispParams->rgvarg[4].vt == (VT_DISPATCH | VT_BYREF));
// Cancel
_ASSERT(pDispParams->rgvarg[3].vt == (VT_BOOL | VT_BYREF));
// dwFlags
_ASSERT(pDispParams->rgvarg[2].vt == VT_I4);
// bstrUrlContext
_ASSERT(pDispParams->rgvarg[1].vt == VT_BSTR);
// bstrUrl
_ASSERT(pDispParams->rgvarg[0].vt == VT_BSTR);
HWND popupHandle = CreatePopupWindow(
browserWindow_->GetWindowHandle());
_ASSERT(popupHandle);
BrowserWindow* browserWindow = GetBrowserWindow(popupHandle);
if (!browserWindow) {
LOG_WARNING << "BrowserEvents2::NewWindow3() failed: "
"CreatePopupWindow() failed";
// Cancel parameter. Current navigation should be cancelled.
*pDispParams->rgvarg[3].pboolVal = VARIANT_TRUE;
return S_OK;
}
const IWebBrowser2Ptr webBrowser2 = browserWindow->GetWebBrowser2();
IDispatchPtr dispatch;
hr = webBrowser2->get_Application(&dispatch);
if (FAILED(hr) || !dispatch) {
LOG_WARNING << "BrowserEvents2::NewWindow3() failed: "
"webBrowser2->get_Application() failed";
return S_OK;
}
*pDispParams->rgvarg[4].ppdispVal = dispatch.Detach();
*pDispParams->rgvarg[3].pboolVal = VARIANT_FALSE;
// Following events (DWebBrowserEvents2) will appear
// after popup creation, they inform about "features"
// passed to "window.open", such as width, height and others:
// DISPID_ONTOOLBAR
// DISPID_ONADDRESSBAR
// DISPID_WINDOWSETRESIZABLE
// DISPID_ONMENUBAR
// DISPID_ONSTATUSBAR
// DISPID_ONFULLSCREEN
// DISPID_CLIENTTOHOSTWINDOW
// DISPID_WINDOWSETWIDTH
// DISPID_WINDOWSETHEIGHT
// DISPID_WINDOWSETTOP
// DISPID_WINDOWSETLEFT
// DISPID_NAVIGATECOMPLETE2
return S_OK;
} else if (dispId == DISPID_WINDOWSETWIDTH) {
_ASSERT(pDispParams->cArgs == 1);
_ASSERT(pDispParams->rgvarg[0].vt == VT_I4); // nWidth
long width = pDispParams->rgvarg[0].lVal;
// LOG_DEBUG << "BrowserEvents2::WindowSetWidth(): width = "
// << width;
browserWindow_->SetWidth(width);
} else if (dispId == DISPID_WINDOWSETHEIGHT) {
_ASSERT(pDispParams->cArgs == 1);
_ASSERT(pDispParams->rgvarg[0].vt == VT_I4); // nHeight
long height = pDispParams->rgvarg[0].lVal;
// LOG_DEBUG << "BrowserEvents2::WindowSetHeight(): height = "
// << height;
browserWindow_->SetHeight(height);
} else if (dispId == DISPID_WINDOWSETTOP) {
_ASSERT(pDispParams->cArgs == 1);
//.........这里部分代码省略.........