Print Page | Close Window

CXTPTabControl - Set single tab color

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=18457
Printed Date: 25 June 2025 at 2:18am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPTabControl - Set single tab color
Posted By: Marco1
Subject: CXTPTabControl - Set single tab color
Date Posted: 27 May 2011 at 6:34am
Problem is to set the color background of a single tab in CXTPTabControl.

Tab control is themed via:
wndTabControl.GetPaintManager()->SetAppearance(xtpTabAppearancePropertyPageFlat);
wndTabControl.GetPaintManager()->SetColor(xtpTabColorOffice2003);
wndTabControl.GetPaintManager()->DisableLunaColors(FALSE);

Now I try setting a single tab backgroud to red via:
wndTabControl.GetItem(3)->SetColor(RGB(0xFF, 0x00, 0x00));

But tab backgroud remains unchanged. Any advice?



-------------
Product: XTP 18.3.0 on VS 2017
Platform: VS 2017 / Windows 10 (64bit)



Replies:
Posted By: mgampi
Date Posted: 27 May 2011 at 7:58am
Hi;

Try to handle

ON_MESSAGE(WM_XTP_GETTABCOLOR, OnGetTabColor)

HTH


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: Marco1
Date Posted: 28 May 2011 at 1:31pm
mgampi, thanx, didn't worked as I wanted.

Okay, perhaps this is useful for someone who as a similar problem:

Tab colors only work in "OneNoteColor" mode, so enable this via
wndTabControl.GetPaintManager()->SetOneNoteColors(TRUE);

Then derive your own control and override GetItemColor

class CXTPTabControlEx : public CXTPTabControl
{
public: 
  COLORREF GetItemColor(const CXTPTabManagerItem* pItem) const {
    return pItem->IsSelected() ? GetPaintManager()->GetColorSet()->m_clrButtonSelected : OwnColor here ;
  }
};



-------------
Product: XTP 18.3.0 on VS 2017
Platform: VS 2017 / Windows 10 (64bit)



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