DeskBand实现之SdkDeskBandObject.cpp文件有什么用
小编给大家分享一下DeskBand实现之SdkDeskBandObject.cpp文件有什么用,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
创新互联:成立于2013年为各行业开拓出企业自己的“网站建设”服务,为上1000家公司企业提供了专业的成都网站制作、网站建设、网页设计和网站推广服务, 按需求定制设计由设计师亲自精心设计,设计的效果完全按照客户的要求,并适当的提出合理的建议,拥有的视觉效果,策划师分析客户的同行竞争对手,根据客户的实际情况给出合理的网站构架,制作客户同行业具有领先地位的。
SdkDeskBandObject.cpp文件
说明:这是Desk Band最核心的类,它主要完成Band对象的创建,销毁,窗体创建,关闭,显示等。当创建空上对象时,一定要把当前DLL的引用计数加1,对象析构时,DLL的引用计数要减1。
#define _DEFINE_GLOBAL_VARIABLES #include "SdkDeskBandDef.h" #include "SdkDeskBandObject.h" SdkDeskBandObject::SdkDeskBandObject(void) { m_lRefCount = 1; m_dwBandID = 0; m_fHasFocus = FALSE; m_fIsDirty = FALSE; m_dwViewMode = DBIF_VIEWMODE_NORMAL; m_pInputObjSite = NULL; m_pDeskBandWin = NULL; m_fCompositionEnabled = FALSE; // Add the reference count of dll. // This is a global variable defined in SdkDeskBandDef.h file InterlockedIncrement(&g_lDllRefCount); } ////////////////////////////////////////////////////////////////////////// SdkDeskBandObject::~SdkDeskBandObject(void) { // Subtract the reference count of dll. // This is a global variable defined in SdkDeskBandDef.h file InterlockedDecrement(&g_lDllRefCount); SAFE_DELETE(m_pDeskBandWin); SAFE_RELEASE(m_pInputObjSite); } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::QueryInterface(REFIID riid, void** ppv) { static const QITAB qit[] = { QITABENT(SdkDeskBandObject, IDeskBand), QITABENT(SdkDeskBandObject, IDeskBand2), QITABENT(SdkDeskBandObject, IDockingWindow), QITABENT(SdkDeskBandObject, IPersist), QITABENT(SdkDeskBandObject, IPersistStream), QITABENT(SdkDeskBandObject, IInputObject), QITABENT(SdkDeskBandObject, IOleWindow), QITABENT(SdkDeskBandObject, IObjectWithSite), { 0 }, }; return QISearch(this, qit, riid, ppv); } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP_(ULONG) SdkDeskBandObject::AddRef() { return InterlockedIncrement(&m_lRefCount); } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP_(ULONG) SdkDeskBandObject::Release() { ULONG lRef = InterlockedDecrement(&m_lRefCount); if ( 0 == lRef ) { delete this; } return lRef; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::GetWindow(HWND *phwnd) { if ( NULL == phwnd ) { return E_INVALIDARG; } if ( NULL != m_pDeskBandWin ) { *phwnd = m_pDeskBandWin->GetDeskBandHandle(); } return S_OK; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::ContextSensitiveHelp(BOOL fEnterMode) { UNREFERENCED_PARAMETER(fEnterMode); return E_NOTIMPL; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::ShowDW(BOOL fShow) { if ( NULL != m_pDeskBandWin ) { m_pDeskBandWin->ShowDeskBand(fShow); } return S_OK; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::CloseDW(DWORD dwReserved) { UNREFERENCED_PARAMETER(dwReserved); if ( NULL != m_pDeskBandWin ) { m_pDeskBandWin->CloseDeskBand(); } return S_OK; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved) { UNREFERENCED_PARAMETER(prcBorder); UNREFERENCED_PARAMETER(punkToolbarSite); UNREFERENCED_PARAMETER(fReserved); return E_NOTIMPL; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi) { if ( NULL == pdbi ) { return E_INVALIDARG; } m_dwBandID = dwBandID; m_dwViewMode = dwViewMode; SIZE deskBandSize = m_pDeskBandWin->GetDeskBandMinSize( (DBIF_VIEWMODE_VERTICAL == dwViewMode) ? FALSE : TRUE ); POINTL ptMinSize = { deskBandSize.cx, deskBandSize.cy }; POINTL ptActual = { deskBandSize.cx, deskBandSize.cy }; if ( pdbi->dwMask & DBIM_MINSIZE ) { pdbi->ptMinSize = ptMinSize; } if ( pdbi->dwMask & DBIM_ACTUAL ) { pdbi->ptActual = ptActual; } if ( pdbi->dwMask & DBIM_MAXSIZE ) { // There is no limit for the maximum height. pdbi->ptMaxSize.y = -1; } if ( pdbi->dwMask & DBIM_INTEGRAL ) { // The sizing step value of the band object. pdbi->ptIntegral.y = 1; } if ( pdbi->dwMask & DBIM_TITLE ) { // Do NOT show the title by removing the flag. pdbi->dwMask &= ~DBIM_TITLE; } if ( pdbi->dwMask & DBIM_MODEFLAGS ) { pdbi->dwModeFlags = DBIMF_NORMAL | DBIMF_VARIABLEHEIGHT; } if ( pdbi->dwMask & DBIM_BKCOLOR ) { // Use the default background color by removing this flag. pdbi->dwMask &= ~DBIM_BKCOLOR; } return S_OK; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::CanRenderComposited(BOOL *pfCanRenderComposited) { if ( NULL == pfCanRenderComposited ) { return E_INVALIDARG; } *pfCanRenderComposited = TRUE; return S_OK; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::SetCompositionState(BOOL fCompositionEnabled) { m_fCompositionEnabled = fCompositionEnabled; if ( NULL != m_pDeskBandWin ) { m_pDeskBandWin->RefreshDeskBand(); } return S_OK; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::GetCompositionState(BOOL *pfCompositionEnabled) { if ( NULL == pfCompositionEnabled ) { return E_INVALIDARG; } *pfCompositionEnabled = m_fCompositionEnabled; return S_OK; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::GetClassID(CLSID *pclsid) { if ( NULL == pclsid ) { return E_INVALIDARG; } *pclsid = CLSID_SdkDeskBand; return S_OK; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::IsDirty() { return (TRUE == m_fIsDirty) ? S_OK : S_FALSE; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::Load(IStream *pStm) { UNREFERENCED_PARAMETER(pStm); return E_NOTIMPL; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::Save(IStream *pStm, BOOL fClearDirty) { UNREFERENCED_PARAMETER(pStm); if ( TRUE == fClearDirty ) { m_fIsDirty = FALSE; } return E_NOTIMPL; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::GetSizeMax(ULARGE_INTEGER *pcbSize) { UNREFERENCED_PARAMETER(pcbSize); return E_NOTIMPL; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::SetSite(IUnknown *pUnkSite) { SAFE_RELEASE(m_pInputObjSite); if ( NULL == pUnkSite ) { return S_OK; } IOleWindow *pOleWindow = NULL; HRESULT hr = pUnkSite->QueryInterface(IID_PPV_ARGS(&pOleWindow)); if ( SUCCEEDED(hr) ) { HWND hParentWnd = NULL; hr = pOleWindow->GetWindow(&hParentWnd); if ( SUCCEEDED(hr) ) { // Create the desk band window. if ( NULL != m_pDeskBandWin ) { // g_hDllInst is a global variable to // indicate instance of current dll defined // in SdkDeskBanddef.h file. m_pDeskBandWin->CreateDeskBand(hParentWnd, g_hDllInst, this); } } hr = pUnkSite->QueryInterface(IID_PPV_ARGS(&m_pInputObjSite)); } SAFE_RELEASE(pOleWindow); return hr; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::GetSite(REFIID riid, void **ppv) { if ( NULL == ppv ) { return E_INVALIDARG; } HRESULT hr = E_FAIL; if ( NULL == m_pInputObjSite ) { *ppv = NULL; } else { hr = m_pInputObjSite->QueryInterface(riid, ppv); } return hr; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::UIActivateIO(BOOL fActivate, MSG *pMsg) { UNREFERENCED_PARAMETER(pMsg); if ( TRUE == fActivate ) { if ( NULL != m_pDeskBandWin ) { SetFocus(m_pDeskBandWin->GetDeskBandHandle()); } } return S_OK; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::HasFocusIO() { return (TRUE == m_fHasFocus) ? S_OK : S_FALSE; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkDeskBandObject::TranslateAcceleratorIO(MSG *pMsg) { UNREFERENCED_PARAMETER(pMsg); return S_FALSE; } ////////////////////////////////////////////////////////////////////////// BOOL SdkDeskBandObject::OnSetFocus(BOOL fSetFocus) { if ( NULL == m_pInputObjSite ) { return FALSE; } m_fHasFocus = fSetFocus; HRESULT hr = m_pInputObjSite->OnFocusChangeIS( static_cast(this), fSetFocus); return SUCCEEDED(hr) ? TRUE : FALSE; } ////////////////////////////////////////////////////////////////////////// BOOL SdkDeskBandObject::IsVerticalViewMode() { return (DBIF_VIEWMODE_VERTICAL == m_dwViewMode) ? TRUE : FALSE; }
SdkClassFactory.cpp文件
说明:这个类用于创建Band对象,在其CreateInstance方法里面,就要创建出Band对象,它由DllGetClassObject函数调用。
SdkClassFactory::SdkClassFactory(void) { m_lRefCount = 1; // Add the reference count of dll. This is a global // variable defined in SdkDeskBandDef.h file InterlockedIncrement(&g_lDllRefCount); } ////////////////////////////////////////////////////////////////////////// SdkClassFactory::~SdkClassFactory(void) { // Subtract the reference count of dll. This is a global // variable defined in SdkDeskBandDef.h file InterlockedDecrement(&g_lDllRefCount); } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkClassFactory::QueryInterface(REFIID riid, void **ppv) { static const QITAB qit[] = { QITABENT(SdkClassFactory, IUnknown), QITABENT(SdkClassFactory, IClassFactory), { 0 }, }; return QISearch(this, qit, riid, ppv); } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP_(ULONG) SdkClassFactory::AddRef() { return InterlockedIncrement(&m_lRefCount); } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP_(ULONG) SdkClassFactory::Release() { ULONG lRef = InterlockedDecrement(&m_lRefCount); if ( 0 == lRef ) { delete this; } return m_lRefCount; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkClassFactory::CreateInstance( IUnknown *pUnkOuter, REFIID riid, void **ppv) { HRESULT hr = CLASS_E_NOAGGREGATION; if ( NULL == pUnkOuter ) { hr = E_OUTOFMEMORY; SdkDeskBandObject *pDeskBand = new SdkDeskBandObject(); if ( NULL != pDeskBand ) { hr = pDeskBand->QueryInterface(riid, ppv); } SAFE_RELEASE(pDeskBand); } return hr; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP SdkClassFactory::LockServer(BOOL fLock) { if ( TRUE == fLock ) { // Add the reference count of dll. This is a // global variable defined in SdkDeskBandDef.h file. InterlockedIncrement(&g_lDllRefCount); } else { // Subtract the reference count of dll. This is // a global variable defined in SdkDeskBandDef.h file. InterlockedDecrement(&g_lDllRefCount); } return S_OK; }
以上是“DeskBand实现之SdkDeskBandObject.cpp文件有什么用”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!
网站标题:DeskBand实现之SdkDeskBandObject.cpp文件有什么用
链接URL:http://cdiso.cn/article/peeeso.html