Question

I have tabcontrol component on my form. After I put XPManifest, its color became white, I want to change it, but couldn't find color property. And I don't want to remove XPManifest as well. Is there any way to solve this issue?

Was it helpful?

Solution

To change the color of a TTabControl must put the OwnerDraw property to true false and write your own code to draw the tabs and the background in the OnDrawTab Event.

see this example.

procedure TForm38.TabControl1DrawTab(Control: TCustomTabControl; TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
y    : Integer;
x    : Integer;
aRect: TRect;
begin
  if Active then
  begin
    //Fill the tab rect
    Control.Canvas.Brush.Color := clWebGainsboro;
    Control.Canvas.FillRect(Rect);        
    //Fill the background
    aRect.Left:=1;
    aRect.Right:=Control.Width-1;
    aRect.Bottom:=Control.Height-1;
    aRect.Top:=Rect.Bottom+1;
    Control.Canvas.FillRect(aRect);   
  end
  else
  begin
    //Fill the tab rect
    Control.Canvas.Brush.Color := clBtnFace;
    Control.Canvas.FillRect(Rect);
  end;

  y  := Rect.Top + ((Rect.Bottom - Rect.Top - Control.Canvas.TextHeight(TTabControl(Control).Tabs[TabIndex])) div 2) + 1;
  x  := Rect.Left + ((Rect.Right - Rect.Left - Control.Canvas.TextWidth (TTabControl(Control).Tabs[TabIndex])) div 2) + 1;
  //draw the tab title
  Control.Canvas.TextOut(x,y,TTabControl(Control).Tabs[TabIndex]);
end;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top