?
Solved

Tabcontrol colour problem

Posted on 2001-07-12
5
Medium Priority
?
1,343 Views
Last Modified: 2008-02-01
This is probably really easy, however driving me mad!

How do I set the color property of the individual tabcontrol tabs?, I am creating a variable amount of tabs at run time with the TTabcontrol component.

I would really like to stick to the native VCL components in Delphi 5 to keep things simple.

Thanks!

Matt
0
Comment
Question by:mattlaver
  • 2
4 Comments
 
LVL 3

Expert Comment

by:nnbbb09
ID: 6278187

Matt,

I think the only way to change the colour of the tabs is to use the OnDrawTab event handler.
0
 
LVL 3

Expert Comment

by:nnbbb09
ID: 6278199
This is some code that I posted for a previous answer :

procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
tmpRect:TRect;
begin
With Control as TPageControl do
begin
  if Active then
    Canvas.Brush.Color:=clAqua
  else
    Canvas.Brush.Color:=clBtnFace;

  Canvas.FillRect(Rect);
  tmpRect:=Rect;
  DrawText(Canvas.Handle,
           pChar(Pages[TabIndex].Caption),
           -1,
           tmpRect,
           DT_CENTER or
           DT_SINGLELINE or
           DT_VCENTER);
end;
end;

All this does is paint the active tab aqua. But you could amend it to paint various tabs. Remember to set ownerdraw to true for the pagecontrol

Jo
0
 

Expert Comment

by:skyrider_tieus
ID: 6706449
nnbbb09:

I tried your code in D6, and there was a problem with the
DrawText function.  As the pagecontrol was first initiated, all tab captions would display the same text as the set active tab.  When one tab was clicked, its caption and the previous tab caption would display the same text as the currently selective one.  Any idea how to fix this problem?
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8492031
PAQ'd and points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

840 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