当前位置: 首页>>代码示例>>C++>>正文


C++ IObjectWithSite::SetSite方法代码示例

本文整理汇总了C++中IObjectWithSite::SetSite方法的典型用法代码示例。如果您正苦于以下问题:C++ IObjectWithSite::SetSite方法的具体用法?C++ IObjectWithSite::SetSite怎么用?C++ IObjectWithSite::SetSite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IObjectWithSite的用法示例。


在下文中一共展示了IObjectWithSite::SetSite方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DelayedControlCreation

bool CActiveXUI::DelayedControlCreation()
{
	ReleaseControl();
	// At this point we'll create the ActiveX control
	m_bCreated = true;
	IOleControl* pOleControl = NULL;
	HRESULT 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( (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);
}
开发者ID:kovrov,项目名称:scrap,代码行数:49,代码来源:UIActiveX.cpp

示例2: test_CShellMenu

void test_CShellMenu()
{
    HRESULT hResult;
    IShellMenu* shellMenu;
    IDockingWindow* dockingMenu;
    IShellFolder *shellFolder;
    IObjectWithSite *menuWithSite;
    HWND hwndToolbar;

    HWND hWndParent = CreateWindowExW(0, L"EDIT", L"miau", 0, CW_USEDEFAULT, CW_USEDEFAULT,
        CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);
    CDummyWindow* dummyWindow = new CDummyWindow(hWndParent);

    if (!CreateCShellMenu(&shellMenu, &dockingMenu, &menuWithSite))
    {
        skip("failed to create CShellMenuObject\n");
        delete dummyWindow;
        return;
    }

    hResult = SHGetDesktopFolder(&shellFolder);
    test_S_OK(hResult, "SHGetDesktopFolder failed");

    hResult = shellMenu->Initialize(NULL, 0, ANCESTORDEFAULT, SMINIT_TOPLEVEL|SMINIT_VERTICAL);
    test_S_OK(hResult, "Initialize failed");

    hResult = shellMenu->SetShellFolder(shellFolder, NULL, NULL, 0);
    test_S_OK(hResult, "SetShellFolder failed");

    hResult = menuWithSite->SetSite(dummyWindow);
    test_S_OK(hResult, "SetSite failed");

    hResult = dockingMenu->GetWindow(&hwndToolbar);
    test_S_OK(hResult, "GetWindow failed");
    ok(hwndToolbar != NULL, "GetWindow should return a window\n");

    HWND hwndRealParent = GetParent(hwndToolbar);
    ok(GetParent(hwndRealParent) == hWndParent, "Wrong parent\n");
    ok(CheckWindowClass(hwndToolbar, L"ToolbarWindow32"), "Wrong class\n");
    ok(CheckWindowClass(hwndRealParent, L"SysPager"), "Wrong class\n");

    menuWithSite->Release();
    dockingMenu->Release();
    shellMenu->Release();
    ok(!IsWindow(hwndToolbar), "The toolbar window should not exist\n");

    DestroyWindow(hWndParent);
}
开发者ID:Moteesh,项目名称:reactos,代码行数:48,代码来源:menu.cpp

示例3: ReleaseControl

void CActiveXUI::ReleaseControl()
{
    m_hwndHost = NULL;
    if( m_pUnk != NULL ) {
        IObjectWithSite* pSite = NULL;
        m_pUnk->QueryInterface(IID_IObjectWithSite, (LPVOID*) &pSite);
        if( pSite != NULL ) {
            pSite->SetSite(NULL);
            pSite->Release();
        }
        m_pUnk->Close(OLECLOSE_NOSAVE);
        m_pUnk->SetClientSite(NULL);
        m_pUnk->Release(); 
        m_pUnk = NULL;
    }
    if( m_pControl != NULL ) {
        m_pControl->m_pOwner = NULL;
        m_pControl->Release();
        m_pControl = NULL;
    }
    m_pManager->RemoveMessageFilter(this);
}
开发者ID:YaoXuanZhi,项目名称:ThirdParty_SDK,代码行数:22,代码来源:UIActiveX.cpp

示例4: DoCreateControl

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, _T("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);
}
开发者ID:YaoXuanZhi,项目名称:ThirdParty_SDK,代码行数:66,代码来源:UIActiveX.cpp

示例5: CreateControl

bool AxContainer::CreateControl( const std::string &strModule, REFCLSID rclsid )
{
	IOleControl* pOleControl = NULL;

	HRESULT hr = -1;
	if( !strModule.empty() ) 
	{
		HMODULE hModule = ::LoadLibrary((LPCTSTR)strModule.c_str());
		if( hModule != NULL ) 
		{
			IClassFactory* aClassFactory = NULL;
			DllGetClassObjectFunc aDllGetClassObjectFunc = (DllGetClassObjectFunc)::GetProcAddress(hModule, "DllGetClassObject");
			hr = aDllGetClassObjectFunc(rclsid, IID_IClassFactory, (LPVOID*)&aClassFactory);
			if( SUCCEEDED(hr) ) 
			{
				hr = aClassFactory->CreateInstance(NULL, IID_IOleObject, (LPVOID*)&pOleControl);
			}
			aClassFactory->Release();
		}
	}
	if( FAILED(hr) ) 
		hr = ::CoCreateInstance(rclsid, NULL, CLSCTX_ALL, IID_IOleControl, (LPVOID*)&pOleControl);

	if( FAILED(hr) ) 
		return false;
	pOleControl->QueryInterface(IID_IOleObject, (LPVOID*) &m_pOleObject);
	pOleControl->Release();
	if( m_pOleObject == NULL ) 
		return false;

	hr = m_pOleObject->QueryInterface(IID_IOleInPlaceObjectWindowless, (LPVOID*) &m_pInPlaceObject);

	// More control creation stuff
	DWORD dwMiscStatus = 0;
	m_pOleObject->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus);
	// Initialize control
	if( (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST) != 0 ) 
		m_pOleObject->SetClientSite(this);
	IPersistStreamInit* pPersistStreamInit = NULL;
	m_pOleObject->QueryInterface(IID_IPersistStreamInit, (LPVOID*) &pPersistStreamInit);
	if( pPersistStreamInit != NULL )
	{
		hr = pPersistStreamInit->InitNew();
		pPersistStreamInit->Release();
	}
	if( FAILED(hr) ) 
		return false;
	if( (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST) == 0 ) 
		m_pOleObject->SetClientSite(this);
	// Grab the view...
	hr = m_pOleObject->QueryInterface(IID_IViewObjectEx, (LPVOID*) &m_pViewObject);
	if( FAILED(hr) ) 
		hr = m_pOleObject->QueryInterface(IID_IViewObject2, (LPVOID*) &m_pViewObject);
	if( FAILED(hr) ) 
		hr = m_pOleObject->QueryInterface(IID_IViewObject, (LPVOID*) &m_pViewObject);

	// Activate and done...
	m_pOleObject->SetHostNames(OLESTR("UIActiveX"), NULL);
	if( (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME) == 0 ) 
		DoVerb(OLEIVERB_INPLACEACTIVATE);

	IObjectWithSite* pSite = NULL;
	m_pOleObject->QueryInterface(IID_IObjectWithSite, (LPVOID*) &pSite);
	if( pSite != NULL ) 
	{
		pSite->SetSite(static_cast<IOleWindow*>(this));
		pSite->Release();
	}

	return SUCCEEDED(hr);
}
开发者ID:fgokey,项目名称:WidgetUI,代码行数:71,代码来源:AxWidget.cpp

