--- /dev/null
+// Win32++ Version 7.3\r
+// Released: 30th November 2011\r
+//\r
+// David Nash\r
+// url: https://sourceforge.net/projects/win32-framework\r
+//\r
+//\r
+// Copyright (c) 2005-2011 David Nash\r
+//\r
+// Permission is hereby granted, free of charge, to\r
+// any person obtaining a copy of this software and\r
+// associated documentation files (the "Software"),\r
+// to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify,\r
+// merge, publish, distribute, sublicense, and/or sell\r
+// copies of the Software, and to permit persons to whom\r
+// the Software is furnished to do so, subject to the\r
+// following conditions:\r
+//\r
+// The above copyright notice and this permission notice\r
+// shall be included in all copies or substantial portions\r
+// of the Software.\r
+//\r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF\r
+// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\r
+// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\r
+// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT\r
+// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR\r
+// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE\r
+// OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+////////////////////////////////////////////////////////\r
+\r
+\r
+#ifndef _WIN32XX_REBAR_H_\r
+#define _WIN32XX_REBAR_H_\r
+\r
+#include "wincore.h"\r
+#include "gdi.h"\r
+#include "controls.h"\r
+\r
+namespace Win32xx\r
+{\r
+\r
+ struct ReBarTheme\r
+ {\r
+ BOOL UseThemes; // TRUE if themes are used\r
+ COLORREF clrBkgnd1; // Colour 1 for rebar background\r
+ COLORREF clrBkgnd2; // Colour 2 for rebar background\r
+ COLORREF clrBand1; // Colour 1 for rebar band background. Use NULL if not required\r
+ COLORREF clrBand2; // Colour 2 for rebar band background. Use NULL if not required\r
+ BOOL FlatStyle; // Bands are rendered with flat rather than raised style\r
+ BOOL BandsLeft; // Position bands left on rearrange\r
+ BOOL LockMenuBand; // Lock MenuBar's band in dedicated top row, without gripper\r
+ BOOL RoundBorders; // Use rounded band borders\r
+ BOOL ShortBands; // Allows bands to be shorter than maximum available width\r
+ BOOL UseLines; // Displays horizontal lines between bands\r
+ };\r
+\r
+ ////////////////////////////////////\r
+ // Declaration of the CReBar class\r
+ //\r
+ class CReBar : public CWnd\r
+ {\r
+ public:\r
+ CReBar();\r
+ virtual ~CReBar();\r
+\r
+ // Operations\r
+ BOOL DeleteBand(const int nBand) const;\r
+ int HitTest(RBHITTESTINFO& rbht);\r
+ HWND HitTest(POINT pt);\r
+ int IDToIndex(UINT uBandID) const;\r
+ BOOL InsertBand(const int nBand, REBARBANDINFO& rbbi) const;\r
+ BOOL IsBandVisible(int nBand) const;\r
+ void MaximizeBand(UINT uBand, BOOL fIdeal = FALSE);\r
+ void MinimizeBand(UINT uBand);\r
+ BOOL MoveBand(UINT uFrom, UINT uTo);\r
+ void MoveBandsLeft();\r
+ BOOL ResizeBand(const int nBand, const CSize& sz) const;\r
+ BOOL ShowGripper(int nBand, BOOL fShow) const;\r
+ BOOL ShowBand(int nBand, BOOL fShow) const;\r
+ BOOL SizeToRect(CRect& rect) const;\r
+ \r
+ // Attributes\r
+ int GetBand(const HWND hWnd) const;\r
+ CRect GetBandBorders(int nBand) const;\r
+ int GetBandCount() const;\r
+ BOOL GetBandInfo(const int nBand, REBARBANDINFO& rbbi) const;\r
+ CRect GetBandRect(int i) const;\r
+ UINT GetBarHeight() const;\r
+ BOOL GetBarInfo(REBARINFO& rbi) const;\r
+ HWND GetMenuBar() {return m_hMenuBar;}\r
+ ReBarTheme& GetReBarTheme() {return m_Theme;}\r
+ UINT GetRowCount() const;\r
+ int GetRowHeight(int nRow) const;\r
+ UINT GetSizeofRBBI() const;\r
+ CToolTip* GetToolTips() const;\r
+ BOOL SetBandBitmap(const int nBand, const CBitmap* pBackground) const;\r
+ BOOL SetBandColor(const int nBand, const COLORREF clrFore, const COLORREF clrBack) const;\r
+ BOOL SetBandInfo(const int nBand, REBARBANDINFO& rbbi) const;\r
+ BOOL SetBarInfo(REBARINFO& rbi) const;\r
+ void SetMenuBar(HWND hMenuBar) {m_hMenuBar = hMenuBar;}\r
+ void SetReBarTheme(ReBarTheme& Theme);\r
+ void SetToolTips(CToolTip* pToolTip) const;\r
+\r
+ protected:\r
+ //Overridables\r
+ virtual BOOL OnEraseBkgnd(CDC* pDC);\r
+ virtual void PreCreate(CREATESTRUCT& cs);\r
+ virtual void PreRegisterClass(WNDCLASS &wc);\r
+ virtual LRESULT WndProcDefault(UINT uMsg, WPARAM wParam, LPARAM lParam);\r
+\r
+ private:\r
+ CReBar(const CReBar&); // Disable copy construction\r
+ CReBar& operator = (const CReBar&); // Disable assignment operator\r
+\r
+ ReBarTheme m_Theme;\r
+ BOOL m_bIsDragging;\r
+ HWND m_hMenuBar;\r
+ LPARAM m_Orig_lParam;\r
+ };\r
+\r
+}\r
+\r
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+\r
+\r
+namespace Win32xx\r
+{\r
+\r
+ ///////////////////////////////////\r
+ // Definitions for the CReBar class\r
+ //\r
+ inline CReBar::CReBar() : m_bIsDragging(FALSE), m_hMenuBar(0), m_Orig_lParam(0L)\r
+ {\r
+ ZeroMemory(&m_Theme, sizeof(ReBarTheme));\r
+ }\r
+\r
+ inline CReBar::~CReBar()\r
+ {\r
+ }\r
+\r
+ inline BOOL CReBar::DeleteBand(int nBand) const\r
+ // Deletes a band from a rebar control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)SendMessage(RB_DELETEBAND, nBand, 0L);\r
+ }\r
+\r
+ inline int CReBar::GetBand(HWND hWnd) const\r
+ // Returns the zero based band number for this window handle\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ int nResult = -1;\r
+ if (NULL == hWnd) return nResult;\r
+\r
+ for (int nBand = 0; nBand < GetBandCount(); ++nBand)\r
+ {\r
+ REBARBANDINFO rbbi = {0};\r
+ rbbi.cbSize = GetSizeofRBBI();\r
+ rbbi.fMask = RBBIM_CHILD;\r
+ GetBandInfo(nBand, rbbi);\r
+ if (rbbi.hwndChild == hWnd)\r
+ nResult = nBand;\r
+ }\r
+\r
+ return nResult;\r
+ }\r
+\r
+ inline CRect CReBar::GetBandBorders(int nBand) const\r
+ // Retrieves the borders of a band.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ CRect rc;\r
+ SendMessage(RB_GETBANDBORDERS, nBand, (LPARAM)&rc);\r
+ return rc;\r
+ }\r
+\r
+ inline int CReBar::GetBandCount() const\r
+ // Retrieves the count of bands currently in the rebar control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(RB_GETBANDCOUNT, 0L, 0L);\r
+ }\r
+\r
+ inline BOOL CReBar::GetBandInfo(int nBand, REBARBANDINFO& rbbi) const\r
+ // Retrieves information about a specified band in a rebar control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ assert(nBand >= 0);\r
+\r
+ // REBARBANDINFO describes individual BAND characteristics\r
+ rbbi.cbSize = GetSizeofRBBI();\r
+ return (BOOL)SendMessage(RB_GETBANDINFO, nBand, (LPARAM)&rbbi);\r
+ }\r
+\r
+ inline CRect CReBar::GetBandRect(int i) const\r
+ // Retrieves the bounding rectangle for a given band in a rebar control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ CRect rc;\r
+ SendMessage(RB_GETRECT, i, (LPARAM)&rc);\r
+ return rc;\r
+ }\r
+\r
+ inline UINT CReBar::GetBarHeight() const\r
+ // Retrieves the height of the rebar control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (UINT)SendMessage(RB_GETBARHEIGHT, 0L, 0L);\r
+ }\r
+\r
+ inline BOOL CReBar::GetBarInfo(REBARINFO& rbi) const\r
+ // Retrieves information about the rebar control and the image list it uses.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ // REBARINFO describes overall rebar control characteristics\r
+ rbi.cbSize = GetSizeofRBBI();\r
+ return (BOOL)SendMessage(RB_GETBARINFO, 0L, (LPARAM)&rbi);\r
+ }\r
+\r
+ inline UINT CReBar::GetRowCount() const\r
+ // Retrieves the number of rows of bands in a rebar control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (UINT)SendMessage(RB_GETROWCOUNT, 0L, 0L);\r
+ }\r
+\r
+ inline int CReBar::GetRowHeight(int nRow) const\r
+ // Retrieves the height of a specified row in a rebar control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(RB_GETROWHEIGHT, nRow, 0L);\r
+ }\r
+\r
+ inline UINT CReBar::GetSizeofRBBI() const\r
+ // The size of the REBARBANDINFO struct changes according to _WIN32_WINNT\r
+ // sizeof(REBARBANDINFO) can report an incorrect size for older Window versions,\r
+ // or newer Window version without XP themes enabled.\r
+ // Use this function to get a safe size for REBARBANDINFO.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ UINT uSizeof = sizeof(REBARBANDINFO);\r
+\r
+ #if defined REBARBANDINFO_V6_SIZE // only defined for VS2008 or higher\r
+ #if !defined (_WIN32_WINNT) || _WIN32_WINNT >= 0x0600\r
+ if ((GetWinVersion() < 2600) || (GetComCtlVersion() < 610)) // Vista and Vista themes?\r
+ uSizeof = REBARBANDINFO_V6_SIZE;\r
+ #endif\r
+ #endif\r
+\r
+ return uSizeof;\r
+ }\r
+\r
+ inline CToolTip* CReBar::GetToolTips() const\r
+ // Retrieves the handle to any ToolTip control associated with the rebar control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (CToolTip*)FromHandle( (HWND)SendMessage(RB_GETTOOLTIPS, 0L, 0L) );\r
+ }\r
+\r
+ inline int CReBar::HitTest(RBHITTESTINFO& rbht)\r
+ // Determines which portion of a rebar band is at a given point on the screen,\r
+ // if a rebar band exists at that point.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(RB_HITTEST, 0L, (LPARAM)&rbht);\r
+ }\r
+\r
+ inline HWND CReBar::HitTest(POINT pt)\r
+ // Return the child HWND at the given point\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ // Convert the point to client co-ordinates\r
+ ScreenToClient(pt);\r
+\r
+ // Get the rebar band with the point\r
+ RBHITTESTINFO rbhti = {0};\r
+ rbhti.pt = pt;\r
+ int iBand = HitTest(rbhti);\r
+\r
+ if (iBand >= 0)\r
+ {\r
+ // Get the rebar band's hWnd\r
+ REBARBANDINFO rbbi = {0};\r
+ rbbi.cbSize = GetSizeofRBBI();\r
+ rbbi.fMask = RBBIM_CHILD;\r
+ GetBandInfo(iBand, rbbi);\r
+\r
+ return rbbi.hwndChild;\r
+ }\r
+ else\r
+ return NULL;\r
+ }\r
+\r
+ inline int CReBar::IDToIndex(UINT uBandID) const\r
+ // Converts a band identifier to a band index in a rebar control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (int)SendMessage(RB_IDTOINDEX, (WPARAM)uBandID, 0L);\r
+ }\r
+\r
+ inline BOOL CReBar::InsertBand(int nBand, REBARBANDINFO& rbbi) const\r
+ // Inserts a new band in a rebar control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ rbbi.cbSize = GetSizeofRBBI();\r
+ return (BOOL)SendMessage(RB_INSERTBAND, nBand, (LPARAM)&rbbi);\r
+ }\r
+\r
+ inline BOOL CReBar::IsBandVisible(int nBand) const\r
+ // Returns true if the band is visible\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ REBARBANDINFO rbbi = {0};\r
+ rbbi.cbSize = GetSizeofRBBI();\r
+ rbbi.fMask = RBBIM_STYLE;\r
+ GetBandInfo(nBand, rbbi);\r
+\r
+ return !(rbbi.fStyle & RBBS_HIDDEN);\r
+ }\r
+\r
+ inline BOOL CReBar::OnEraseBkgnd(CDC* pDC)\r
+ {\r
+ BOOL Erase = TRUE;\r
+ if (!m_Theme.UseThemes)\r
+ Erase = FALSE;\r
+\r
+ if (!m_Theme.clrBkgnd1 && !m_Theme.clrBkgnd2 && !m_Theme.clrBand1 && !m_Theme.clrBand2)\r
+ Erase = FALSE;\r
+\r
+ if (Erase)\r
+ {\r
+ CRect rcReBar = GetClientRect();\r
+ int BarWidth = rcReBar.Width();\r
+ int BarHeight = rcReBar.Height();\r
+\r
+ // Create and set up our memory DC\r
+ CMemDC MemDC(pDC);\r
+ MemDC.CreateCompatibleBitmap(pDC, BarWidth, BarHeight);\r
+\r
+ // Draw to ReBar background to the memory DC\r
+ rcReBar.right = 600;\r
+ MemDC.GradientFill(m_Theme.clrBkgnd1, m_Theme.clrBkgnd2, rcReBar, TRUE);\r
+ if (BarWidth >= 600)\r
+ {\r
+ rcReBar.left = 600;\r
+ rcReBar.right = BarWidth;\r
+ MemDC.SolidFill(m_Theme.clrBkgnd2, rcReBar);\r
+ }\r
+\r
+ if (m_Theme.clrBand1 || m_Theme.clrBand2)\r
+ {\r
+ // Draw the individual band backgrounds\r
+ for (int nBand = 0 ; nBand < GetBandCount(); ++nBand)\r
+ {\r
+ if (IsBandVisible(nBand))\r
+ {\r
+ if (nBand != GetBand(m_hMenuBar))\r
+ {\r
+ // Determine the size of this band\r
+ CRect rcBand = GetBandRect(nBand);\r
+\r
+ // Determine the size of the child window\r
+ REBARBANDINFO rbbi = {0};\r
+ rbbi.cbSize = GetSizeofRBBI();\r
+ rbbi.fMask = RBBIM_CHILD ;\r
+ GetBandInfo(nBand, rbbi);\r
+ CRect rcChild;\r
+ ::GetWindowRect(rbbi.hwndChild, &rcChild);\r
+ int ChildWidth = rcChild.right - rcChild.left;\r
+\r
+ // Determine our drawing rectangle\r
+ CRect rcDraw = rcBand;\r
+ rcDraw.bottom = rcDraw.top + (rcBand.bottom - rcBand.top)/2;\r
+ int xPad = IsXPThemed()? 2: 0;\r
+ rcDraw.left -= xPad;\r
+\r
+ // Fill the Source CDC with the band's background\r
+ CMemDC SourceDC(pDC);\r
+ SourceDC.CreateCompatibleBitmap(pDC, BarWidth, BarHeight);\r
+ CRect rcBorder = GetBandBorders(nBand);\r
+ rcDraw.right = rcBand.left + ChildWidth + rcBorder.left;\r
+ SourceDC.SolidFill(m_Theme.clrBand1, rcDraw);\r
+ rcDraw.top = rcDraw.bottom;\r
+ rcDraw.bottom = rcBand.bottom;\r
+ SourceDC.GradientFill(m_Theme.clrBand1, m_Theme.clrBand2, rcDraw, FALSE);\r
+\r
+ // Set Curve amount for rounded edges\r
+ int Curve = m_Theme.RoundBorders? 12 : 0;\r
+\r
+ // Create our mask for rounded edges using RoundRect\r
+ CMemDC MaskDC(pDC);\r
+ MaskDC.CreateCompatibleBitmap(pDC, BarWidth, BarHeight);\r
+\r
+ rcDraw.top = rcBand.top;\r
+ if (!m_Theme.FlatStyle)\r
+ ::InflateRect(&rcDraw, 1, 1);\r
+\r
+ int left = rcDraw.left;\r
+ int right = rcDraw.right;\r
+ int top = rcDraw.top;\r
+ int bottom = rcDraw.bottom;\r
+ int cx = rcDraw.right - rcBand.left + xPad;\r
+ int cy = rcDraw.bottom - rcBand.top;\r
+\r
+ if (m_Theme.FlatStyle)\r
+ {\r
+ MaskDC.SolidFill(RGB(0,0,0), rcDraw);\r
+ MaskDC.BitBlt(left, top, cx, cy, &MaskDC, left, top, PATINVERT);\r
+ MaskDC.RoundRect(left, top, right, bottom, Curve, Curve);\r
+ }\r
+ else\r
+ {\r
+ MaskDC.SolidFill(RGB(0,0,0), rcDraw);\r
+ MaskDC.RoundRect(left, top, right, bottom, Curve, Curve);\r
+ MaskDC.BitBlt(left, top, cx, cy, &MaskDC, left, top, PATINVERT);\r
+ }\r
+\r
+ // Copy Source DC to Memory DC using the RoundRect mask\r
+ MemDC.BitBlt(left, top, cx, cy, &SourceDC, left, top, SRCINVERT);\r
+ MemDC.BitBlt(left, top, cx, cy, &MaskDC, left, top, SRCAND);\r
+ MemDC.BitBlt(left, top, cx, cy, &SourceDC, left, top, SRCINVERT);\r
+\r
+ // Extra drawing to prevent jagged edge while moving bands\r
+ if (m_bIsDragging)\r
+ {\r
+ CClientDC ReBarDC(this);\r
+ ReBarDC.BitBlt(rcDraw.right - ChildWidth, rcDraw.top, ChildWidth, cy, &MemDC, rcDraw.right - ChildWidth, rcDraw.top, SRCCOPY);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ if (m_Theme.UseLines)\r
+ {\r
+ // Draw lines between bands\r
+ for (int j = 0; j < GetBandCount()-1; ++j)\r
+ {\r
+ rcReBar = GetBandRect(j);\r
+ rcReBar.left = MAX(0, rcReBar.left - 4);\r
+ rcReBar.bottom +=2;\r
+ MemDC.DrawEdge(rcReBar, EDGE_ETCHED, BF_BOTTOM | BF_ADJUST);\r
+ }\r
+ }\r
+\r
+ // Copy the Memory DC to the window's DC\r
+ pDC->BitBlt(0, 0, BarWidth, BarHeight, &MemDC, 0, 0, SRCCOPY);\r
+ }\r
+ \r
+ return Erase;\r
+ }\r
+\r
+ inline void CReBar::PreCreate(CREATESTRUCT &cs)\r
+ // Sets the CREATESTRUCT paramaters prior to window creation\r
+ {\r
+ cs.style = WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |\r
+ CCS_NODIVIDER | RBS_VARHEIGHT | RBS_BANDBORDERS ;\r
+\r
+ cs.cy = 100;\r
+ }\r
+\r
+ inline void CReBar::PreRegisterClass(WNDCLASS &wc)\r
+ {\r
+ // Set the Window Class\r
+ wc.lpszClassName = REBARCLASSNAME;\r
+ }\r
+\r
+ inline void CReBar::MaximizeBand(UINT uBand, BOOL fIdeal /*= FALSE*/)\r
+ // Resizes a band in a rebar control to either its ideal or largest size.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(RB_MAXIMIZEBAND, (WPARAM)uBand, (LPARAM)fIdeal);\r
+ }\r
+\r
+ inline void CReBar::MinimizeBand(UINT uBand)\r
+ // Resizes a band in a rebar control to its smallest size.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ SendMessage(RB_MINIMIZEBAND, (WPARAM)uBand, 0L);\r
+ }\r
+\r
+ inline BOOL CReBar::MoveBand(UINT uFrom, UINT uTo)\r
+ // Moves a band from one index to another.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)SendMessage(RB_MOVEBAND, (WPARAM)uFrom, (LPARAM)uTo);\r
+ }\r
+\r
+ inline void CReBar::MoveBandsLeft()\r
+ // Repositions the bands so they are left justified\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ int OldrcTop = -1;\r
+ for (int nBand = GetBandCount() -1; nBand >= 0; --nBand)\r
+ {\r
+ CRect rc = GetBandRect(nBand);\r
+ if (rc.top != OldrcTop)\r
+ {\r
+ // Maximize the last band on each row\r
+ if (IsBandVisible(nBand))\r
+ {\r
+ ::SendMessage(GetHwnd(), RB_MAXIMIZEBAND, nBand, 0L);\r
+ OldrcTop = rc.top;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ inline BOOL CReBar::ResizeBand(int nBand, const CSize& sz) const\r
+ // Sets a band's size\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ REBARBANDINFO rbbi = {0};\r
+ rbbi.cbSize = GetSizeofRBBI();\r
+ rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_SIZE;\r
+\r
+ GetBandInfo(nBand, rbbi);\r
+ rbbi.cx = sz.cx + 2;\r
+ rbbi.cxMinChild = sz.cx + 2;\r
+ rbbi.cyMinChild = sz.cy;\r
+ rbbi.cyMaxChild = sz.cy;\r
+\r
+ return SetBandInfo(nBand, rbbi );\r
+ }\r
+\r
+ inline BOOL CReBar::SetBandBitmap(int nBand, const CBitmap* pBackground) const\r
+ // Sets the band's bitmaps\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ assert(pBackground);\r
+\r
+ REBARBANDINFO rbbi = {0};\r
+ rbbi.cbSize = GetSizeofRBBI();\r
+ rbbi.fMask = RBBIM_STYLE;\r
+ GetBandInfo(nBand, rbbi);\r
+ rbbi.fMask |= RBBIM_BACKGROUND;\r
+ rbbi.hbmBack = *pBackground;\r
+\r
+ return (BOOL)SendMessage(RB_SETBANDINFO, nBand, (LPARAM)&rbbi);\r
+ }\r
+\r
+ inline BOOL CReBar::SetBandColor(int nBand, COLORREF clrFore, COLORREF clrBack) const\r
+ // Sets the band's color\r
+ // Note: No effect with XP themes enabled\r
+ // No effect if a bitmap has been set\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ REBARBANDINFO rbbi = {0};\r
+ rbbi.cbSize = GetSizeofRBBI();\r
+ rbbi.fMask = RBBIM_COLORS;\r
+ rbbi.clrFore = clrFore;\r
+ rbbi.clrBack = clrBack;\r
+\r
+ return (BOOL)SendMessage(RB_SETBANDINFO, nBand, (LPARAM)&rbbi);\r
+ }\r
+\r
+ inline BOOL CReBar::SetBandInfo(int nBand, REBARBANDINFO& rbbi) const\r
+ // Sets the characteristics of a rebar control.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ assert(nBand >= 0);\r
+\r
+ // REBARBANDINFO describes individual BAND characteristics0\r
+ rbbi.cbSize = GetSizeofRBBI();\r
+ return (BOOL)SendMessage(RB_SETBANDINFO, nBand, (LPARAM)&rbbi);\r
+ }\r
+\r
+ inline BOOL CReBar::SetBarInfo(REBARINFO& rbi) const\r
+ // REBARINFO associates an image list with the rebar\r
+ // A band will also need to set RBBIM_IMAGE\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ rbi.cbSize = GetSizeofRBBI();\r
+ return (BOOL)SendMessage(RB_SETBARINFO, 0L, (LPARAM)&rbi);\r
+ }\r
+\r
+ inline void CReBar::SetReBarTheme(ReBarTheme& Theme)\r
+ {\r
+ m_Theme.UseThemes = Theme.UseThemes;\r
+ m_Theme.clrBkgnd1 = Theme.clrBkgnd1;\r
+ m_Theme.clrBkgnd2 = Theme.clrBkgnd2;\r
+ m_Theme.clrBand1 = Theme.clrBand1;\r
+ m_Theme.clrBand2 = Theme.clrBand2;\r
+ m_Theme.BandsLeft = Theme.BandsLeft;\r
+ m_Theme.LockMenuBand = Theme.LockMenuBand;\r
+ m_Theme.ShortBands = Theme.ShortBands;\r
+ m_Theme.UseLines = Theme.UseLines;\r
+ m_Theme.FlatStyle = Theme.FlatStyle;\r
+ m_Theme.RoundBorders = Theme.RoundBorders;\r
+\r
+ if (IsWindow())\r
+ {\r
+ if (m_Theme.LockMenuBand)\r
+ ShowGripper(GetBand(m_hMenuBar), FALSE);\r
+ else\r
+ ShowGripper(GetBand(m_hMenuBar), TRUE);\r
+ \r
+ Invalidate();\r
+ }\r
+ }\r
+\r
+ inline BOOL CReBar::ShowBand(int nBand, BOOL fShow) const\r
+ // Show or hide a band\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)SendMessage(RB_SHOWBAND, (WPARAM)nBand, (LPARAM)fShow);\r
+ }\r
+\r
+ inline BOOL CReBar::ShowGripper(int nBand, BOOL fShow) const\r
+ // Show or hide the band's gripper\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+\r
+ REBARBANDINFO rbbi = {0};\r
+ rbbi.cbSize = GetSizeofRBBI();\r
+ rbbi.fMask = RBBIM_STYLE;\r
+ GetBandInfo(nBand, rbbi);\r
+ if (fShow)\r
+ {\r
+ rbbi.fStyle |= RBBS_GRIPPERALWAYS;\r
+ rbbi.fStyle &= ~RBBS_NOGRIPPER;\r
+ }\r
+ else\r
+ {\r
+ rbbi.fStyle &= ~RBBS_GRIPPERALWAYS;\r
+ rbbi.fStyle |= RBBS_NOGRIPPER;\r
+ }\r
+\r
+ return SetBandInfo(nBand, rbbi);\r
+ }\r
+\r
+ inline BOOL CReBar::SizeToRect(CRect& rect) const\r
+ // Attempts to find the best layout of the bands for the given rectangle.\r
+ // The rebar bands will be arranged and wrapped as necessary to fit the rectangle.\r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ return (BOOL)SendMessage(RB_SIZETORECT, 0, (LPARAM) (LPRECT)rect);\r
+ }\r
+\r
+ inline void CReBar::SetToolTips(CToolTip* pToolTip) const\r
+ // Associates a ToolTip control with the rebar control. \r
+ {\r
+ assert(::IsWindow(m_hWnd));\r
+ HWND hToolTip = pToolTip? pToolTip->GetHwnd() : (HWND)0;\r
+ SendMessage(RB_SETTOOLTIPS, WPARAM(hToolTip), 0);\r
+ }\r
+\r
+ inline LRESULT CReBar::WndProcDefault(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+ {\r
+ switch (uMsg)\r
+ {\r
+ case WM_MOUSEMOVE:\r
+ if (m_Theme.UseThemes && m_Theme.LockMenuBand)\r
+ {\r
+ // We want to lock the first row in place, but allow other bands to move!\r
+ // Use move messages to limit the resizing of bands\r
+ int y = GET_Y_LPARAM(lParam);\r
+\r
+ if (y <= GetRowHeight(0))\r
+ return 0L; // throw this message away\r
+ }\r
+ break;\r
+ case WM_LBUTTONDOWN:\r
+ m_Orig_lParam = lParam; // Store the x,y position\r
+ m_bIsDragging = TRUE;\r
+ break;\r
+ case WM_LBUTTONUP:\r
+ if (m_Theme.UseThemes && m_Theme.LockMenuBand)\r
+ {\r
+ // Use move messages to limit the resizing of bands\r
+ int y = GET_Y_LPARAM(lParam);\r
+\r
+ if (y <= GetRowHeight(0))\r
+ {\r
+ // Use x,y from WM_LBUTTONDOWN for WM_LBUTTONUP position\r
+ lParam = m_Orig_lParam;\r
+ }\r
+ }\r
+ m_bIsDragging = FALSE;\r
+ break;\r
+ case UWM_GETREBARTHEME:\r
+ {\r
+ ReBarTheme& rm = GetReBarTheme();\r
+ return (LRESULT)&rm;\r
+ }\r
+ case UWM_TOOLBAR_RESIZE:\r
+ {\r
+ HWND hToolBar = (HWND)wParam;\r
+ LPSIZE pToolBarSize = (LPSIZE)lParam;\r
+ ResizeBand(GetBand(hToolBar), *pToolBarSize);\r
+ }\r
+ break;\r
+ }\r
+\r
+ // pass unhandled messages on for default processing\r
+ return CWnd::WndProcDefault(uMsg, wParam, lParam);\r
+ }\r
+\r
+} // namespace Win32xx\r
+\r
+#endif // #ifndef _WIN32XX_REBAR_H_\r