TMainMenu 类[一]


自动建立一个 SDI Application 程序, 程序包含了漂亮的菜单:

TMainMenu 类[一]

在窗体文件内记录着菜单数据:

object MainMenu1: TMainMenu

  Images = ImageList1

  Left = 8

  Top = 152

  object File1: TMenuItem

    Caption = '&File'

    Hint = 'File related commands'

    object FileNewItem: TMenuItem

      Action = FileNew1

    end

    object FileOpenItem: TMenuItem

      Action = FileOpen1

    end

    object FileSaveItem: TMenuItem

      Action = FileSave1

    end

    object FileSaveAsItem: TMenuItem

      Action = FileSaveAs1

    end

    object N1: TMenuItem

      Caption = '-'

    end

    object FileExitItem: TMenuItem

      Action = FileExit1

    end

  end

  object Edit1: TMenuItem

    Caption = '&Edit'

    Hint = 'Edit commands'

    object CutItem: TMenuItem

      Action = EditCut1

    end

    object CopyItem: TMenuItem

      Action = EditCopy1

    end

    object PasteItem: TMenuItem

      Action = EditPaste1

    end

  end

  object Help1: TMenuItem

    Caption = '&Help'

    Hint = 'Help topics'

    object HelpAboutItem: TMenuItem

      Action = HelpAbout1

    end

  end

end


 
   
菜单是一个 TMainMenu 类型的对象; 每一个菜单项都是一个 TMenuItem 类型的对象. 单元文件中有声明:

MainMenu1     : TMainMenu;



File1         : TMenuItem;

FileNewItem   : TMenuItem;

FileOpenItem  : TMenuItem;

FileSaveItem  : TMenuItem;

FileSaveAsItem: TMenuItem;

N1            : TMenuItem;

FileExitItem  : TMenuItem;

Edit1         : TMenuItem;

CutItem       : TMenuItem;

CopyItem      : TMenuItem;

PasteItem     : TMenuItem;

Help1         : TMenuItem;

HelpAboutItem : TMenuItem;


 
   
看来学习 TMainMenu 类, 必须同时学习 TMenuItem 类; 因为菜单是由若干菜单项(TMenuItem)构成的.

你可能感兴趣的:(main)