Print Page | Close Window

Enable Visual Studio 2015 theme to HeaderCtrl

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=22994
Printed Date: 29 April 2024 at 7:53am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Enable Visual Studio 2015 theme to HeaderCtrl
Posted By: JoseAngel
Subject: Enable Visual Studio 2015 theme to HeaderCtrl
Date Posted: 11 April 2016 at 8:01am
I just added Visual Studio 2015 support for HeaderCtrl (maybe it doesn't contemplate all the cases, but for me is enought).
If you want to add it, follow the next steps:

1. Add this section to VisualStudio2015Dark.ini

[HeaderCtrl]
Back=37 37 38
Border=63 63 70
Text=246 246 246

2. Add this section to VisualStudio2015Light.ini

[HeaderCtrl]
Back=245 245 245
Border=204 206 219
Text=66 66 66

3. Add this section to VisualStudio2015Blue.ini

[HeaderCtrl]
Back=246 246 246
Border=204 206 219
Text=66 66 66

4. Compile VisualStudio2015 solution.

5. Add this case in CXTPHeaderCtrl::SetTheme

 case xtpControlThemeVisualStudio2015:
  m_pTheme = new CXTPHeaderCtrlThemeVisualStudio2015;
  break;

6. Add this class definition to XTPHeaderCtrlTheme.h

class _XTP_EXT_CLASS CXTPHeaderCtrlThemeVisualStudio2015 : public CXTPHeaderCtrlTheme
{
public:
 CXTPHeaderCtrlThemeVisualStudio2015();
 virtual ~CXTPHeaderCtrlThemeVisualStudio2015();

protected:
 virtual void RefreshMetrics(CXTPHeaderCtrl* pHeader);
 virtual void OnDrawBackground(LPDRAWITEMSTRUCT lpDIS);
 virtual void OnDrawItemBackground(LPDRAWITEMSTRUCT lpDIS);
};

7. Add this lines to XTPHeaderCtrlTheme.cpp

CXTPHeaderCtrlThemeVisualStudio2015::CXTPHeaderCtrlThemeVisualStudio2015()
{
 m_nTheme = xtpControlThemeVisualStudio2015;
 m_dwDrawStyle = HDR_XTP_SORTARROW;
}

CXTPHeaderCtrlThemeVisualStudio2015::~CXTPHeaderCtrlThemeVisualStudio2015()
{
}

void CXTPHeaderCtrlThemeVisualStudio2015::RefreshMetrics(CXTPHeaderCtrl* pHeader)
{
 CXTPHeaderCtrlTheme::RefreshMetrics(pHeader);

 m_cr3DFace = XTPIniColor(_T("HeaderCtrl"), _T("Back"), RGB(37, 37, 38));
 m_cr3DHighLight = XTPIniColor(_T("HeaderCtrl"), _T("Border"), RGB(63, 63, 70));
 m_crText = XTPIniColor(_T("HeaderCtrl"), _T("Text"), RGB(255, 255, 255));
}

void CXTPHeaderCtrlThemeVisualStudio2015::OnDrawBackground(LPDRAWITEMSTRUCT lpDIS)
{
 CRect rcItem(lpDIS->rcItem);
 CDC* pDC = CDC::FromHandle(lpDIS->hDC);

 // fill background
 pDC->FillSolidRect(&rcItem, m_cr3DFace);
 rcItem.right += 2;

 // draw bottom border.
 CXTPPenDC penDC(lpDIS->hDC, m_cr3DHighLight);
 pDC->MoveTo(rcItem.left, rcItem.bottom - 1);
 pDC->LineTo(rcItem.right, rcItem.bottom - 1);
}

void CXTPHeaderCtrlThemeVisualStudio2015::OnDrawItemBackground(LPDRAWITEMSTRUCT lpDIS)
{
 CDC* pDC = CDC::FromHandle(lpDIS->hDC);

 CXTPPenDC penDC(lpDIS->hDC, m_cr3DHighLight);
 pDC->MoveTo(lpDIS->rcItem.right - 1, 2);
 pDC->LineTo(lpDIS->rcItem.right - 1, lpDIS->rcItem.bottom - 2);
}

And voila.








Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net