unit UPageControl;
interface
uses
ComCtrls, Types;
function GetIndexTab( Control : TCustomTabControl; X, Y: Integer; var Index : Integer ) : Boolean;
procedure DrawButton( Control : TCustomTabControl; Index : Integer; State : Boolean );
implementation
uses
Math, Graphics, Buttons;
function GetButtonRect( Control : TCustomTabControl; Index : integer) : TRect;
begin
with Control.TabRect( Index ) do
begin
Result.Right := Right - 2;
Result.Top := Top + 3;
Result.Bottom := Result.Top + Control.Canvas.TextHeight( '0' );
Result.Left := Result.Right - ( Result.Bottom - Result.Top );
end;
end;
function GetIndexTab( Control : TCustomTabControl; X, Y: Integer; var Index : Integer ) : Boolean;
begin
Result := false;
Index := Control.IndexOfTabAt( X, Y );
if ( Index >= 0 ) then
Result := PtInRect( GetButtonRect( Control, Index ), Point( X, Y ));
end;
procedure DrawButton( Control : TCustomTabControl; Index : Integer; State : Boolean );
var Rect : TRect;
begin
Rect := Control.TabRect( Index );
with Control.Canvas do
begin
TextRect( Rect, Rect.Left + 4, Rect.Top + 3,
( Control as TPageControl ).Pages[ Index ].Caption );
Rect := GetButtonRect( Control, Index );
with DrawButtonFace( Control.Canvas, Rect, 1, bsNew, true, true, false ) do
begin
Pen.Color := IfThen( State, clBtnText, clBtnShadow );
Pen.Width := 2;
MoveTo( Left + 1, Top + 1 );
LineTo( Right - 3, Bottom - 3 );
MoveTo( Right - 3, Top + 1 );
LineTo( Left + 1, Bottom - 3 );
end;
end;
end;
end.