Solved

CTabCtrl text color

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 92
Strange date stored 22 119
CRON statement to run every 3 minutes except on Monday morning 12am to 2am 7 94
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 93
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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

786 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