先定制好一个TMainMenu
然后在表单中你喜欢的位置放置一个TToolBar。
设置TToolBar的属性
Align := alNone
EdgeBorders.ebTop := False
Flat := True
ShowCaption := True
为TMainMenu中每一个下拉菜单创建一个TToolButton,把每一个TToolButton的
MenuItem设置为对应的TMainMenu的下拉菜单
我的例子如下:
object Form1: TForm1
Left = 193
Top = 81
Width = 435
Height = 300
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object ToolBar1: TToolBar
Left = 0
Top = 100
Width = 427
Height = 29
Align = alNone
ButtonHeight = 21
ButtonWidth = 31
Caption = 'ToolBar1'
EdgeBorders = []
Flat = True
ShowCaptions = True
TabOrder = 0
object ToolButton1: TToolButton
Left = 0
Top = 0
Caption = '&File'
MenuItem = File1
end
object ToolButton2: TToolButton
Left = 31
Top = 0
Caption = '&Edit'
MenuItem = Edit1
end
end
object MainMenu1: TMainMenu
Left = 84
Top = 192
object File1: TMenuItem
Caption = '&File'
object Open1: TMenuItem
Caption = '&Open'
end
object Save1: TMenuItem
Caption = '&Save'
end
object N1: TMenuItem
Caption = '-'
end
object Exit1: TMenuItem
Caption = 'E&xit'
end
end
object Edit1: TMenuItem
Caption = '&Edit'
object Cut1: TMenuItem
Caption = 'C&ut'
end
object Copy1: TMenuItem
Caption = '&Copy'
end
object Paster1: TMenuItem
Caption = '&Paste'
end
end
end
end
好了,运行程序测试一下结果吧。