You need a function that maps the tag number to the frame class, for example:
type TFrameClass = class of TFrame; function GetFrameClass(const aClassID: Integer): TFrameClass; begin case aClassID of 1 : Result := TFrameFoo; 2 : Result := TFrameBar; else Result := nil; end; end;
and then you can create frames:
var FrClass: TFrameClass; Frame: TFrame; begin FrClass := GetFrameClass(btn.Tag); if(FrClass <> nil)then begin Frame := FrClass.Create(tabsheet); Frame.Parent := tabsheet; end;
source share