jahlxx Posted October 25, 2016 Posted October 25, 2016 Hi. I have a TUniframe called frame1. How can I create a new frame called frame2 as a clone of frame1 in run time? Thanks. Quote
tappatappa Posted October 25, 2016 Posted October 25, 2016 If "cloning" the visual components is sufficient you can try serializing/deserializing the frame. If you need to preserve the data (and non-visual components, i.e. datasets) you need to to it by hand, and it may be very hard.For serializing the components see http://docwiki.embarcadero.com/CodeExamples/Berlin/en/ComponentToString_(Delphi) Beware, this process is possible only in Delphi. I tried in C++ and never succeeded. Quote
tappatappa Posted October 25, 2016 Posted October 25, 2016 In order to make the stringToComponent work you need to register the class you want to deserializehttp://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Classes_RegisterClass.html Quote
jahlxx Posted October 27, 2016 Author Posted October 27, 2016 Hi. Is not exactly what I'm looking for. Now, for every form I have 4 files: - 2 files for the form (.pas, and .dfm) - 2 files for the frame where I am going to load the form. other .pas and.dfm for the frame I'd like to have only one frame crated, and create frames in run time, as a copy of that frame, but I dont know how to do it. Now, I'm doing as I explain above, the files of the frame are very little, but I think it could be more clear having only the files for the form and create the frame in run-time. somme help and / or idea, will be wellcome. thanks. Quote
jahlxx Posted March 19, 2018 Author Posted March 19, 2018 Hi all. I have this: var xfrc: Tfpframe; And this piece of code only works the 1st. time that is excuted: xfrc := Tfpframe.Create(self); xfrc.Align := alClient; xfrc.Parent := Ts; The 2nd. time, raises the error: A Component names fpframe already exists. Any Idea? Thanks. Quote
jahlxx Posted March 19, 2018 Author Posted March 19, 2018 I answer myself: I think the problem is the owner of the frame. If I do this, works. xfrc := Tfpframe.Create(Ts);xfrc.Align := alClient;xfrc.Parent := Ts; Is correct? Any other best way to do it? Thanks. Quote
jahlxx Posted March 19, 2018 Author Posted March 19, 2018 Sorry, don't understand. I need many frames, created as a predefines frame, and must be different frames. Quote
Oliver Morsch Posted March 19, 2018 Posted March 19, 2018 Every frame must have an unique name. xfrc.name := 'something unique'; example: xfrc.name := xfrc.name + IntToStr(Integer(xfrc)); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.