/** * @file XTPReBar.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPREBAR_H__) # define __XTPREBAR_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPToolBar; /** @cond */ # if _MSC_VER < 1200 // MFC 6.0 # ifndef AFX_IDW_REBAR # define AFX_IDW_REBAR 0xE804 # endif class _XTP_EXT_CLASS CXTPReBarBase : public CControlBar { DECLARE_DYNAMIC(CXTPReBarBase) // Construction public: CXTPReBarBase(); BOOL Create(CWnd* pParentWnd, DWORD dwCtrlStyle = RBS_BANDBORDERS, DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_TOP, UINT nID = AFX_IDW_REBAR); // Attributes public: int m_iComCtlVersion; // Operations public: BOOL AddBar(CWnd* pBar, LPCTSTR pszText = NULL, CBitmap* pbmp = NULL, DWORD dwStyle = RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP); BOOL AddBar(CWnd* pBar, COLORREF clrFore, COLORREF clrBack, LPCTSTR pszText = NULL, DWORD dwStyle = RBBS_GRIPPERALWAYS); // Implementation virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler); virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const; virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz); virtual CSize CalcDynamicLayout(int nLength, DWORD nMode); # ifdef _DEBUG void EnableDocking(DWORD dwDockStyle); # endif protected: virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); BOOL _AddBar(CWnd* pBar, REBARBANDINFO* pRBBI); //{{AFX_MSG(CReBar) afx_msg BOOL OnNcCreate(LPCREATESTRUCT); afx_msg void OnHeightChange(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnNcPaint(); afx_msg void OnNcCalcSize(BOOL, NCCALCSIZE_PARAMS*); afx_msg LRESULT OnShowBand(WPARAM wParam, LPARAM lParam); afx_msg void OnRecalcParent(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; # else # define CXTPReBarBase CReBar # endif /** @endcond */ /** * @brief * The CXTPReBar object extends the standard MFC CReBar class to provide * extended functionality such as saving and restoring band layouts. */ class _XTP_EXT_CLASS CXTPReBar : public CXTPReBarBase { /** @cond */ DECLARE_DYNAMIC(CXTPReBar) /** @endcond */ public: /** * @brief * Constructs a CXTPReBar object. */ CXTPReBar(); /** * @brief * Destroys a CXTPReBar object, handles cleanup and deallocation. */ virtual ~CXTPReBar(); public: /** * @brief * Call this member to add a band to the rebar. The specified toolbar * will be inserted into the band. * @param pToolBar Pointer to the Toolbar object that will be added to * rebar band. * @param dwStyle Contains styles that can be applied to the rebar. * the only band in the rebar. * @details * The ID of the band that contains the toolbar is assigned the same ID * as the toolbar. * @return * TRUE is the bar was added successfully, FALSE if the bar wasn't added. */ BOOL AddToolBar(CXTPToolBar* pToolBar, DWORD dwStyle = RBBS_GRIPPERALWAYS); /** * @brief * Call this member to remove a toolbar within the rebar. This will * also remove the band that contained the toolbar. * @param pToolBar Pointer to the toolbar that will be removed. */ void DeleteToolBar(CXTPToolBar* pToolBar); /** * @brief * Call this member to locate the band that contains a toolbar. * @param pToolBar Pointer to the toolbar you want to find. * @return * If found on a band in the rebar, then the ID of the band that contains the * toolbar will be returned. If not found, then a value of -1 will be returned. */ int FindBand(CXTPToolBar* pToolBar); /** * @brief * Call this member to retrieve a pointer to the toolbar contained * in the band with the specified ID. * @param nBand ID of a band in the rebar. * @return * A pointer to the toolbar contained in the specified band. */ CXTPToolBar* GetToolBar(int nBand); /** * @brief * Retrieves state information from the registry. * @param lpszProfileName Pointer to a NULL-teminated string that specifies * the name of a key in the Windows registry where the * state information is stored. */ void LoadState(LPCTSTR lpszProfileName); /** * @brief * Saves state information to the registry. * @param lpszProfileName Pointer to a NULL-teminated string that specifies * the name of a key in the Windows registry where the * state information should be stored. */ void SaveState(LPCTSTR lpszProfileName); /** * @brief * This member function implements the behavior of the Win32 message * RB_SETBANDINFO, as described in the Platform SDK. * @param uBand Zero-based index of the band to receive the new settings. * @param prbbi Pointer to a REBARBANDINFO structure that defines the band to be * inserted. You must set the 'cbSize' member of this structure to * sizeof(REBARBANDINFO) before sending this message. * @return * Nonzero if successful, otherwise zero. * * Example: *
* int nCount = m_wndReBar.GetReBarCtrl().GetBandCount(); * CString strText = "Band #:"; * * int i; * for (i = 0; i*/ BOOL SetBandInfo(UINT uBand, REBARBANDINFO* prbbi); protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_MSG(CXTPReBar) void OnChildSize(NMHDR* pNotifyStruct, LRESULT* result); void OnPaint(); BOOL OnEraseBkgnd(CDC* pDC); virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz); //}}AFX_MSG /** @endcond */ private: static const LPCTSTR m_lpszStateInfoEntry; static const LPCTSTR m_lpszStateInfoFormat; }; AFX_INLINE BOOL CXTPReBar::SetBandInfo(UINT uBand, REBARBANDINFO* prbbi) { return (BOOL)DefWindowProc(RB_SETBANDINFO, uBand, (LPARAM)prbbi); } ///////////////////////////////////////////////////////////////////////////// /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // !defined(__XTPREBAR_H__) /** @endcond */cbSize = sizeof(REBARBANDINFO); * * CString strText; * strText.Format("Band #: %d", i); * * LPTSTR lpszText = strText.GetBuffer(strText.GetLength()); * prbbi->lpText = lpszText; * prbbi->cch = strlen(lpszText) + 1; * prbbi->fMask = RBBIM_TEXT; * * m_wndReBar.SetBandInfo(i, prbbi); * * strText.ReleaseBuffer(); * } *