我给你个例子吧,我这里是设置子窗体的caption,你修改一下就可以实现你的目的了!
///////////////////////////////////////////////////////////////////////////
// 功能: 运行非模态窗体 //
// 入口参数:AForm: 窗体类实例 //
// AFormClass:窗体类 //
// Panert:容器 //
// AFormCaption:窗体标题 //
// 返回值: 成功 True ;失败 False //
///////////////////////////////////////////////////////////////////////////
function RunChildShow(AForm:TForm;AFormClass: TFormClass;Panert:TTrPanel;AFormCaption:String):Boolean;
var
i:Integer;
begin
Result:=false;
for i:=0 to Application.ComponentCount-1 do
if (Application.Components[i] is AFormClass ) then
begin
// Application.MessageBox(Pchar((PanertForm.Components[i] as AFormClass).Caption),'',0);
if (Application.Components[i] as AFormClass).Caption = AFormCaption then
begin
ShowWindow((Application.Components[i] as AFormClass).Handle,SW_RESTORE);
exit;
end;
end;
if not Assigned(AForm) then
begin
AForm:=AFormClass.Create(Application);
try
AForm.Parent:=Panert;
AForm.Top:=0;
AForm.Left:=0;
AForm.Width:=Panert.Width-5;
AForm.Height:=Panert.Height-5;
AForm.Caption:=AFormCaption;
AForm.Show;
finally
end;
end ;
Result:=true;
end;