Hay un error en el GetTabIndex, ya que sólo actúa sobre el PageControl1, si tenemos varios PageControl no funcionará, dejo código nuevo.
Código Delphi
[-]procedure TfrmServicios.OnEventPageControlDrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
procedure SetChangeColorControl(Style: TFontStyles; Color: TColor);
begin
Control.Canvas.Font.Style := Style;
Control.Canvas.Font.Color := Color;
end;
function GetTabIndex: Integer;
var
I, TIndex, Ind: Integer;
begin
TIndex := -1;
Ind := TabIndex;
for I := 0 to ((Control as TPageControl).PageCount -1) do
begin
if (TIndex = TabIndex) then
Break;
if (not (Control as TPageControl).Pages[i].TabVisible) then
Inc(Ind)
else
Inc(TIndex);
end;
Result := Ind;
end;
var
R: TRect;
TabCaption: String;
begin
if Active then
SetChangeColorControl([fsBold], clBlue)
else
SetChangeColorControl([], clBlack);
TabCaption := (Control as TPageControl).Pages[GetTabIndex].Caption;
R := Rect;
Control.Canvas.FillRect(R);
DrawText(
Control.Canvas.Handle, PChar(TabCaption), -1, R,
DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
Un saludo
P.D.: Perdón