Solved

Tabcontrol colour problem

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

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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