本文整理汇总了C++中IOleClientSite类的典型用法代码示例。如果您正苦于以下问题:C++ IOleClientSite类的具体用法?C++ IOleClientSite怎么用?C++ IOleClientSite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IOleClientSite类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetI
// @pymethod |PyIOleObject|SetClientSite|Description of SetClientSite.
PyObject *PyIOleObject::SetClientSite(PyObject *self, PyObject *args)
{
IOleObject *pIOO = GetI(self);
if ( pIOO == NULL )
return NULL;
// @pyparm <o PyIOleClientSite>|pClientSite||Description for pClientSite
PyObject *obpClientSite;
IOleClientSite * pClientSite;
if ( !PyArg_ParseTuple(args, "O:SetClientSite", &obpClientSite) )
return NULL;
BOOL bPythonIsHappy = TRUE;
if (!PyCom_InterfaceFromPyInstanceOrObject(obpClientSite, IID_IOleClientSite, (void **)&pClientSite, TRUE /* bNoneOK */))
bPythonIsHappy = FALSE;
if (!bPythonIsHappy) return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIOO->SetClientSite( pClientSite );
if (pClientSite) pClientSite->Release();
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return OleSetOleError(hr);
Py_INCREF(Py_None);
return Py_None;
}
示例2: GetI
// @pymethod |PyIOleClientSite|GetMoniker|Description of GetMoniker.
PyObject *PyIOleClientSite::GetMoniker(PyObject *self, PyObject *args)
{
IOleClientSite *pIOCS = GetI(self);
if ( pIOCS == NULL )
return NULL;
// @pyparm int|dwAssign||Description for dwAssign
// @pyparm int|dwWhichMoniker||Description for dwWhichMoniker
DWORD dwAssign;
DWORD dwWhichMoniker;
IMoniker * ppmk;
if ( !PyArg_ParseTuple(args, "ii:GetMoniker", &dwAssign, &dwWhichMoniker) )
return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIOCS->GetMoniker( dwAssign, dwWhichMoniker, &ppmk );
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return OleSetOleError(hr);
PyObject *obppmk;
obppmk = PyCom_PyObjectFromIUnknown(ppmk, IID_IMoniker, FALSE);
PyObject *pyretval = Py_BuildValue("O", obppmk);
Py_XDECREF(obppmk);
return pyretval;
}
示例3: nekoIBlockInstance
nekoFlashInstance::nekoFlashInstance(nekoIBlock *block)
: nekoIBlockInstance(block)
, mFlashType(FLASH_MOVIE)
, mCurView(NULL)
, mSkipAbleTime(0)
, mOleObject(0)
, mFlashSite(0)
, flashInterface(0)
{
HMODULE flashLib = GetNekoNovel()->GetFlashLib();
mFlashSite = nekoNew nekoFlashSite;
mFlashSite->Init(this);
if(flashLib)
{
IClassFactory* factory = 0;
GetClassObject getClassFunc = (GetClassObject)GetProcAddress(flashLib, "DllGetClassObject");
HRESULT result = getClassFunc(ShockwaveFlashObjects::CLSID_ShockwaveFlash, IID_IClassFactory, (void**)&factory);
if(SUCCEEDED(result))
{
factory->CreateInstance(NULL, IID_IOleObject, (void**)&mOleObject);
factory->Release();
}
}
// If we still don't have the object, try loading from registry
if(!mOleObject)
{
HRESULT result = CoCreateInstance(ShockwaveFlashObjects::CLSID_ShockwaveFlash, 0, CLSCTX_INPROC_SERVER, IID_IOleObject, (void**)&mOleObject);
if(FAILED(result))
{
LogPrint(LOG_LEVEL_WARN, "플래시 컨트롤을 불러올 수 없습니다.\nFlash.ocx가 설치되어 있지 않을 수 있습니다.");
return;
}
}
IOleClientSite* clientSite = 0;
mFlashSite->QueryInterface(__uuidof(IOleClientSite), (void**)&clientSite);
mOleObject->SetClientSite(clientSite);
clientSite->Release();
mOleObject->QueryInterface(__uuidof(ShockwaveFlashObjects::IShockwaveFlash), (LPVOID*)&flashInterface);
flashInterface->PutWMode("opaque");
mOleObject->DoVerb(OLEIVERB_SHOW, 0, clientSite, 0, 0, 0);
clientSite->Release();
//mOleObject->QueryInterface(__uuidof(IOleInPlaceObjectWindowless), (LPVOID*)windowlessObject.Pptr());
flashInterface->QueryInterface(IID_IViewObject, (void**)&mCurView);
mBufferUsingCount++;
}
示例4: InsertBitmap
// returns true on success, false on failure
//bool InsertBitmap(IRichEditOle* pRichEditOle, HBITMAP hBitmap, HGLOBAL hGlobal)
bool InsertBitmap(IRichEditOle* pRichEditOle, HENHMETAFILE hEmf)
{
SCODE sc;
// Get the image data object
//
static const FORMATETC lc_format[] =
{
{ CF_ENHMETAFILE, 0, DVASPECT_CONTENT, -1, TYMED_ENHMF }//,
// { CF_BITMAP, 0, DVASPECT_CONTENT, -1, TYMED_GDI },
// { CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }
};
STGMEDIUM lc_stgmed[] =
{
{ TYMED_ENHMF, { (HBITMAP)hEmf }, 0 }//,
// { TYMED_GDI, { hBitmap }, 0 },
// { TYMED_HGLOBAL, { (HBITMAP)hGlobal }, 0 }
};
IDataObject *pods;
CreateDataObject(lc_format, lc_stgmed, 1, &pods);
// Get the RichEdit container site
//
IOleClientSite *pOleClientSite;
pRichEditOle->GetClientSite(&pOleClientSite);
// Initialize a Storage Object
//
LPLOCKBYTES lpLockBytes = NULL;
sc = CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
if (sc != S_OK)
{
pOleClientSite->Release();
return false;
}
IStorage *pStorage;
sc = StgCreateDocfileOnILockBytes(lpLockBytes,
STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE, 0, &pStorage);
if (sc != S_OK)
{
lpLockBytes->Release();
pOleClientSite->Release();
return false;
}
// The final ole object which will be inserted in the richedit control
//
IOleObject *pOleObject;
sc = OleCreateStaticFromData(pods, IID_IOleObject, OLERENDER_FORMAT,
(LPFORMATETC)lc_format, pOleClientSite, pStorage, (void **)&pOleObject);
if (sc != S_OK)
{
pStorage->Release();
lpLockBytes->Release();
pOleClientSite->Release();
return false;
}
// all items are "contained" -- this makes our reference to this object
// weak -- which is needed for links to embedding silent update.
OleSetContainedObject(pOleObject, TRUE);
// Now Add the object to the RichEdit
//
REOBJECT reobject = { 0 };
reobject.cbStruct = sizeof(REOBJECT);
reobject.cp = REO_CP_SELECTION;
reobject.dvaspect = DVASPECT_CONTENT;
reobject.poleobj = pOleObject;
reobject.polesite = pOleClientSite;
reobject.pstg = pStorage;
reobject.dwFlags = REO_BELOWBASELINE;
sc = pOleObject->GetUserClassID(&reobject.clsid);
if (sc != S_OK)
{
pOleObject->Release();
pStorage->Release();
lpLockBytes->Release();
pOleClientSite->Release();
return false;
}
// Insert the bitmap at the current location in the richedit control
//
sc = pRichEditOle->InsertObject(&reobject);
// Release all unnecessary interfaces
//
pOleObject->Release();
pStorage->Release();
lpLockBytes->Release();
pOleClientSite->Release();
pods->Release();
//.........这里部分代码省略.........
示例5: HRESULT
//---------------------------------------------------------------------
CFlashDXPlayer::CFlashDXPlayer(HMODULE flashDLL, unsigned int width, unsigned int height)
{
m_userData = NULL;
m_flashInterface = NULL;
m_oleObject = NULL;
m_windowlessObject = NULL;
m_lastMouseX = 0;
m_lastMouseY = 0;
m_lastMouseButtons = 0;
m_dirtyFlag = false;
m_width = width;
m_height = height;
m_controlSite.Init(this);
m_controlSite.AddRef();
m_alphaBlackDC = NULL;
m_alphaBlackBitmap = NULL;
m_alphaBlackBuffer = NULL;
m_alphaWhiteDC = NULL;
m_alphaWhiteBitmap = NULL;
m_alphaWhiteBuffer = NULL;
HRESULT hr;
typedef HRESULT (__stdcall *DllGetClassObjectFunc)(REFCLSID rclsid, REFIID riid, LPVOID * ppv);
if (flashDLL != NULL)
{
IClassFactory* aClassFactory = NULL;
DllGetClassObjectFunc aDllGetClassObjectFunc = (DllGetClassObjectFunc) GetProcAddress(flashDLL, "DllGetClassObject");
hr = aDllGetClassObjectFunc(CLSID_ShockwaveFlash, IID_IClassFactory, (void**)&aClassFactory);
if (FAILED(hr))
return;
aClassFactory->CreateInstance(NULL, IID_IOleObject, (void**)&m_oleObject);
aClassFactory->Release();
}
else
{
hr = CoCreateInstance(CLSID_ShockwaveFlash, NULL, CLSCTX_INPROC_SERVER, IID_IOleObject, (void**)&m_oleObject);
if (FAILED(hr))
return;
}
IOleClientSite* pClientSite = NULL;
hr = m_controlSite.QueryInterface(__uuidof(IOleClientSite), (void**)&pClientSite);
if (FAILED(hr))
return;
hr = m_oleObject->SetClientSite(pClientSite);
if (FAILED(hr))
return;
hr = m_oleObject->QueryInterface(__uuidof(IShockwaveFlash), (void**)&m_flashInterface);
if (FAILED(hr))
return;
m_flashInterface->DisableLocalSecurity();
m_flashInterface->PutEmbedMovie(FALSE);
m_flashInterface->PutAllowScriptAccess(L"always");
SetTransparencyMode(IFlashDXPlayer::TMODE_OPAQUE);
SetQuality(IFlashDXPlayer::QUALITY_HIGH);
hr = m_oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, pClientSite, 0, NULL, NULL);
assert(SUCCEEDED(hr));
pClientSite->Release();
hr = m_oleObject->QueryInterface(__uuidof(IOleInPlaceObjectWindowless), (void**)&m_windowlessObject);
assert(SUCCEEDED(hr));
m_flashSink.Init(this);
m_flashSink.AddRef();
// Resize player
ResizePlayer(width, height);
}
示例6: FlashSite
void FlashControl::createControl(HMODULE _lib)
{
site = new FlashSite();
site->AddRef();
site->Init(this);
// Try to load from user-supplied Flash OCX first
if (_lib)
{
typedef HRESULT (__stdcall *GetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID * ppv);
IClassFactory* factory = 0;
GetClassObject getClassFunc = (GetClassObject)GetProcAddress(_lib, "DllGetClassObject");
HRESULT result = getClassFunc(ShockwaveFlashObjects::CLSID_ShockwaveFlash, IID_IClassFactory, (void**)&factory);
if (SUCCEEDED(result))
{
factory->CreateInstance(NULL, IID_IOleObject, (void**)&oleObject);
factory->Release();
}
}
// If we still don't have the object, try loading from registry
if (!oleObject)
{
HRESULT result = CoCreateInstance(ShockwaveFlashObjects::CLSID_ShockwaveFlash, 0, CLSCTX_INPROC_SERVER, IID_IOleObject, (void**)&oleObject);
if (FAILED(result))
{
MYGUI_EXCEPT("Unable to load the Flash ActiveX control.");
}
}
IOleClientSite* clientSite = 0;
site->QueryInterface(__uuidof(IOleClientSite), (void**)&clientSite);
oleObject->SetClientSite(clientSite);
clientSite->Release();
IOleInPlaceObject* inPlaceObject = 0;
oleObject->QueryInterface(__uuidof(IOleInPlaceObject), (LPVOID*)&inPlaceObject);
if (inPlaceObject)
{
invalidateTotally();
inPlaceObject->SetObjectRects(&dirtyBounds, &dirtyBounds);
inPlaceObject->Release();
}
oleObject->QueryInterface(__uuidof(ShockwaveFlashObjects::IShockwaveFlash), (LPVOID*)&flashInterface);
flashInterface->PutWMode("opaque");
oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, 0, clientSite, 0, 0, 0);
clientSite->Release();
oleObject->QueryInterface(__uuidof(IOleInPlaceObjectWindowless), (LPVOID*)&windowlessObject);
handler = new FlashHandler();
handler->AddRef();
handler->Init(this);
IViewObject* curView = 0;
flashInterface->QueryInterface(IID_IViewObject, (void**)&curView);
}
示例7: getClassFunc
void FlashControl::createControl()
{
site = new Impl::FlashSite();
site->AddRef();
site->Init(this);
HMODULE flashLib = HikariManager::Get().flashLib;
// Try to load from user-supplied Flash OCX first
if(flashLib)
{
IClassFactory* factory = 0;
GetClassObject getClassFunc = (GetClassObject)GetProcAddress(flashLib, "DllGetClassObject");
HRESULT result = getClassFunc(ShockwaveFlashObjects::CLSID_ShockwaveFlash, IID_IClassFactory, (void**)&factory);
if(SUCCEEDED(result))
{
factory->CreateInstance(NULL, IID_IOleObject, (void**)&oleObject);
factory->Release();
}
}
// If we still don't have the object, try loading from registry
if(!oleObject)
{
HRESULT result = CoCreateInstance(ShockwaveFlashObjects::CLSID_ShockwaveFlash, 0, CLSCTX_INPROC_SERVER, IID_IOleObject, (void**)&oleObject);
if(FAILED(result))
OGRE_EXCEPT(Ogre::Exception::ERR_RT_ASSERTION_FAILED, "Unable to load the Flash ActiveX control.", "FlashControl::createControl");
}
IOleClientSite* clientSite = 0;
site->QueryInterface(__uuidof(IOleClientSite), (void**)&clientSite);
oleObject->SetClientSite(clientSite);
clientSite->Release();
IOleInPlaceObject* inPlaceObject = 0;
oleObject->QueryInterface(__uuidof(IOleInPlaceObject), (LPVOID*)&inPlaceObject);
if(inPlaceObject)
{
invalidateTotally();
inPlaceObject->SetObjectRects(&dirtyBounds, &dirtyBounds);
inPlaceObject->Release();
}
oleObject->QueryInterface(__uuidof(ShockwaveFlashObjects::IShockwaveFlash), (LPVOID*)&flashInterface);
flashInterface->PutWMode("opaque");
oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, 0, clientSite, 0, 0, 0);
clientSite->Release();
oleObject->QueryInterface(__uuidof(IOleInPlaceObjectWindowless), (LPVOID*)&windowlessObject);
handler = new Impl::FlashHandler();
handler->AddRef();
handler->Init(this);
IViewObject* curView = 0;
flashInterface->QueryInterface(IID_IViewObject, (void**)&curView);
}
示例8: DeleteObject
// Static member functions
void CImageDataObject::InsertBitmap(IRichEditOle* pRichEditOle, HBITMAP hBitmap) {
LPLOCKBYTES lpLockBytes = NULL;
SCODE sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
if(sc != S_OK) {
DeleteObject(hBitmap);
pRichEditOle->Release();
dcdebug("Thrown OLE Exception: %d\n", sc);
return;
}
dcassert(lpLockBytes != NULL);
// Initialize a Storage Object
IStorage *pStorage = NULL;
sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &pStorage);
if(sc != S_OK) {
DeleteObject(hBitmap);
pRichEditOle->Release();
lpLockBytes->Release();
lpLockBytes = NULL;
dcdebug("Thrown OLE Exception: %d\n", sc);
return;
}
dcassert(pStorage != NULL);
CImageDataObject pods;
pods.SetBitmap(hBitmap);
// Get the RichEdit container site
IOleClientSite *pOleClientSite;
pRichEditOle->GetClientSite(&pOleClientSite);
// The final ole object which will be inserted in the richedit control
IOleObject* pOleObject = pods.GetOleObject(pOleClientSite, pStorage);
if(pOleObject != NULL) {
// all items are "contained" -- this makes our reference to this object
// weak -- which is needed for links to embedding silent update.
OleSetContainedObject(pOleObject, TRUE);
// Now Add the object to the RichEdit
REOBJECT reobject = { 0 };
reobject.cbStruct = sizeof(REOBJECT);
CLSID clsid;
sc = pOleObject->GetUserClassID(&clsid);
if(sc != S_OK) {
pRichEditOle->Release();
DeleteObject(hBitmap);
dcdebug("Thrown OLE Exception: %d\n", sc);
return;
}
reobject.clsid = clsid;
reobject.cp = REO_CP_SELECTION;
reobject.dvaspect = DVASPECT_CONTENT;
reobject.dwFlags = REO_BELOWBASELINE;
reobject.poleobj = pOleObject;
reobject.polesite = pOleClientSite;
reobject.pstg = pStorage;
// Insert the bitmap at the current location in the richedit control
pRichEditOle->InsertObject(&reobject);
// Release all unnecessary interfaces
pOleObject->Release();
}
pOleClientSite->Release();
lpLockBytes->Release();
pStorage->Release();
pRichEditOle->Release();
DeleteObject(hBitmap);
}
示例9: RichEdit_InsertFace
// 插入表情图片
BOOL RichEdit_InsertFace(ITextServices *pTextServices, ITextHost *pTextHost,
LPCTSTR lpszFileName, int nFaceId, int nFaceIndex,
COLORREF clrBg, BOOL bAutoScale, int nReservedWidth)
{
BSTR bstrFileName = NULL;
IRichEditOle * pRichEditOle = NULL;
IOleClientSite *pOleClientSite = NULL;
IImageOle* pImageOle = NULL;
IOleObject *pOleObject = NULL;
REOBJECT reobject = {0};
HRESULT hr = E_FAIL;
if (NULL == pTextServices || NULL == pTextHost ||
NULL == lpszFileName || NULL == *lpszFileName)
return FALSE;
TCHAR cProtocol[16] = {0};
_tcsncpy(cProtocol, lpszFileName, 7);
if ((_tcsicmp(cProtocol, _T("http://")) != 0) && ::GetFileAttributes(lpszFileName) == 0xFFFFFFFF)
return FALSE;
bstrFileName = ::SysAllocString(lpszFileName);
if (NULL == bstrFileName)
return FALSE;
pTextServices->TxSendMessage(EM_GETOLEINTERFACE, 0, (LPARAM)&pRichEditOle, NULL);
if (NULL == pRichEditOle)
goto Ret0;
hr = ::CoCreateInstance(CLSID_ImageOle, NULL,
CLSCTX_INPROC_SERVER, IID_IImageOle, (void**)&pImageOle);
if (FAILED(hr))
goto Ret0;
hr = pImageOle->QueryInterface(IID_IOleObject, (void **)&pOleObject);
if (FAILED(hr))
goto Ret0;
pRichEditOle->GetClientSite(&pOleClientSite);
if (NULL == pOleClientSite)
goto Ret0;
pOleObject->SetClientSite(pOleClientSite);
pImageOle->SetTextServices(pTextServices);
pImageOle->SetTextHost(pTextHost);
pImageOle->SetFaceId(nFaceId);
pImageOle->SetFaceIndex(nFaceIndex);
pImageOle->SetBgColor(clrBg);
pImageOle->SetAutoScale(bAutoScale, nReservedWidth);
pImageOle->LoadFromFile(bstrFileName);
hr = ::OleSetContainedObject(pOleObject, TRUE);
reobject.cbStruct = sizeof(REOBJECT);
reobject.clsid = CLSID_ImageOle;
reobject.cp = REO_CP_SELECTION;
reobject.dvaspect = DVASPECT_CONTENT;
reobject.dwFlags = REO_BELOWBASELINE;
reobject.poleobj = pOleObject;
reobject.polesite = pOleClientSite;
reobject.dwUser = 0;
hr = pRichEditOle->InsertObject(&reobject);
Ret0:
if (pOleObject != NULL)
pOleObject->Release();
if (pImageOle != NULL)
pImageOle->Release();
if (pOleClientSite != NULL)
pOleClientSite->Release();
if (pRichEditOle != NULL)
pRichEditOle->Release();
if (bstrFileName != NULL)
::SysFreeString(bstrFileName);
return SUCCEEDED(hr);
}
示例10: GetObject
// returns true on success, false on failure
bool ImageDataObject::InsertBitmap(IRichEditOle* pRichEditOle, HBITMAP hBitmap)
{
BITMAP bminfo;
// Get the image data object
//
ImageDataObject *pods = new ImageDataObject;
GetObject(hBitmap, sizeof(bminfo), &bminfo);
pods->SetBitmap(hBitmap);
// Get the RichEdit container site
//
IOleClientSite *pOleClientSite;
pRichEditOle->GetClientSite(&pOleClientSite);
// Initialize a Storage Object
//
LPLOCKBYTES lpLockBytes = nullptr;
SCODE sc = ::CreateILockBytesOnHGlobal(nullptr, TRUE, &lpLockBytes);
if (sc != S_OK) {
pOleClientSite->Release();
return false;
}
IStorage *pStorage;
sc = ::StgCreateDocfileOnILockBytes(lpLockBytes, STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE, 0, &pStorage);
if (sc != S_OK) {
lpLockBytes = nullptr;
pOleClientSite->Release();
return false;
}
// The final ole object which will be inserted in the richedit control
//
IOleObject *pOleObject;
pOleObject = pods->GetOleObject(pOleClientSite, pStorage);
if (pOleObject == nullptr) {
pStorage->Release();
pOleClientSite->Release();
return false;
}
// all items are "contained" -- this makes our reference to this object
// weak -- which is needed for links to embedding silent update.
OleSetContainedObject(pOleObject, TRUE);
// Now Add the object to the RichEdit
//
REOBJECT reobject;
memset(&reobject, 0, sizeof(REOBJECT));
reobject.cbStruct = sizeof(REOBJECT);
CLSID clsid;
sc = pOleObject->GetUserClassID(&clsid);
if (sc != S_OK) {
pOleObject->Release();
pStorage->Release();
pOleClientSite->Release();
return false;
}
reobject.clsid = clsid;
reobject.cp = REO_CP_SELECTION;
reobject.dvaspect = DVASPECT_CONTENT;
reobject.poleobj = pOleObject;
reobject.polesite = pOleClientSite;
reobject.pstg = pStorage;
reobject.dwFlags = bminfo.bmHeight <= 12 ? 0 : REO_BELOWBASELINE;
// Insert the bitmap at the current location in the richedit control
//
sc = pRichEditOle->InsertObject(&reobject);
// Release all unnecessary interfaces
//
pOleObject->Release();
pOleClientSite->Release();
lpLockBytes->Release();
pStorage->Release();
return sc == S_OK;
}
示例11: InsertBitmap
void CImageDataObject::InsertBitmap(IRichEditOle* pRichEditOle, HBITMAP hBitmap)
{
SCODE sc;
// Get the image data object
//
CImageDataObject *pods = new CImageDataObject;
LPDATAOBJECT lpDataObject;
pods->QueryInterface(IID_IDataObject, (void **)&lpDataObject);
pods->SetBitmap(hBitmap);
// Get the RichEdit container site
//
IOleClientSite *pOleClientSite;
pRichEditOle->GetClientSite(&pOleClientSite);
// Initialize a Storage Object
//
IStorage *pStorage;
LPLOCKBYTES lpLockBytes = NULL;
sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
if (sc != S_OK)
AfxThrowOleException(sc);
ASSERT(lpLockBytes != NULL);
sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &pStorage);
if (sc != S_OK)
{
VERIFY(lpLockBytes->Release() == 0);
lpLockBytes = NULL;
AfxThrowOleException(sc);
}
ASSERT(pStorage != NULL);
// The final ole object which will be inserted in the richedit control
//
IOleObject *pOleObject;
pOleObject = pods->GetOleObject(pOleClientSite, pStorage);
if(!pOleObject)
AfxThrowOleException(sc);
// all items are "contained" -- this makes our reference to this object
// weak -- which is needed for links to embedding silent update.
OleSetContainedObject(pOleObject, TRUE);
// Now Add the object to the RichEdit
//
REOBJECT reobject;
ZeroMemory(&reobject, sizeof(REOBJECT));
reobject.cbStruct = sizeof(REOBJECT);
CLSID clsid;
sc = pOleObject->GetUserClassID(&clsid);
if (sc != S_OK)
AfxThrowOleException(sc);
reobject.clsid = clsid;
reobject.cp = REO_CP_SELECTION;
reobject.dvaspect = DVASPECT_CONTENT;
reobject.poleobj = pOleObject;
reobject.polesite = pOleClientSite;
reobject.pstg = pStorage;
// Insert the bitmap at the current location in the richedit control
//
pRichEditOle->InsertObject(&reobject);
// Release all unnecessary interfaces
//
pOleObject->Release();
pOleClientSite->Release();
pStorage->Release();
lpDataObject->Release();
}
示例12: RichEdit_InsertSkin
BOOL RichEdit_InsertSkin(CDuiRichEdit *pRicheditCtrl, CDuiSkinBase *pSkin)
{
IRichEditOle *pRichEditOle=NULL;
LRESULT lRes=pRicheditCtrl->DuiSendMessage(EM_GETOLEINTERFACE,0,(LPARAM)&pRichEditOle);
if(!pRichEditOle) return FALSE;
SCODE sc;
IOleClientSite *pOleClientSite = NULL;
pRichEditOle->GetClientSite(&pOleClientSite);
if (NULL == pOleClientSite)
return FALSE;
IStorage *pStorage = NULL;
LPLOCKBYTES lpLockBytes = NULL;
sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
if (sc != S_OK)
return FALSE;
sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &pStorage);
if (sc != S_OK)
{
lpLockBytes->Release();
lpLockBytes = NULL;
return FALSE;
}
CImageOle *pImageOle = new CImageOle(pRicheditCtrl);
if (NULL == pImageOle)
return FALSE;
pImageOle->SetDuiSkinObj(pSkin);
IOleObject *pOleObject = NULL;
pImageOle->QueryInterface(IID_IOleObject, (void **)&pOleObject);
if (NULL == pOleObject)
{
delete pImageOle;
return FALSE;
}
pImageOle->SetClientSite(pOleClientSite);
HRESULT hr = ::OleSetContainedObject(pOleObject, TRUE);
REOBJECT reobject = {0};
reobject.cbStruct = sizeof(REOBJECT);
reobject.clsid = CLSID_NULL;
reobject.cp = REO_CP_SELECTION;
reobject.dvaspect = DVASPECT_CONTENT;
reobject.poleobj = pOleObject;
reobject.polesite = pOleClientSite;
reobject.pstg = pStorage;
reobject.dwUser = 0;
pRichEditOle->InsertObject(&reobject);
pOleObject->Release();
pOleClientSite->Release();
pStorage->Release();
pRichEditOle->Release();
return TRUE;
}
示例13: OleRegGetMiscStatus
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);
//.........这里部分代码省略.........
示例14:
~Pimpl()
{
if (control != 0)
{
control->Close (OLECLOSE_NOSAVE);
control->Release();
}
clientSite->Release();
storage->Release();
}