妖の僧的 Delphi 博客

记录学习过程中的点点滴滴,是喜欢,不是职业;记性不好,特别需要这么一个博客.

My Links

Blog Stats

News

菜单的隐藏&显示

//还是先上万一老师的原代码

//隐藏与显示菜单
Self.Menu := nil; {隐藏菜单}

Self.Menu := MainMenu1; {显示菜单}

//初一看到代码,我有点抓不到感觉的意思...

//我觉得我得自己写一个,万老师这个自当是绝佳的参考资料...

unit MainFrm;

interface

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

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Self.Menu := nil; {隐藏菜单}
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Self.Menu := MainMenu1; {显示菜单}
end;

end.

//写到这的时候,我明白了...
//万老师是把精要的两句提出来了...
//我的小DEMO:http://files.cnblogs.com/files/FanYs/TMainMenu.rar

posted on 2015-03-14 15:35 妖の僧 阅读(...) 评论(...) 编辑 收藏