我的动态菜单在加载的时候有错误?
unit code;interfaceuses
Menus,SysUtils; procedure menushow(Sender: TObject);
var
w:integer;
MyMainMenu: TMainMenu;
MyPopUpMenu: TPopUpMenu;
MySubItem1,MySubItem2 : TMenuItem;
MySubItems: array[0..3] of TMenuItem;
MyPopUpItems: array[0..3] of TMenuItem;implementationuses main;procedure menushow(Sender: TObject);
var
MyItem: array[0..2] of TMenuItem;
MySubItems: array[0..3] of TMenuItem;
i: Integer;
j: integer;
begin
for j := 0 to 2 do
begin
MyItem[j] := TMenuItem.Create(frmmain.Owner);
MyItem[j].Caption := 'New item ' + IntToStr(j);
MyMainMenu.Items.Add(MyItem[j]);
end; for i := 0 to 3 do
begin
MySubItems[i] := TMenuItem.Create(frmmain.Owner);
MySubItems[i].Caption := 'New item ' + IntToStr(i);
//MySubItems[i].OnClick := MyPopUpHandler;
MyMainMenu.Items[0].Add(MySubItems[i]);
end;
end;end.上面一段CODE中有错误,有高手能帮我指出来吗?
并且说是为什么?请了!!!!
unit code;interfaceuses
Menus,SysUtils; procedure menushow(Sender: TObject);
var
w:integer;
MyMainMenu: TMainMenu;
MyPopUpMenu: TPopUpMenu;
MySubItem1,MySubItem2 : TMenuItem;
MySubItems: array[0..3] of TMenuItem;
MyPopUpItems: array[0..3] of TMenuItem;implementationuses main;procedure menushow(Sender: TObject);
var
MyItem: array[0..2] of TMenuItem;
MySubItems: array[0..3] of TMenuItem;
i: Integer;
j: integer;
begin
for j := 0 to 2 do
begin
MyItem[j] := TMenuItem.Create(frmmain.Owner);
MyItem[j].Caption := 'New item ' + IntToStr(j);
MyMainMenu.Items.Add(MyItem[j]);
end; for i := 0 to 3 do
begin
MySubItems[i] := TMenuItem.Create(frmmain.Owner);
MySubItems[i].Caption := 'New item ' + IntToStr(i);
//MySubItems[i].OnClick := MyPopUpHandler;
MyMainMenu.Items[0].Add(MySubItems[i]);
end;
end;end.上面一段CODE中有错误,有高手能帮我指出来吗?
并且说是为什么?请了!!!!
解决方案 »
- 如何根据错误提示找到代码位置?
- 从C++builder改学Delphi可取吗
- TClientDataset中有重大BUG:
- 进来没有分,给个人分帖,请不要进
- 有麻煩
- Delphi编写的ASP/MTS组件的The requested resource is in use问题
- 网站的主页竟然被人替换了,如何防止这类事情?(服务器为win2000 adv server)
- 100分求书:橙子的《Delphi 从初学到高手》
- 我解决了几乎所有Delphi+Access同仁的问题—动态创建、压缩Access数据库(*.MDB)
- 客户登陆后,服务器自动保留客户名称,如何避免重复。
- 在做一个三层结构的程序时,遇到的问题!!!!!
- 各位大俠们:哪里有类似sql server中新建立视图那样的delphi控件或参考?
var
Form1: TForm1;
MyMainMenu:TMainMenu;
MySubItem:array [0..4] of TMenuItem;
i:integer;
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
MyItemMenu:array [0..2] of TMenuItem;
begin
MyMainMenu:=TMainMenu.Create(self); //建立主菜单
for i:=0 to 2 do
begin
MyItemMenu[i]:=TMenuItem.create(self); //建立三个菜单项
MyItemMenu[i].Caption :='主菜单'+IntToStr(i);
MyMainMenu.Items.Add(MyItemMenu[i]);
end; for i:=0 to 4 do
begin
MysubItem[i]:=TMenuItem.Create(Self);
MySubItem[i].Caption :='子菜单项'+IntToStr(i);
MyMainMenu.Items[0].add(MySubItem[i]); //在第一个菜单项建立5个子菜单项
end; for i:=0 to 1 do
begin
MysubItem[i]:=TMenuItem.Create(Self);
MySubItem[i].Caption :='子菜单项'+IntToStr(i);
MyMainMenu.Items[1].add(MySubItem[i]); //在第一个菜单项建立2个子菜单项
end; for i:=0 to 4 do
begin
MysubItem[i]:=TMenuItem.Create(Self);
MySubItem[i].Caption :='子菜单项'+IntToStr(i);
MyMainMenu.Items[2].add(MySubItem[i]); //在第一个菜单项建立5个子菜单项
end;end; 建立右键菜单用同样的方法