如何根据一个form对象的name,来获取这个对象 我在一个程序里面打开好多form, 然后想操作某个特定的form,已知这个form的name,并且知道是当前活动窗体,请问如何获取这个form对象? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 通过Screen对象来遍历就行了:var i:integer;for i:=0 to Screen.FormCount-1 dobegin if Screen.Forms[i].Name='xxx' then //....end; for i := 0 to Self.MDIChildCount do begin if Self.MDIChildren[I].name = 'xxxx' then begin //--------------------- break; end; end;mdi窗口 MDi: ActiveMDIChild普通窗体: Screen.Forms[i] 我表示我这里没注意到“并且知道是当前活动窗体”呵呵。Screen.ActiveForm也可以。 创建var frm:TForm2;begin frm := TForm2.Create(Application); frm.Name := 'frm2'; frm.Show;end;查找Application.FindComponent('frm2') WebBrowser用法,有DEMO最好 两球碰撞的计算,有兴趣的来看看 用Delphi打开Word文档在关闭时怎么自己判断是否修改,而不弹出word的保存界面。 如何将Access中的表单写到TListBox中? 熬到夜里仍然没有解决的问题!急! 怎么样获得DELPHI的控件的属性列表(在程序运行期间) 用shell做一个向后退的按钮 怎样快速求两个文本文件中内容相同的行 【CreateProcess】、【MsgWaitForMultipleObjects】与线程冲突了 如果你认为你是高手,就请进!!! 如何根据一个form对象的name,来获取这个对象 求大哥帮我解释一个函数
var i:integer;for i:=0 to Screen.FormCount-1 do
begin
if Screen.Forms[i].Name='xxx' then
//....
end;
begin
if Self.MDIChildren[I].name = 'xxxx' then
begin
//---------------------
break;
end;
end;
mdi窗口
普通窗体: Screen.Forms[i]
frm:TForm2;
begin
frm := TForm2.Create(Application);
frm.Name := 'frm2';
frm.Show;
end;
查找
Application.FindComponent('frm2')