Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

CTabCtrl text color

Posted on 1997-07-29
4
641 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

828 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