建立一个主MDI表单,一个菜单,一些按钮,点击按钮会从一个BPL包中打开MDI子表单,同时会将打开的表单标题添加到菜单中动态菜单项中,这些功能都已完成,最后一步,当子表单关闭时,要将此表单标题从动态菜单中删除掉,我用以下方法,却无法实现: 在主表单的ONACTIVE事件中,添加以下过程:
var
mainmenu:tmainmenu;
i:integer;
formname:shortstring;
begin
mainmenu:= tmainmenu(Parent.FindComponent('mainmenu1'));
for i:=0 to mainmenu.Items[mainmenu.Items.Count-1].Count-1 do
//动态菜单是最后一个菜单栏
begin
formname:=mainmenu.Items[mainmenu.Items.Count-1].Items[i].hint;
//子表单的名字放在菜单项的hint中
if tform(application.FindComponent(formname))=nil then
begin
mainmenu.Items[mainmenu.Items.Count-1].Delete(i);
exit;
end;
end;
end;在子表单的close事件中,已加了以下代码:
action:=cafree;
self:=nil;然而application.FindComponent(formname)却不是nil,究竟是哪里出了问题呢?请高手教教吧.
var
mainmenu:tmainmenu;
i:integer;
formname:shortstring;
begin
mainmenu:= tmainmenu(Parent.FindComponent('mainmenu1'));
for i:=0 to mainmenu.Items[mainmenu.Items.Count-1].Count-1 do
//动态菜单是最后一个菜单栏
begin
formname:=mainmenu.Items[mainmenu.Items.Count-1].Items[i].hint;
//子表单的名字放在菜单项的hint中
if tform(application.FindComponent(formname))=nil then
begin
mainmenu.Items[mainmenu.Items.Count-1].Delete(i);
exit;
end;
end;
end;在子表单的close事件中,已加了以下代码:
action:=cafree;
self:=nil;然而application.FindComponent(formname)却不是nil,究竟是哪里出了问题呢?请高手教教吧.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货