Solved

CTabCtrl text color

Posted on 1997-07-29
4
632 Views
Last Modified: 2013-11-20
I need to change the text color (and maybe the background) in my CTabCtrl-derived class.
Any idea?
0
Comment
Question by:winmeister
  • 2
4 Comments
 
LVL 4

Expert Comment

by:mbhakta
ID: 1302896
You have to make a ownerdrawn CTabCtrl. Now override the DrawItem() method.

The LPDRAWITEMSTRUCT lpDrawItemStruct  parameter will contain the neccessary stuff you need to colour the tab. i.e. hDC, hWnd, Rect etc. You will have to do the hard part by TextOut()'ing the text (with the colour of your choice) , to get it working.
0
 
LVL 1

Author Comment

by:winmeister
ID: 1302897
It was clear that owner-drawing the control I could get the hands on the text color, but then I will also have to entirely draw the control by myself, providing all the stuff for managing the focus, the selection, etc...
I was asking for a simple method of just changing the color of the text in the tabs.....
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1302898
I don't think there is a simple way to do it. What Tab control is nothing but a ownerdrawn list box.
0
 
LVL 8

Accepted Solution

by:
gelbert earned 50 total points
ID: 1302899
You should overide function DrawItem() but your version of this function should get handle of DC from LPDRAWITEMSTRUCT lpDrawItemStruct and call CDC::SetBkColor and CDC::SetTextColor ( to get CDC object from hDC use function CDC::FromHandle() it is static function). After you change color call default implimentation of DrawItem(). So you do not have to do all dirty work yourself.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 146
viewing source code from eclipse 13 88
wordmultiple challenge 12 118
Making an alias 7 79
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now