1 // Win32++ Version 7.3
\r
2 // Released: 30th November 2011
\r
6 // url: https://sourceforge.net/projects/win32-framework
\r
9 // Copyright (c) 2005-2011 David Nash
\r
11 // Permission is hereby granted, free of charge, to
\r
12 // any person obtaining a copy of this software and
\r
13 // associated documentation files (the "Software"),
\r
14 // to deal in the Software without restriction, including
\r
15 // without limitation the rights to use, copy, modify,
\r
16 // merge, publish, distribute, sublicense, and/or sell
\r
17 // copies of the Software, and to permit persons to whom
\r
18 // the Software is furnished to do so, subject to the
\r
19 // following conditions:
\r
21 // The above copyright notice and this permission notice
\r
22 // shall be included in all copies or substantial portions
\r
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
\r
26 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
\r
27 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
\r
28 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
\r
29 // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
\r
30 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
31 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
32 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
\r
33 // OR OTHER DEALINGS IN THE SOFTWARE.
\r
35 ////////////////////////////////////////////////////////
\r
38 #ifndef _WIN32XX_REBAR_H_
\r
39 #define _WIN32XX_REBAR_H_
\r
41 #include "wincore.h"
\r
43 #include "controls.h"
\r
50 BOOL UseThemes; // TRUE if themes are used
\r
51 COLORREF clrBkgnd1; // Colour 1 for rebar background
\r
52 COLORREF clrBkgnd2; // Colour 2 for rebar background
\r
53 COLORREF clrBand1; // Colour 1 for rebar band background. Use NULL if not required
\r
54 COLORREF clrBand2; // Colour 2 for rebar band background. Use NULL if not required
\r
55 BOOL FlatStyle; // Bands are rendered with flat rather than raised style
\r
56 BOOL BandsLeft; // Position bands left on rearrange
\r
57 BOOL LockMenuBand; // Lock MenuBar's band in dedicated top row, without gripper
\r
58 BOOL RoundBorders; // Use rounded band borders
\r
59 BOOL ShortBands; // Allows bands to be shorter than maximum available width
\r
60 BOOL UseLines; // Displays horizontal lines between bands
\r
63 ////////////////////////////////////
\r
64 // Declaration of the CReBar class
\r
66 class CReBar : public CWnd
\r
73 BOOL DeleteBand(const int nBand) const;
\r
74 int HitTest(RBHITTESTINFO& rbht);
\r
75 HWND HitTest(POINT pt);
\r
76 int IDToIndex(UINT uBandID) const;
\r
77 BOOL InsertBand(const int nBand, REBARBANDINFO& rbbi) const;
\r
78 BOOL IsBandVisible(int nBand) const;
\r
79 void MaximizeBand(UINT uBand, BOOL fIdeal = FALSE);
\r
80 void MinimizeBand(UINT uBand);
\r
81 BOOL MoveBand(UINT uFrom, UINT uTo);
\r
82 void MoveBandsLeft();
\r
83 BOOL ResizeBand(const int nBand, const CSize& sz) const;
\r
84 BOOL ShowGripper(int nBand, BOOL fShow) const;
\r
85 BOOL ShowBand(int nBand, BOOL fShow) const;
\r
86 BOOL SizeToRect(CRect& rect) const;
\r
89 int GetBand(const HWND hWnd) const;
\r
90 CRect GetBandBorders(int nBand) const;
\r
91 int GetBandCount() const;
\r
92 BOOL GetBandInfo(const int nBand, REBARBANDINFO& rbbi) const;
\r
93 CRect GetBandRect(int i) const;
\r
94 UINT GetBarHeight() const;
\r
95 BOOL GetBarInfo(REBARINFO& rbi) const;
\r
96 HWND GetMenuBar() {return m_hMenuBar;}
\r
97 ReBarTheme& GetReBarTheme() {return m_Theme;}
\r
98 UINT GetRowCount() const;
\r
99 int GetRowHeight(int nRow) const;
\r
100 UINT GetSizeofRBBI() const;
\r
101 CToolTip* GetToolTips() const;
\r
102 BOOL SetBandBitmap(const int nBand, const CBitmap* pBackground) const;
\r
103 BOOL SetBandColor(const int nBand, const COLORREF clrFore, const COLORREF clrBack) const;
\r
104 BOOL SetBandInfo(const int nBand, REBARBANDINFO& rbbi) const;
\r
105 BOOL SetBarInfo(REBARINFO& rbi) const;
\r
106 void SetMenuBar(HWND hMenuBar) {m_hMenuBar = hMenuBar;}
\r
107 void SetReBarTheme(ReBarTheme& Theme);
\r
108 void SetToolTips(CToolTip* pToolTip) const;
\r
112 virtual BOOL OnEraseBkgnd(CDC* pDC);
\r
113 virtual void PreCreate(CREATESTRUCT& cs);
\r
114 virtual void PreRegisterClass(WNDCLASS &wc);
\r
115 virtual LRESULT WndProcDefault(UINT uMsg, WPARAM wParam, LPARAM lParam);
\r
118 CReBar(const CReBar&); // Disable copy construction
\r
119 CReBar& operator = (const CReBar&); // Disable assignment operator
\r
121 ReBarTheme m_Theme;
\r
122 BOOL m_bIsDragging;
\r
124 LPARAM m_Orig_lParam;
\r
129 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\r
135 ///////////////////////////////////
\r
136 // Definitions for the CReBar class
\r
138 inline CReBar::CReBar() : m_bIsDragging(FALSE), m_hMenuBar(0), m_Orig_lParam(0L)
\r
140 ZeroMemory(&m_Theme, sizeof(ReBarTheme));
\r
143 inline CReBar::~CReBar()
\r
147 inline BOOL CReBar::DeleteBand(int nBand) const
\r
148 // Deletes a band from a rebar control.
\r
150 assert(::IsWindow(m_hWnd));
\r
151 return (BOOL)SendMessage(RB_DELETEBAND, nBand, 0L);
\r
154 inline int CReBar::GetBand(HWND hWnd) const
\r
155 // Returns the zero based band number for this window handle
\r
157 assert(::IsWindow(m_hWnd));
\r
160 if (NULL == hWnd) return nResult;
\r
162 for (int nBand = 0; nBand < GetBandCount(); ++nBand)
\r
164 REBARBANDINFO rbbi = {0};
\r
165 rbbi.cbSize = GetSizeofRBBI();
\r
166 rbbi.fMask = RBBIM_CHILD;
\r
167 GetBandInfo(nBand, rbbi);
\r
168 if (rbbi.hwndChild == hWnd)
\r
175 inline CRect CReBar::GetBandBorders(int nBand) const
\r
176 // Retrieves the borders of a band.
\r
178 assert(::IsWindow(m_hWnd));
\r
181 SendMessage(RB_GETBANDBORDERS, nBand, (LPARAM)&rc);
\r
185 inline int CReBar::GetBandCount() const
\r
186 // Retrieves the count of bands currently in the rebar control.
\r
188 assert(::IsWindow(m_hWnd));
\r
189 return (int)SendMessage(RB_GETBANDCOUNT, 0L, 0L);
\r
192 inline BOOL CReBar::GetBandInfo(int nBand, REBARBANDINFO& rbbi) const
\r
193 // Retrieves information about a specified band in a rebar control.
\r
195 assert(::IsWindow(m_hWnd));
\r
196 assert(nBand >= 0);
\r
198 // REBARBANDINFO describes individual BAND characteristics
\r
199 rbbi.cbSize = GetSizeofRBBI();
\r
200 return (BOOL)SendMessage(RB_GETBANDINFO, nBand, (LPARAM)&rbbi);
\r
203 inline CRect CReBar::GetBandRect(int i) const
\r
204 // Retrieves the bounding rectangle for a given band in a rebar control.
\r
206 assert(::IsWindow(m_hWnd));
\r
208 SendMessage(RB_GETRECT, i, (LPARAM)&rc);
\r
212 inline UINT CReBar::GetBarHeight() const
\r
213 // Retrieves the height of the rebar control.
\r
215 assert(::IsWindow(m_hWnd));
\r
216 return (UINT)SendMessage(RB_GETBARHEIGHT, 0L, 0L);
\r
219 inline BOOL CReBar::GetBarInfo(REBARINFO& rbi) const
\r
220 // Retrieves information about the rebar control and the image list it uses.
\r
222 assert(::IsWindow(m_hWnd));
\r
224 // REBARINFO describes overall rebar control characteristics
\r
225 rbi.cbSize = GetSizeofRBBI();
\r
226 return (BOOL)SendMessage(RB_GETBARINFO, 0L, (LPARAM)&rbi);
\r
229 inline UINT CReBar::GetRowCount() const
\r
230 // Retrieves the number of rows of bands in a rebar control.
\r
232 assert(::IsWindow(m_hWnd));
\r
233 return (UINT)SendMessage(RB_GETROWCOUNT, 0L, 0L);
\r
236 inline int CReBar::GetRowHeight(int nRow) const
\r
237 // Retrieves the height of a specified row in a rebar control.
\r
239 assert(::IsWindow(m_hWnd));
\r
240 return (int)SendMessage(RB_GETROWHEIGHT, nRow, 0L);
\r
243 inline UINT CReBar::GetSizeofRBBI() const
\r
244 // The size of the REBARBANDINFO struct changes according to _WIN32_WINNT
\r
245 // sizeof(REBARBANDINFO) can report an incorrect size for older Window versions,
\r
246 // or newer Window version without XP themes enabled.
\r
247 // Use this function to get a safe size for REBARBANDINFO.
\r
249 assert(::IsWindow(m_hWnd));
\r
251 UINT uSizeof = sizeof(REBARBANDINFO);
\r
253 #if defined REBARBANDINFO_V6_SIZE // only defined for VS2008 or higher
\r
254 #if !defined (_WIN32_WINNT) || _WIN32_WINNT >= 0x0600
\r
255 if ((GetWinVersion() < 2600) || (GetComCtlVersion() < 610)) // Vista and Vista themes?
\r
256 uSizeof = REBARBANDINFO_V6_SIZE;
\r
263 inline CToolTip* CReBar::GetToolTips() const
\r
264 // Retrieves the handle to any ToolTip control associated with the rebar control.
\r
266 assert(::IsWindow(m_hWnd));
\r
267 return (CToolTip*)FromHandle( (HWND)SendMessage(RB_GETTOOLTIPS, 0L, 0L) );
\r
270 inline int CReBar::HitTest(RBHITTESTINFO& rbht)
\r
271 // Determines which portion of a rebar band is at a given point on the screen,
\r
272 // if a rebar band exists at that point.
\r
274 assert(::IsWindow(m_hWnd));
\r
275 return (int)SendMessage(RB_HITTEST, 0L, (LPARAM)&rbht);
\r
278 inline HWND CReBar::HitTest(POINT pt)
\r
279 // Return the child HWND at the given point
\r
281 assert(::IsWindow(m_hWnd));
\r
283 // Convert the point to client co-ordinates
\r
284 ScreenToClient(pt);
\r
286 // Get the rebar band with the point
\r
287 RBHITTESTINFO rbhti = {0};
\r
289 int iBand = HitTest(rbhti);
\r
293 // Get the rebar band's hWnd
\r
294 REBARBANDINFO rbbi = {0};
\r
295 rbbi.cbSize = GetSizeofRBBI();
\r
296 rbbi.fMask = RBBIM_CHILD;
\r
297 GetBandInfo(iBand, rbbi);
\r
299 return rbbi.hwndChild;
\r
305 inline int CReBar::IDToIndex(UINT uBandID) const
\r
306 // Converts a band identifier to a band index in a rebar control.
\r
308 assert(::IsWindow(m_hWnd));
\r
309 return (int)SendMessage(RB_IDTOINDEX, (WPARAM)uBandID, 0L);
\r
312 inline BOOL CReBar::InsertBand(int nBand, REBARBANDINFO& rbbi) const
\r
313 // Inserts a new band in a rebar control.
\r
315 assert(::IsWindow(m_hWnd));
\r
317 rbbi.cbSize = GetSizeofRBBI();
\r
318 return (BOOL)SendMessage(RB_INSERTBAND, nBand, (LPARAM)&rbbi);
\r
321 inline BOOL CReBar::IsBandVisible(int nBand) const
\r
322 // Returns true if the band is visible
\r
324 assert(::IsWindow(m_hWnd));
\r
326 REBARBANDINFO rbbi = {0};
\r
327 rbbi.cbSize = GetSizeofRBBI();
\r
328 rbbi.fMask = RBBIM_STYLE;
\r
329 GetBandInfo(nBand, rbbi);
\r
331 return !(rbbi.fStyle & RBBS_HIDDEN);
\r
334 inline BOOL CReBar::OnEraseBkgnd(CDC* pDC)
\r
337 if (!m_Theme.UseThemes)
\r
340 if (!m_Theme.clrBkgnd1 && !m_Theme.clrBkgnd2 && !m_Theme.clrBand1 && !m_Theme.clrBand2)
\r
345 CRect rcReBar = GetClientRect();
\r
346 int BarWidth = rcReBar.Width();
\r
347 int BarHeight = rcReBar.Height();
\r
349 // Create and set up our memory DC
\r
351 MemDC.CreateCompatibleBitmap(pDC, BarWidth, BarHeight);
\r
353 // Draw to ReBar background to the memory DC
\r
354 rcReBar.right = 600;
\r
355 MemDC.GradientFill(m_Theme.clrBkgnd1, m_Theme.clrBkgnd2, rcReBar, TRUE);
\r
356 if (BarWidth >= 600)
\r
358 rcReBar.left = 600;
\r
359 rcReBar.right = BarWidth;
\r
360 MemDC.SolidFill(m_Theme.clrBkgnd2, rcReBar);
\r
363 if (m_Theme.clrBand1 || m_Theme.clrBand2)
\r
365 // Draw the individual band backgrounds
\r
366 for (int nBand = 0 ; nBand < GetBandCount(); ++nBand)
\r
368 if (IsBandVisible(nBand))
\r
370 if (nBand != GetBand(m_hMenuBar))
\r
372 // Determine the size of this band
\r
373 CRect rcBand = GetBandRect(nBand);
\r
375 // Determine the size of the child window
\r
376 REBARBANDINFO rbbi = {0};
\r
377 rbbi.cbSize = GetSizeofRBBI();
\r
378 rbbi.fMask = RBBIM_CHILD ;
\r
379 GetBandInfo(nBand, rbbi);
\r
381 ::GetWindowRect(rbbi.hwndChild, &rcChild);
\r
382 int ChildWidth = rcChild.right - rcChild.left;
\r
384 // Determine our drawing rectangle
\r
385 CRect rcDraw = rcBand;
\r
386 rcDraw.bottom = rcDraw.top + (rcBand.bottom - rcBand.top)/2;
\r
387 int xPad = IsXPThemed()? 2: 0;
\r
388 rcDraw.left -= xPad;
\r
390 // Fill the Source CDC with the band's background
\r
391 CMemDC SourceDC(pDC);
\r
392 SourceDC.CreateCompatibleBitmap(pDC, BarWidth, BarHeight);
\r
393 CRect rcBorder = GetBandBorders(nBand);
\r
394 rcDraw.right = rcBand.left + ChildWidth + rcBorder.left;
\r
395 SourceDC.SolidFill(m_Theme.clrBand1, rcDraw);
\r
396 rcDraw.top = rcDraw.bottom;
\r
397 rcDraw.bottom = rcBand.bottom;
\r
398 SourceDC.GradientFill(m_Theme.clrBand1, m_Theme.clrBand2, rcDraw, FALSE);
\r
400 // Set Curve amount for rounded edges
\r
401 int Curve = m_Theme.RoundBorders? 12 : 0;
\r
403 // Create our mask for rounded edges using RoundRect
\r
404 CMemDC MaskDC(pDC);
\r
405 MaskDC.CreateCompatibleBitmap(pDC, BarWidth, BarHeight);
\r
407 rcDraw.top = rcBand.top;
\r
408 if (!m_Theme.FlatStyle)
\r
409 ::InflateRect(&rcDraw, 1, 1);
\r
411 int left = rcDraw.left;
\r
412 int right = rcDraw.right;
\r
413 int top = rcDraw.top;
\r
414 int bottom = rcDraw.bottom;
\r
415 int cx = rcDraw.right - rcBand.left + xPad;
\r
416 int cy = rcDraw.bottom - rcBand.top;
\r
418 if (m_Theme.FlatStyle)
\r
420 MaskDC.SolidFill(RGB(0,0,0), rcDraw);
\r
421 MaskDC.BitBlt(left, top, cx, cy, &MaskDC, left, top, PATINVERT);
\r
422 MaskDC.RoundRect(left, top, right, bottom, Curve, Curve);
\r
426 MaskDC.SolidFill(RGB(0,0,0), rcDraw);
\r
427 MaskDC.RoundRect(left, top, right, bottom, Curve, Curve);
\r
428 MaskDC.BitBlt(left, top, cx, cy, &MaskDC, left, top, PATINVERT);
\r
431 // Copy Source DC to Memory DC using the RoundRect mask
\r
432 MemDC.BitBlt(left, top, cx, cy, &SourceDC, left, top, SRCINVERT);
\r
433 MemDC.BitBlt(left, top, cx, cy, &MaskDC, left, top, SRCAND);
\r
434 MemDC.BitBlt(left, top, cx, cy, &SourceDC, left, top, SRCINVERT);
\r
436 // Extra drawing to prevent jagged edge while moving bands
\r
439 CClientDC ReBarDC(this);
\r
440 ReBarDC.BitBlt(rcDraw.right - ChildWidth, rcDraw.top, ChildWidth, cy, &MemDC, rcDraw.right - ChildWidth, rcDraw.top, SRCCOPY);
\r
447 if (m_Theme.UseLines)
\r
449 // Draw lines between bands
\r
450 for (int j = 0; j < GetBandCount()-1; ++j)
\r
452 rcReBar = GetBandRect(j);
\r
453 rcReBar.left = MAX(0, rcReBar.left - 4);
\r
454 rcReBar.bottom +=2;
\r
455 MemDC.DrawEdge(rcReBar, EDGE_ETCHED, BF_BOTTOM | BF_ADJUST);
\r
459 // Copy the Memory DC to the window's DC
\r
460 pDC->BitBlt(0, 0, BarWidth, BarHeight, &MemDC, 0, 0, SRCCOPY);
\r
466 inline void CReBar::PreCreate(CREATESTRUCT &cs)
\r
467 // Sets the CREATESTRUCT paramaters prior to window creation
\r
469 cs.style = WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |
\r
470 CCS_NODIVIDER | RBS_VARHEIGHT | RBS_BANDBORDERS ;
\r
475 inline void CReBar::PreRegisterClass(WNDCLASS &wc)
\r
477 // Set the Window Class
\r
478 wc.lpszClassName = REBARCLASSNAME;
\r
481 inline void CReBar::MaximizeBand(UINT uBand, BOOL fIdeal /*= FALSE*/)
\r
482 // Resizes a band in a rebar control to either its ideal or largest size.
\r
484 assert(::IsWindow(m_hWnd));
\r
485 SendMessage(RB_MAXIMIZEBAND, (WPARAM)uBand, (LPARAM)fIdeal);
\r
488 inline void CReBar::MinimizeBand(UINT uBand)
\r
489 // Resizes a band in a rebar control to its smallest size.
\r
491 assert(::IsWindow(m_hWnd));
\r
492 SendMessage(RB_MINIMIZEBAND, (WPARAM)uBand, 0L);
\r
495 inline BOOL CReBar::MoveBand(UINT uFrom, UINT uTo)
\r
496 // Moves a band from one index to another.
\r
498 assert(::IsWindow(m_hWnd));
\r
499 return (BOOL)SendMessage(RB_MOVEBAND, (WPARAM)uFrom, (LPARAM)uTo);
\r
502 inline void CReBar::MoveBandsLeft()
\r
503 // Repositions the bands so they are left justified
\r
505 assert(::IsWindow(m_hWnd));
\r
508 for (int nBand = GetBandCount() -1; nBand >= 0; --nBand)
\r
510 CRect rc = GetBandRect(nBand);
\r
511 if (rc.top != OldrcTop)
\r
513 // Maximize the last band on each row
\r
514 if (IsBandVisible(nBand))
\r
516 ::SendMessage(GetHwnd(), RB_MAXIMIZEBAND, nBand, 0L);
\r
523 inline BOOL CReBar::ResizeBand(int nBand, const CSize& sz) const
\r
524 // Sets a band's size
\r
526 assert(::IsWindow(m_hWnd));
\r
528 REBARBANDINFO rbbi = {0};
\r
529 rbbi.cbSize = GetSizeofRBBI();
\r
530 rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_SIZE;
\r
532 GetBandInfo(nBand, rbbi);
\r
533 rbbi.cx = sz.cx + 2;
\r
534 rbbi.cxMinChild = sz.cx + 2;
\r
535 rbbi.cyMinChild = sz.cy;
\r
536 rbbi.cyMaxChild = sz.cy;
\r
538 return SetBandInfo(nBand, rbbi );
\r
541 inline BOOL CReBar::SetBandBitmap(int nBand, const CBitmap* pBackground) const
\r
542 // Sets the band's bitmaps
\r
544 assert(::IsWindow(m_hWnd));
\r
545 assert(pBackground);
\r
547 REBARBANDINFO rbbi = {0};
\r
548 rbbi.cbSize = GetSizeofRBBI();
\r
549 rbbi.fMask = RBBIM_STYLE;
\r
550 GetBandInfo(nBand, rbbi);
\r
551 rbbi.fMask |= RBBIM_BACKGROUND;
\r
552 rbbi.hbmBack = *pBackground;
\r
554 return (BOOL)SendMessage(RB_SETBANDINFO, nBand, (LPARAM)&rbbi);
\r
557 inline BOOL CReBar::SetBandColor(int nBand, COLORREF clrFore, COLORREF clrBack) const
\r
558 // Sets the band's color
\r
559 // Note: No effect with XP themes enabled
\r
560 // No effect if a bitmap has been set
\r
562 assert(::IsWindow(m_hWnd));
\r
564 REBARBANDINFO rbbi = {0};
\r
565 rbbi.cbSize = GetSizeofRBBI();
\r
566 rbbi.fMask = RBBIM_COLORS;
\r
567 rbbi.clrFore = clrFore;
\r
568 rbbi.clrBack = clrBack;
\r
570 return (BOOL)SendMessage(RB_SETBANDINFO, nBand, (LPARAM)&rbbi);
\r
573 inline BOOL CReBar::SetBandInfo(int nBand, REBARBANDINFO& rbbi) const
\r
574 // Sets the characteristics of a rebar control.
\r
576 assert(::IsWindow(m_hWnd));
\r
577 assert(nBand >= 0);
\r
579 // REBARBANDINFO describes individual BAND characteristics0
\r
580 rbbi.cbSize = GetSizeofRBBI();
\r
581 return (BOOL)SendMessage(RB_SETBANDINFO, nBand, (LPARAM)&rbbi);
\r
584 inline BOOL CReBar::SetBarInfo(REBARINFO& rbi) const
\r
585 // REBARINFO associates an image list with the rebar
\r
586 // A band will also need to set RBBIM_IMAGE
\r
588 assert(::IsWindow(m_hWnd));
\r
590 rbi.cbSize = GetSizeofRBBI();
\r
591 return (BOOL)SendMessage(RB_SETBARINFO, 0L, (LPARAM)&rbi);
\r
594 inline void CReBar::SetReBarTheme(ReBarTheme& Theme)
\r
596 m_Theme.UseThemes = Theme.UseThemes;
\r
597 m_Theme.clrBkgnd1 = Theme.clrBkgnd1;
\r
598 m_Theme.clrBkgnd2 = Theme.clrBkgnd2;
\r
599 m_Theme.clrBand1 = Theme.clrBand1;
\r
600 m_Theme.clrBand2 = Theme.clrBand2;
\r
601 m_Theme.BandsLeft = Theme.BandsLeft;
\r
602 m_Theme.LockMenuBand = Theme.LockMenuBand;
\r
603 m_Theme.ShortBands = Theme.ShortBands;
\r
604 m_Theme.UseLines = Theme.UseLines;
\r
605 m_Theme.FlatStyle = Theme.FlatStyle;
\r
606 m_Theme.RoundBorders = Theme.RoundBorders;
\r
610 if (m_Theme.LockMenuBand)
\r
611 ShowGripper(GetBand(m_hMenuBar), FALSE);
\r
613 ShowGripper(GetBand(m_hMenuBar), TRUE);
\r
619 inline BOOL CReBar::ShowBand(int nBand, BOOL fShow) const
\r
620 // Show or hide a band
\r
622 assert(::IsWindow(m_hWnd));
\r
623 return (BOOL)SendMessage(RB_SHOWBAND, (WPARAM)nBand, (LPARAM)fShow);
\r
626 inline BOOL CReBar::ShowGripper(int nBand, BOOL fShow) const
\r
627 // Show or hide the band's gripper
\r
629 assert(::IsWindow(m_hWnd));
\r
631 REBARBANDINFO rbbi = {0};
\r
632 rbbi.cbSize = GetSizeofRBBI();
\r
633 rbbi.fMask = RBBIM_STYLE;
\r
634 GetBandInfo(nBand, rbbi);
\r
637 rbbi.fStyle |= RBBS_GRIPPERALWAYS;
\r
638 rbbi.fStyle &= ~RBBS_NOGRIPPER;
\r
642 rbbi.fStyle &= ~RBBS_GRIPPERALWAYS;
\r
643 rbbi.fStyle |= RBBS_NOGRIPPER;
\r
646 return SetBandInfo(nBand, rbbi);
\r
649 inline BOOL CReBar::SizeToRect(CRect& rect) const
\r
650 // Attempts to find the best layout of the bands for the given rectangle.
\r
651 // The rebar bands will be arranged and wrapped as necessary to fit the rectangle.
\r
653 assert(::IsWindow(m_hWnd));
\r
654 return (BOOL)SendMessage(RB_SIZETORECT, 0, (LPARAM) (LPRECT)rect);
\r
657 inline void CReBar::SetToolTips(CToolTip* pToolTip) const
\r
658 // Associates a ToolTip control with the rebar control.
\r
660 assert(::IsWindow(m_hWnd));
\r
661 HWND hToolTip = pToolTip? pToolTip->GetHwnd() : (HWND)0;
\r
662 SendMessage(RB_SETTOOLTIPS, WPARAM(hToolTip), 0);
\r
665 inline LRESULT CReBar::WndProcDefault(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
670 if (m_Theme.UseThemes && m_Theme.LockMenuBand)
\r
672 // We want to lock the first row in place, but allow other bands to move!
\r
673 // Use move messages to limit the resizing of bands
\r
674 int y = GET_Y_LPARAM(lParam);
\r
676 if (y <= GetRowHeight(0))
\r
677 return 0L; // throw this message away
\r
680 case WM_LBUTTONDOWN:
\r
681 m_Orig_lParam = lParam; // Store the x,y position
\r
682 m_bIsDragging = TRUE;
\r
685 if (m_Theme.UseThemes && m_Theme.LockMenuBand)
\r
687 // Use move messages to limit the resizing of bands
\r
688 int y = GET_Y_LPARAM(lParam);
\r
690 if (y <= GetRowHeight(0))
\r
692 // Use x,y from WM_LBUTTONDOWN for WM_LBUTTONUP position
\r
693 lParam = m_Orig_lParam;
\r
696 m_bIsDragging = FALSE;
\r
698 case UWM_GETREBARTHEME:
\r
700 ReBarTheme& rm = GetReBarTheme();
\r
701 return (LRESULT)&rm;
\r
703 case UWM_TOOLBAR_RESIZE:
\r
705 HWND hToolBar = (HWND)wParam;
\r
706 LPSIZE pToolBarSize = (LPSIZE)lParam;
\r
707 ResizeBand(GetBand(hToolBar), *pToolBarSize);
\r
712 // pass unhandled messages on for default processing
\r
713 return CWnd::WndProcDefault(uMsg, wParam, lParam);
\r
716 } // namespace Win32xx
\r
718 #endif // #ifndef _WIN32XX_REBAR_H_
\r