Solved

Tabcontrol colour problem

Posted on 2001-07-12
5
1,286 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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