但是必须先用一横线占一个子菜单位,不然弹不出来
procedure TFrmStart.N4Click(Sender: TObject);//N4其caption为"窗口"
var
popItem:TMenuItem;
i:integer;
frmCap:string;
begin
if n4.Count>1 then
begin
for i:=1 to n4.Count-1 do
begin
n4.Delete(0);//N4.clear一用就什么都弹不出来
end;
end;
for i:=0 to screen.FormCount-1 do
begin
frmCap:=screen.Forms[i].Caption;
popItem:=TMenuItem.Create(self);
popItem.Tag:=i;
popItem.Caption:=frmCap;
popItem.OnClick:=windowItem;
n4.Insert(0,popItem);//插入子菜单到顶端
end;
end;