Solved

CTabCtrl text color

Posted on 1997-07-29
4
648 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
[X]
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
  • 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
fix34  challenge 9 167
sumHeights2  challenge 7 131
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 1,333
Authenticate using sesu from script 7 116
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 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