Solved

CTabCtrl text color

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

18 Experts available now in Live!

Get 1:1 Help Now