The only problem with your approach is that you cannot add multiple instances of the same frame to a given form:
Frame1 := TMyFrame.Create(Self);
Frame1.Parent := Self;
// ...
Frame2 := TMyFrame.Create(Self); // bombs out with "a component with the name MyFrame already exists"
The workaround for his is to assign a different name for each instance:
Frame1 := TMyFrame.Create(Self)
Frame1.Parent := Self;
Frame1.Name := "FirstFrame";
// ...
Frame2 := TMyFrame.Create(Self); // works now, there is no name conflict
Edit: It’s also possible to assign an empty string for the name, so you don’t need to come up with a unique name for each instance.






Leave a comment