Solved

Tabcontrol colour problem

Posted on 2001-07-12
5
1,259 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
5 Comments
 
LVL 3

Expert Comment

by:nnbbb09
Comment Utility

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
Comment Utility
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
Comment Utility
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
Comment Utility
PAQ'd and points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

8 Experts available now in Live!

Get 1:1 Help Now