www.pudn.com > ShortCutEx.rar > ShortCutToolBar.cpp, change:2004-08-09,size:4781b
//ShortCutToolBar.cpp : Implementation of CShortCutToolBar //***************************************************************************// // // // This file was created using the DeskBand ATL Object Wizard 2.0 // // By Erik Thompson © 2001 // // Email questions and comments to erikt@radbytes.com // // // //***************************************************************************// #include "stdafx.h" #include <wchar.h> #include "ShortCutEx.h" #include "ShortCutToolBar.h" const WCHAR TITLE_CShortCutToolBar[] = L"ShortCutBar"; ///////////////////////////////////////////////////////////////////////////// // CShortCutToolBar CShortCutToolBar::CShortCutToolBar(): m_dwBandID(0), m_dwViewMode(0), m_bShow(FALSE), m_bEnterHelpMode(FALSE), m_hWndParent(NULL), m_pSite(NULL) { } BOOL CShortCutToolBar::RegisterAndCreateWindow() { RECT rect; ::GetClientRect(m_hWndParent, &rect); m_ReflectWnd.Create(m_hWndParent, rect, NULL, WS_CHILD); // The toolbar is the window that the host will be using so it is the window that is important. return m_ReflectWnd.GetToolBar().IsWindow(); } // IDeskBand STDMETHODIMP CShortCutToolBar::GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO* pdbi) { m_dwBandID = dwBandID; m_dwViewMode = dwViewMode; if (pdbi) { if (pdbi->dwMask & DBIM_MINSIZE) { pdbi->ptMinSize.x = 250; pdbi->ptMinSize.y = 26; } if (pdbi->dwMask & DBIM_MAXSIZE) { pdbi->ptMaxSize.x = 0; // ignored pdbi->ptMaxSize.y = 26; // width } if (pdbi->dwMask & DBIM_INTEGRAL) { pdbi->ptIntegral.x = 1; // ignored pdbi->ptIntegral.y = 1; // not sizeable } if (pdbi->dwMask & DBIM_ACTUAL) { pdbi->ptActual.x = 250; pdbi->ptActual.y = 26; } if (pdbi->dwMask & DBIM_TITLE) { wcscpy(pdbi->wszTitle, TITLE_CShortCutToolBar); } if (pdbi->dwMask & DBIM_BKCOLOR) { //Use the default background color by removing this flag. pdbi->dwMask &= ~DBIM_BKCOLOR; } if (pdbi->dwMask & DBIM_MODEFLAGS) { pdbi->dwModeFlags = DBIMF_VARIABLEHEIGHT; } } return S_OK; } // IOleWindow STDMETHODIMP CShortCutToolBar::GetWindow(HWND* phwnd) { HRESULT hr = S_OK; if (NULL == phwnd) { hr = E_INVALIDARG; } else { //*phwnd = m_ReflectWnd.m_hWnd; *phwnd = m_ReflectWnd.GetToolBar().m_hWnd; } return hr; } STDMETHODIMP CShortCutToolBar::ContextSensitiveHelp(BOOL fEnterMode) { m_bEnterHelpMode = fEnterMode; return S_OK; } // IDockingWindow STDMETHODIMP CShortCutToolBar::CloseDW(unsigned long dwReserved) { ShowDW(FALSE); return S_OK; } STDMETHODIMP CShortCutToolBar::ResizeBorderDW(const RECT* prcBorder, IUnknown* punkToolbarSite, BOOL fReserved) { // Not used by any band object. return E_NOTIMPL; } STDMETHODIMP CShortCutToolBar::ShowDW(BOOL fShow) { HRESULT hr = S_OK; m_bShow = fShow; m_ReflectWnd.GetToolBar().ShowWindow(m_bShow ? SW_SHOW : SW_HIDE); // ShowWindow(m_hWnd, m_bShow ? SW_SHOW : SW_HIDE); return hr; } // IObjectWithSite STDMETHODIMP CShortCutToolBar::SetSite(IUnknown* pUnkSite) { //If a site is being held, release it. if(m_pSite) { m_pSite->Release(); m_pSite = NULL; } //If punkSite is not NULL, a new site is being set. if(pUnkSite) { //Get the parent window. IOleWindow *pOleWindow = NULL; m_hWndParent = NULL; if(SUCCEEDED(pUnkSite->QueryInterface(IID_IOleWindow, (LPVOID*)&pOleWindow))) { pOleWindow->GetWindow(&m_hWndParent); pOleWindow->Release(); } if(!::IsWindow(m_hWndParent)) return E_FAIL; if(!RegisterAndCreateWindow()) return E_FAIL; //Get and keep the IInputObjectSite pointer. if(SUCCEEDED(pUnkSite->QueryInterface(IID_IInputObjectSite, (LPVOID*)&m_pSite))) { return S_OK; } return E_FAIL; } return S_OK; } STDMETHODIMP CShortCutToolBar::GetSite(REFIID riid, void **ppvSite) { *ppvSite = NULL; if(m_pSite) { return m_pSite->QueryInterface(riid, ppvSite); } return E_FAIL; } // IPersist STDMETHODIMP CShortCutToolBar::GetClassID(CLSID *pClassID) { *pClassID = CLSID_ShortCutToolBar; return S_OK; } // IPersistStream STDMETHODIMP CShortCutToolBar::IsDirty(void) { return S_FALSE; } STDMETHODIMP CShortCutToolBar::Load(IStream *pStm) { return S_OK; } STDMETHODIMP CShortCutToolBar::Save(IStream *pStm, BOOL fClearDirty) { return S_OK; } STDMETHODIMP CShortCutToolBar::GetSizeMax(ULARGE_INTEGER *pcbSize) { return E_NOTIMPL; }