本文整理汇总了C++中IObjectWithSite类的典型用法代码示例。如果您正苦于以下问题:C++ IObjectWithSite类的具体用法?C++ IObjectWithSite怎么用?C++ IObjectWithSite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IObjectWithSite类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extension
/* The following steps are taken when showing shell
extensions on an existing menu:
1. Load shell extensions.
2. Build and show menu.
3. Pass selection to shell extension (if necessary).
4. Release shell extensions (also free the DLL's they reside in). */
CContextMenuManager::CContextMenuManager(ContextMenuType_t ContextMenuType,
LPCITEMIDLIST pidlDirectory,IDataObject *pDataObject,IUnknown *pUnkSite)
{
ItemType_t ItemType = GetItemType(pidlDirectory);
const TCHAR *pszRegContext = NULL;
switch(ItemType)
{
case ITEM_TYPE_FOLDER:
if(ContextMenuType == CONTEXT_MENU_TYPE_DRAG_AND_DROP)
{
pszRegContext = CMH_FOLDER_DRAG_AND_DROP;
}
break;
case ITEM_TYPE_DIRECTORY:
if(ContextMenuType == CONTEXT_MENU_TYPE_BACKGROUND)
{
pszRegContext = CMH_DIRECTORY_BACKGROUND;
}
else if(ContextMenuType == CONTEXT_MENU_TYPE_DRAG_AND_DROP)
{
pszRegContext = CMH_DIRECTORY_DRAG_AND_DROP;
}
break;
}
if(pszRegContext != NULL)
{
LoadContextMenuHandlers(pszRegContext,&m_ContextMenuHandlers);
/* Initialize the shell extensions, and extract
an IContextMenu interface. */
for each(auto ContextMenuHandler in m_ContextMenuHandlers)
{
IShellExtInit *pShellExtInit = NULL;
HRESULT hr;
IUnknown *pUnknown = ContextMenuHandler.pUnknown;
hr = pUnknown->QueryInterface(IID_IShellExtInit,
reinterpret_cast<void **>(&pShellExtInit));
if(SUCCEEDED(hr))
{
MenuHandler_t MenuHandler;
IContextMenu *pContextMenu = NULL;
IContextMenu2 *pContextMenu2 = NULL;
IContextMenu3 *pContextMenu3 = NULL;
pShellExtInit->Initialize(pidlDirectory,pDataObject,NULL);
pShellExtInit->Release();
if(pUnkSite != NULL)
{
IObjectWithSite *pObjectSite = NULL;
hr = pUnknown->QueryInterface(IID_IObjectWithSite,reinterpret_cast<void **>(&pObjectSite));
if(SUCCEEDED(hr))
{
pObjectSite->SetSite(pUnkSite);
pObjectSite->Release();
}
}
hr = pUnknown->QueryInterface(IID_IContextMenu3,
reinterpret_cast<void **>(&pContextMenu3));
MenuHandler.pContextMenuActual = pContextMenu3;
if(FAILED(hr) || pContextMenu3 == NULL)
{
hr = pUnknown->QueryInterface(IID_IContextMenu2,
reinterpret_cast<void **>(&pContextMenu2));
MenuHandler.pContextMenuActual = pContextMenu2;
if(FAILED(hr) || pContextMenu2 == NULL)
{
hr = pUnknown->QueryInterface(IID_IContextMenu,
reinterpret_cast<void **>(&pContextMenu));
MenuHandler.pContextMenuActual = pContextMenu;
}
}
MenuHandler.pContextMenu = pContextMenu;
MenuHandler.pContextMenu2 = pContextMenu2;
MenuHandler.pContextMenu3 = pContextMenu3;
MenuHandler.uStartID = 0;
MenuHandler.uEndID = 0;
m_MenuHandlers.push_back(MenuHandler);
}
//.........这里部分代码省略.........
示例2: ReleaseControl
bool CActiveXUI::DoCreateControl()
{
ReleaseControl();
// At this point we'll create the ActiveX control
m_bCreated = true;
IOleControl* pOleControl = NULL;
HRESULT Hr = -1;
if( !m_sModuleName.IsEmpty() ) {
HMODULE hModule = ::LoadLibrary((LPCTSTR)m_sModuleName);
if( hModule != NULL ) {
IClassFactory* aClassFactory = NULL;
DllGetClassObjectFunc aDllGetClassObjectFunc = (DllGetClassObjectFunc)::GetProcAddress(hModule, "DllGetClassObject");
Hr = aDllGetClassObjectFunc(m_clsid, IID_IClassFactory, (LPVOID*)&aClassFactory);
if( SUCCEEDED(Hr) ) {
Hr = aClassFactory->CreateInstance(NULL, IID_IOleObject, (LPVOID*)&pOleControl);
}
aClassFactory->Release();
}
}
if( FAILED(Hr) ) {
Hr = ::CoCreateInstance(m_clsid, NULL, CLSCTX_ALL, IID_IOleControl, (LPVOID*)&pOleControl);
}
ASSERT(SUCCEEDED(Hr));
if( FAILED(Hr) ) return false;
pOleControl->QueryInterface(IID_IOleObject, (LPVOID*) &m_pUnk);
pOleControl->Release();
if( m_pUnk == NULL ) return false;
// Create the host too
m_pControl = new CActiveXCtrl();
m_pControl->m_pOwner = this;
// More control creation stuff
DWORD dwMiscStatus = 0;
m_pUnk->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus);
IOleClientSite* pOleClientSite = NULL;
m_pControl->QueryInterface(IID_IOleClientSite, (LPVOID*) &pOleClientSite);
CSafeRelease<IOleClientSite> RefOleClientSite = pOleClientSite;
// Initialize control
if( (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST) != 0 ) m_pUnk->SetClientSite(pOleClientSite);
IPersistStreamInit* pPersistStreamInit = NULL;
m_pUnk->QueryInterface(IID_IPersistStreamInit, (LPVOID*) &pPersistStreamInit);
if( pPersistStreamInit != NULL ) {
Hr = pPersistStreamInit->InitNew();
pPersistStreamInit->Release();
}
if( FAILED(Hr) ) return false;
if( (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST) == 0 ) m_pUnk->SetClientSite(pOleClientSite);
// Grab the view...
Hr = m_pUnk->QueryInterface(IID_IViewObjectEx, (LPVOID*) &m_pControl->m_pViewObject);
if( FAILED(Hr) ) Hr = m_pUnk->QueryInterface(IID_IViewObject2, (LPVOID*) &m_pControl->m_pViewObject);
if( FAILED(Hr) ) Hr = m_pUnk->QueryInterface(IID_IViewObject, (LPVOID*) &m_pControl->m_pViewObject);
// Activate and done...
m_pUnk->SetHostNames(OLESTR("UIActiveX"), NULL);
if( m_pManager != NULL ) m_pManager->SendNotify((CControlUI*)this, DUI_MSGTYPE_SHOWACTIVEX, 0, 0, false);
if( (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME) == 0 ) {
Hr = m_pUnk->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, pOleClientSite, 0, m_pManager->GetPaintWindow(), &m_rcItem);
//::RedrawWindow(m_pManager->GetPaintWindow(), &m_rcItem, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_INTERNALPAINT | RDW_FRAME);
}
IObjectWithSite* pSite = NULL;
m_pUnk->QueryInterface(IID_IObjectWithSite, (LPVOID*) &pSite);
if( pSite != NULL ) {
pSite->SetSite(static_cast<IOleClientSite*>(m_pControl));
pSite->Release();
}
return SUCCEEDED(Hr);
}
示例3: OleRegGetMiscStatus
//.........这里部分代码省略.........
}
if (0 == (m_dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST))
{
//CComQIPtr<IOleClientSite> spClientSite(GetControllingUnknown());
IOleClientSite *spClientSite = NULL;
((ATL::CAxHostWindow *)this)->QueryInterface( __uuidof(IOleClientSite), (void **)&spClientSite);
//GetControllingUnknown()->QueryInterface( __uuidof(IOleClientSite), (void **)&spClientSite );
if( NULL != spClientSite )
{
m_spOleObject->SetClientSite(spClientSite);
spClientSite->Release();
}
}
m_dwViewObjectType = 0;
hr = m_spOleObject->QueryInterface(__uuidof(IViewObjectEx), (void**) &m_spViewObject);
if (FAILED(hr))
{
hr = m_spOleObject->QueryInterface(__uuidof(IViewObject2), (void**) &m_spViewObject);
if (SUCCEEDED(hr))
{
m_dwViewObjectType = 3;
}
}
else
{
m_dwViewObjectType = 7;
}
if (FAILED(hr))
{
hr = m_spOleObject->QueryInterface(__uuidof(IViewObject), (void**) &m_spViewObject);
if (SUCCEEDED(hr))
{
m_dwViewObjectType = 1;
}
}
//CComQIPtr<IAdviseSink> spAdviseSink(GetControllingUnknown());
IAdviseSink *spAdviseSink = NULL;
//GetControllingUnknown()->QueryInterface( __uuidof(IAdviseSink), (void **)&spAdviseSink );
((ATL::CAxHostWindow *)this)->QueryInterface( __uuidof(IAdviseSink), (void **)&spAdviseSink );
if( NULL != spAdviseSink )
{
m_spOleObject->Advise(spAdviseSink, &m_dwOleObject);
if (m_spViewObject)
{
m_spViewObject->SetAdvise(DVASPECT_CONTENT, 0, spAdviseSink);
}
spAdviseSink->Release();
}
m_spOleObject->SetHostNames(OLESTR("AXWIN"), NULL);
if ((m_dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME) == 0)
{
m_spOleObject->GetExtent( DVASPECT_CONTENT, &m_hmSize );
m_pxSize.cx = m_rcPos.right - m_rcPos.left;
m_pxSize.cy = m_rcPos.bottom - m_rcPos.top;
AtlPixelToHiMetric(&m_pxSize, &m_hmSize);
m_spOleObject->SetExtent(DVASPECT_CONTENT, &m_hmSize);
m_spOleObject->GetExtent(DVASPECT_CONTENT, &m_hmSize);
AtlHiMetricToPixel(&m_hmSize, &m_pxSize);
m_rcPos.right = m_rcPos.left + m_pxSize.cx ;
m_rcPos.bottom = m_rcPos.top + m_pxSize.cy ;
//CComQIPtr<IOleClientSite> spClientSite(GetControllingUnknown());
IOleClientSite *spClientSite = NULL;
//GetControllingUnknown()->QueryInterface( __uuidof(IOleClientSite), (void **)&spClientSite );
((ATL::CAxHostWindow *)this)->QueryInterface( __uuidof(IOleClientSite), (void **)&spClientSite );
if( NULL != spClientSite )
{
m_rcPos.left = m_rcPos.top = 0;
m_rcPos.right = m_hmSize.cx;
m_rcPos.bottom = m_hmSize.cy;
hr = m_spOleObject->DoVerb( OLEIVERB_INPLACEACTIVATE, NULL, spClientSite, 0, m_hWnd, &m_rcPos );
::RedrawWindow( m_hWnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_INTERNALPAINT | RDW_FRAME );
spClientSite->Release();
}
}
if( NULL != pPersist )
{
pPersist->Release();
}
}
//CComPtr<IObjectWithSite> spSite;
IObjectWithSite *spSite = NULL;
pUnKnown->QueryInterface(__uuidof(IObjectWithSite), (void**)&spSite);
if ( NULL != spSite )
{
// spSite->SetSite(GetControllingUnknown());
IUnknown *iUnknown = NULL;
((ATL::CAxHostWindow *)this)->QueryInterface( __uuidof(IUnknown), (void **)&iUnknown );
spSite->SetSite( iUnknown );
spSite->Release();
}
return hr;
}