@@ -90,9 +90,11 @@ static inline COLORREF getTextColor()
90
90
return GetSysColor (COLOR_WINDOWTEXT);
91
91
}
92
92
93
- static COLORREF getBackColor ()
93
+ static COLORREF getBackColor (bool onTitleBar )
94
94
{
95
95
const COLORREF clr = GetSysColor (COLOR_3DFACE);
96
+ if (!onTitleBar)
97
+ return clr;
96
98
return RGB (GetRValue (clr), std::clamp (GetGValue (clr) + 8 , 0 , 255 ), std::clamp (GetBValue (clr) + 8 , 0 , 255 ));
97
99
}
98
100
@@ -132,7 +134,7 @@ BOOL CMyTabCtrl::OnEraseBkgnd(CDC* pDC)
132
134
{
133
135
CRect rClient;
134
136
GetClientRect (rClient);
135
- pDC->FillSolidRect (rClient, getBackColor ());
137
+ pDC->FillSolidRect (rClient, getBackColor (m_bOnTitleBar ));
136
138
return TRUE ;
137
139
}
138
140
@@ -357,17 +359,17 @@ void CMyTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
357
359
CRect rc = lpDraw->rcItem ;
358
360
if (lpDraw->itemState & ODS_SELECTED)
359
361
{
360
- const COLORREF clrShadow = CEColor::GetIntermediateColor (GetSysColor (COLOR_3DSHADOW), getBackColor (), 0 .5f );
362
+ const COLORREF clrShadow = CEColor::GetIntermediateColor (GetSysColor (COLOR_3DSHADOW), getBackColor (m_bOnTitleBar ), 0 .5f );
361
363
if (GetSysColor (COLOR_3DFACE) == GetSysColor (COLOR_WINDOW))
362
364
{
363
365
DrawRoundedRectWithShadow (lpDraw->hDC , rc.left + sw, rc.top + sw - 1 , rc.Width () - sw * 2 , rc.top - sw * 2 + 2 , r, sw,
364
- GetSysColor (COLOR_HIGHLIGHT), clrShadow, getBackColor ());
366
+ GetSysColor (COLOR_HIGHLIGHT), clrShadow, getBackColor (m_bOnTitleBar ));
365
367
SetTextColor (lpDraw->hDC , GetSysColor (COLOR_HIGHLIGHTTEXT));
366
368
}
367
369
else
368
370
{
369
371
DrawRoundedRectWithShadow (lpDraw->hDC , rc.left + sw, rc.top + sw - 1 , rc.Width () - sw * 2 , rc.Height () - sw * 2 + 2 , r, sw,
370
- GetSysColor (COLOR_WINDOW), clrShadow, getBackColor ());
372
+ GetSysColor (COLOR_WINDOW), clrShadow, getBackColor (m_bOnTitleBar ));
371
373
SetTextColor (lpDraw->hDC , getTextColor ());
372
374
}
373
375
}
@@ -613,6 +615,7 @@ BOOL CMDITabBar::Update(bool bOnTitleBar, bool bMaximized)
613
615
if (m_bMaximized)
614
616
AfxGetMainWnd ()->GetWindowRect (&rc);
615
617
m_top = rc.top ;
618
+ m_tabCtrl.SetOnTitleBar (bOnTitleBar);
616
619
return true ;
617
620
}
618
621
@@ -731,7 +734,7 @@ BOOL CMDITabBar::OnEraseBkgnd(CDC* pDC)
731
734
{
732
735
CRect rClient;
733
736
GetClientRect (rClient);
734
- pDC->FillSolidRect (rClient, getBackColor ());
737
+ pDC->FillSolidRect (rClient, getBackColor (m_bOnTitleBar ));
735
738
return TRUE ;
736
739
}
737
740
@@ -741,5 +744,5 @@ void CMDITabBar::OnPaint()
741
744
return __super::OnPaint ();
742
745
CPaintDC dc (this );
743
746
m_titleBar.DrawIcon (AfxGetMainWnd (), dc);
744
- m_titleBar.DrawButtons (dc, getTextColor (), getBackColor ());
747
+ m_titleBar.DrawButtons (dc, getTextColor (), getBackColor (m_bOnTitleBar ));
745
748
}
0 commit comments