W
wutaoqing
Unregistered / Unconfirmed
GUEST, unregistred user!
以下是您的代码:
function CreateComponentCopy(AComponent: TComponent): TComponent;
var
ms: TMemoryStream;
begin
Result := nil;
RegisterClass(TPersistentClass(AComponent.ClassType));
ms := TMemoryStream.Create;
try
ms.WriteComponent(AComponent);
ms.Position := 0;
Result := ms.ReadComponent(nil);
finally
ms.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with (CreateComponentCopy(MaskEdit1) as TWinControl) do
begin
Parent := Self;
Left := 10;
Top := 10;
end;
end;
问题:
我想在form1里面动态创建控件写代码,新创建的控件如何才可以放在form2上去呢??
也就是说,我想在form1上创建控件到form2里面去,该怎么办??
function CreateComponentCopy(AComponent: TComponent): TComponent;
var
ms: TMemoryStream;
begin
Result := nil;
RegisterClass(TPersistentClass(AComponent.ClassType));
ms := TMemoryStream.Create;
try
ms.WriteComponent(AComponent);
ms.Position := 0;
Result := ms.ReadComponent(nil);
finally
ms.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with (CreateComponentCopy(MaskEdit1) as TWinControl) do
begin
Parent := Self;
Left := 10;
Top := 10;
end;
end;
问题:
我想在form1里面动态创建控件写代码,新创建的控件如何才可以放在form2上去呢??
也就是说,我想在form1上创建控件到form2里面去,该怎么办??