Yes we can :) I have done this for a page designer that uses only Textboxes, Rules(lines) and Graphics but it should work for all registered controls.
[Off the cuff code approximation]
var
i, itemCount: Integer;
AClassName: string;
AnItemClass: TSomeBaseClass;
AnItem: TSomeDrivedBaseClass
ARect: TRect;
begin
// just so we have an initail size
ARect.Left := 100;
ARect.Top := 100;
ARect.Bottom := 200;
ARect.Right := 200;
// Alist is a specialised TStringList
for i := 0 to itemCount - 1 do
begin
AClassName := Alist.ByKey['Class' + IntToStr(i)]; // locate class name
AnItemClass := TSomeBaseClass(GetClass(AClassName)); // ClassName must be registered
AnItem := AnItemClass.Create(OwnerComponent, ARect, AParent);
AnItem.LoadFromFile(IntToStr(i), AList); // specialised loader that reads and sets all necessary properties
AddItemToComponentList(AnItem); // Add to form / frame / panel whatever
end;
end;
Of course you first need a "Form designer" that can save the design initially - the saving is just the reverse of the above...I'll leave that as an exercise for the Reader. wWth a little modification you could use Delphi and read the DFM file :)