用一个毛招,PageControl加上ToolBar组合起来,效果勉强还可以 [
]
窗体文件:unit1.dfm
------------------------------------
object Form1: TForm1
Left = 236
Top = 129
Width = 870
Height = 640
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object PageControl1: TPageControl
Left = 0
Top = 28
Width = 289
Height = 193
ActivePage = TabSheet1
TabOrder = 0
OnChange = PageControl1Change
object TabSheet1: TTabSheet
Caption = 'TabSheet1'
end
object TabSheet2: TTabSheet
Caption = 'TabSheet2'
ImageIndex = 1
end
end
object ToolBar1: TToolBar
Left = 47
Top = 29
Width = 20
Height = 21
Align = alNone
ButtonHeight = 21
ButtonWidth = 10
EdgeInner = esNone
EdgeOuter = esNone
Flat = True
TabOrder = 1
Transparent = True
object TBtn1: TToolButton
Left = 0
Top = 0
DropdownMenu = PopupMenu1
Style = tbsDropDown
OnClick = TBtn1Click
OnMouseUp = TBtn1MouseUp
end
end
object ToolBar2: TToolBar
Left = 110
Top = 29
Width = 21
Height = 21
Align = alNone
ButtonHeight = 21
ButtonWidth = 10
Caption = 'ToolBar1'
EdgeInner = esNone
EdgeOuter = esNone
Flat = True
TabOrder = 2
Transparent = True
object ToolButton1: TToolButton
Left = 0
Top = 0
DropdownMenu = PopupMenu2
Style = tbsDropDown
OnClick = TBtn1Click
OnMouseUp = TBtn1MouseUp
end
end
object PopupMenu1: TPopupMenu
Left = 66
Top = 114
object A1: TMenuItem
Caption = 'A1'
end
object A21: TMenuItem
Caption = 'A2'
end
object A31: TMenuItem
Caption = 'A3'
end
end
object PopupMenu2: TPopupMenu
Left = 130
Top = 116
object MenuItem1: TMenuItem
Caption = 'B1'
end
object MenuItem2: TMenuItem
Caption = 'B2'
end
object MenuItem3: TMenuItem
Caption = 'B3'
end
end
end
单元文件:unit1.pas
------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, ToolWin, Menus;
type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
ToolBar1: TToolBar;
TBtn1: TToolButton;
PopupMenu1: TPopupMenu;
A1: TMenuItem;
A21: TMenuItem;
A31: TMenuItem;
PopupMenu2: TPopupMenu;
MenuItem1: TMenuItem;
MenuItem2: TMenuItem;
MenuItem3: TMenuItem;
ToolBar2: TToolBar;
ToolButton1: TToolButton;
procedure PageControl1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
ToolBar1.BringToFront;
ToolBar2.SendToBack;
end;
procedure TForm1.PageControl1Change(Sender: TObject);
begin
if PageControl1.ActivePageIndex=0 then
begin
ToolBar1.BringToFront;
ToolBar2.SendToBack;
end
else
begin
ToolBar1.SendToBack;
ToolBar2.BringToFront;
end;
end;
end.