11-07-2012, 01:43 AM
السلام عليكم
الكود معدل على السريع للعمل على PageControl
المصدر
مجرب على دلفي 7...
السلام عليكم و رحمة الله
الكود معدل على السريع للعمل على PageControl
المصدر
كود :
http://stackoverflow.com/questions/239002/duplicating-components-at-run-timeمجرب على دلفي 7...
كود :
procedure TForm1.Button1Click(Sender: TObject);
var
MyTab:TTabSheet;
CurrentControl, ClonedControl: TControl;
i: Integer;
begin
MyTab := TTabSheet.Create(PageControl1);
MyTab.PageControl := PageControl1;
MyTab.Name := 'TabSheet' + IntToStr(PageControl1.PageCount);
for I := PageControl1.Pages[0].ControlCount - 1 downto 0 do
begin
CurrentControl := PageControl1.Pages[0].Controls[I];
ClonedControl := TControlClass(CurrentControl.ClassType).Create(CurrentControl.Owner);
ClonedControl.Parent := MyTab;
CloneProperties(CurrentControl, ClonedControl);
ClonedControl.Name := CurrentControl.Name +IntToStr(PageControl1.PageCount);
end;
end;
procedure TForm1.CloneProperties(const Source: TControl; const Dest: TControl);
var
ms: TMemoryStream;
OldName: string;
begin
OldName := Source.Name;
Source.Name := '';
try
ms := TMemoryStream.Create;
try
ms.WriteComponent(Source);
ms.Position := 0;
ms.ReadComponent(Dest);
finally
ms.Free;
end;
finally
Source.Name := OldName;
end;
end;السلام عليكم و رحمة الله
و لرب نازلة يضيق لها الفتى ذرعا و عند الله منها المخرج
ضاقت فلما استحكمت حلقاتها فرجت و كنت اضنها لا تفرج
ضاقت فلما استحكمت حلقاتها فرجت و كنت اضنها لا تفرج

