unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure MyClick(Sender:TObject);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
MM:TMenuItem;
begin
MM:=TMenuItem.Create(Self);
MM.Caption:='&shenqw';
// MM.OnClick:=MyClick;
MainMenu1.Items.Add(MM);
MM:=TMenuItem.Create(Self);
MM.Caption:='&shenqw2';
MM.OnClick:=MyClick;
MainMenu1.Items[0].Add(MM);
end;
procedure TForm1.MyClick(Sender: TObject);
begin
ShowMessage('OK');
end;
end.