how to Add Close button to Each Tab : close, button, tpagecontrol

brah2008

Турист
Регистрация
20 Сен 2009
Сообщения
1
Реакции
0
Credits
0
Как добавить кнопку "Закрыть" для каждой вкладки: закрыть, кнопки, TPageControl
веб-браузера вкладки, как Mozilla или Opera таблеток таблеток с близкими кнопки
если есть Programe источников или компонентов для этой опции
помоги мне помоги мне помоги мне помоги мне помоги мне помоги мне помоги мне
;(;(;(
:)
 
Последнее редактирование модератором:

Tualan

Турист
Регистрация
18 Авг 2009
Сообщения
1
Реакции
0
Credits
4
положи кнопку на форму поверх всех компонент
 

asm64d

Местный
Регистрация
14 Июн 2008
Сообщения
940
Реакции
9,672
Credits
0
Вариант Альта
Код:
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.

Использование
Код:
unit Unit17;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls;

type
  TForm17 = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    procedure PageControl1DrawTab(Control: TCustomTabControl; TabIndex: Integer;
        const Rect: TRect; Active: Boolean);
    procedure PageControl1MouseDown(Sender: TObject; Button: TMouseButton; Shift:
        TShiftState; X, Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form17: TForm17;

implementation

uses UPageControl;

{$R *.dfm}

procedure TForm17.PageControl1DrawTab(Control: TCustomTabControl; TabIndex:
    Integer; const Rect: TRect; Active: Boolean);
begin
    DrawButton(Control, TabIndex, Active );
end;

procedure TForm17.PageControl1MouseDown(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    var TabIndex : integer;
begin
    if GetIndexTab( Sender as TCustomTabControl, X, Y, TabIndex ) then
  begin
//в TabIndex будет сидеть номер закладки
  end;
end;

end.