示例6: if

/* 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)
	{
		return;
	}

	BOOL bRet = LoadContextMenuHandlers(pszRegContext,m_ContextMenuHandlers);

	if(!bRet)
	{
		return;
	}

	/* 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_PPV_ARGS(&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_PPV_ARGS(&pObjectSite));

				if(SUCCEEDED(hr))
				{
					pObjectSite->SetSite(pUnkSite);
					pObjectSite->Release();
				}
			}

			hr = pUnknown->QueryInterface(IID_PPV_ARGS(&pContextMenu3));
			MenuHandler.pContextMenuActual = pContextMenu3;

			if(FAILED(hr) || pContextMenu3 == NULL)
			{
				hr = pUnknown->QueryInterface(IID_PPV_ARGS(&pContextMenu2));
				MenuHandler.pContextMenuActual = pContextMenu2;

				if(FAILED(hr) || pContextMenu2 == NULL)
				{
					hr = pUnknown->QueryInterface(IID_PPV_ARGS(&pContextMenu));
					MenuHandler.pContextMenuActual = pContextMenu;
				}
			}

			MenuHandler.pContextMenu = pContextMenu;
			MenuHandler.pContextMenu2 = pContextMenu2;
			MenuHandler.pContextMenu3 = pContextMenu3;

			MenuHandler.uStartID = 0;
//.........这里部分代码省略.........
开发者ID:hollylee,项目名称:explorerplusplus,代码行数:101,代码来源:ContextMenuManager.cpp

示例7: ActivateXcpControl


//.........这里部分代码省略.........
        }

        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;
}
开发者ID:WolfieWerewolf,项目名称:loag,代码行数:101,代码来源:XcpControlHost.cpp


注:本文中的IObjectWithSite::SetSite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。