状态栏自绘事件和TabSet控件的结合.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Tabs, ComCtrls, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
TabSet1: TTabSet;
StatusBar1: TStatusBar;
Notebook1: TNotebook;
Panel1: TPanel;
Panel2: TPanel;
procedure FormCreate(Sender: TObject);
procedure TabSet1Change(Sender: TObject; NewTab: Integer;
var AllowChange: Boolean);
private
procedure DrawStatusBar1Panel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
StatusBar1.Panels.Clear;
StatusBar1.Panels.Add;
StatusBar1.Panels.Add;
StatusBar1.Panels[1].Style:=psOwnerDraw;
TabSet1.Parent:=StatusBar1;
TabSet1.Tabs.Clear;
TabSet1.Tabs.Add('Tab1');
TabSet1.Tabs.Add('Tab2');
TabSet1.TabIndex:=0;
StatusBar1.OnDrawPanel:=DrawStatusBar1Panel;
end;
procedure TForm1.DrawStatusBar1Panel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
begin
if Panel.Index=1 then
TabSet1.SetBounds(Rect.Left,Rect.Top,Rect.Right-Rect.Left,Rect.Bottom-Rect.Top);
end;
procedure TForm1.TabSet1Change(Sender: TObject; NewTab: Integer;
var AllowChange: Boolean);
begin
Notebook1.PageIndex:=NewTab;
end;
end.