// @pymethod |PyIPersistPropertyBag|Load|Called by the container to load the control's properties. PyObject *PyIPersistPropertyBag::Load(PyObject *self, PyObject *args) { PyObject *obBag; // @pyparm <o PyIPropertyBag>|bag||the caller's property bag. PyObject *obLog = NULL; // @pyparm <o PyIErrorLog>|log|None|the caller's error log, or None if ( !PyArg_ParseTuple(args, "O|O:Load", &obBag, &obLog) ) return NULL; IPersistPropertyBag *pIPPB = GetI(self); if ( pIPPB == NULL ) return NULL; IPropertyBag *pIPB; if ( !PyCom_InterfaceFromPyObject(obBag, IID_IPropertyBag, (LPVOID*)&pIPB, FALSE) ) return NULL; IErrorLog *pIEL = NULL; if ( obLog != NULL && obLog != Py_None && !PyCom_InterfaceFromPyObject(obLog, IID_IErrorLog, (LPVOID*)&pIEL, FALSE) ) { pIPB->Release(); return NULL; } PY_INTERFACE_PRECALL; HRESULT hr = pIPPB->Load(pIPB, pIEL); pIPB->Release(); pIEL->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPPB, IID_IPersistPropertyBag); Py_INCREF(Py_None); return Py_None; }
bool CTSProcessor::LoadProperties(IPropertyBag *pPropBag) { IPersistPropertyBag *pPersistPropBag; if (FAILED(m_pTSProcessor->QueryInterface(IID_PPV_ARGS(&pPersistPropBag)))) return false; HRESULT hr = pPersistPropBag->Load(pPropBag, nullptr); pPersistPropBag->Release(); return SUCCEEDED(hr); }
HRESULT CXcpControlHost::ActivateXcpControl(IUnknown* pUnKnown) { if (pUnKnown == NULL) { return S_OK; } m_spUnknown = pUnKnown; HRESULT hr = S_OK; pUnKnown->QueryInterface(__uuidof(IOleObject), (void**)&m_spOleObject); if (m_spOleObject) { //m_spOleObject->GetMiscStatus(DVASPECT_CONTENT, &m_dwMiscStatus); OleRegGetMiscStatus( __uuidof(m_spOleObject), DVASPECT_CONTENT, &m_dwMiscStatus ); if (m_dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST) { //CComQIPtr<IOleClientSite> spClientSite(GetControllingUnknown()); IOleClientSite *spClientSite = NULL; ((ATL::CAxHostWindow *)this)->QueryInterface( __uuidof(IOleClientSite), (void **)&spClientSite ); if( NULL != spClientSite ) { m_spOleObject->SetClientSite(spClientSite); spClientSite->Release(); } } //CComQIPtr<IPersistPropertyBag> pPersist(m_spOleObject); IPersistPropertyBag *pPersist = NULL; m_spOleObject->QueryInterface( __uuidof(IPersistPropertyBag), (void **)&pPersist ); if ( NULL != pPersist ) { IPropertyBag* pPropBag = (IPropertyBag*)new CXcpPropertyBag(); pPropBag->AddRef(); pPersist->Load((IPropertyBag*)pPropBag, NULL); pPropBag->Release(); } 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; }