procedure TForm1.FormShow(Sender: TObject); begin label1.Caption:='6544545'; end; 我试过可以的
procedure TForm1.FormShow(Sender: TObject); //var // label1: Tlabel;//是不是在这又声明了,去掉 begin label1.Caption:='dddddd'; end;
我给你个例子吧,我这里是设置子窗体的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;
我去掉了,label的前缀就行了,呵呵!
没有问题啊 procedure TMDIForm1.FormShow(Sender:TObject); begin Label1.Caption:='mdi'; ChildForm2.Lable1.Caption:='mdi'; end;////////////// procedure TChildForm2.FormShow(Sender:TObject); begin MDIForm1.Label1.Caption:='child'; Lable1.Caption:='child'; end; 是不是你的 ChildForm 没有设置成自动创建,那么要手动创建。
begin
label1.Caption:='6544545';
end;
我试过可以的
//var
// label1: Tlabel;//是不是在这又声明了,去掉
begin
label1.Caption:='dddddd';
end;
///////////////////////////////////////////////////////////////////////////
// 功能: 运行非模态窗体 //
// 入口参数: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;
procedure TMDIForm1.FormShow(Sender:TObject);
begin
Label1.Caption:='mdi';
ChildForm2.Lable1.Caption:='mdi';
end;//////////////
procedure TChildForm2.FormShow(Sender:TObject);
begin
MDIForm1.Label1.Caption:='child';
Lable1.Caption:='child';
end;
是不是你的 ChildForm 没有设置成自动创建,那么要手动创建。