Procedure TForm1.pr_PageControl1_DrawTab(Control: TCustomTabControl; TabIndex: Integer; const [Ref] Rect: TRect; Active: Boolean);
var iMidWidth, iMidHeight, iTextWidth, iTextHeight:Integer;
sCaption:String;
begin
sCaption := TPageControl(Control).Pages[TabIndex].Caption;
iTextWidth := TPageControl(Control).Canvas.TextWidth(sCaption);
iTextHeight := TPageControl(Control).Canvas.TextHeight(sCaption);
iMidWidth := Rect.Left + Ceil((Rect.Width-iTextWidth)/2);
iMidHeight := Rect.Top + Ceil((Rect.Height-iTextHeight)/2);
if Active then
begin
TPageControl(Control).Canvas.Brush.Color := clHighlight;
TPageControl(Control).Canvas.Font.Color := clHighlightText;
end
else
TPageControl(Control).Canvas.Brush.Color := clScrollBar;
TPageControl(Control).Canvas.FillRect(Rect);
TPageControl(Control).Canvas.TextOut(iMidWidth, iMidHeight, sCaption);
end;
沒有留言:
張貼留言