jahlxx Posted October 25, 2016 Share 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. Link to comment Share on other sites More sharing options...
tappatappa Posted October 25, 2016 Share 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. Link to comment Share on other sites More sharing options...
tappatappa Posted October 25, 2016 Share 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 Link to comment Share on other sites More sharing options...
jahlxx Posted October 27, 2016 Author Share 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. Link to comment Share on other sites More sharing options...
jahlxx Posted March 19, 2018 Author Share 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. Link to comment Share on other sites More sharing options...
jahlxx Posted March 19, 2018 Author Share 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. Link to comment Share on other sites More sharing options...
Oliver Morsch Posted March 19, 2018 Share Posted March 19, 2018 Give the frame a unique name. Link to comment Share on other sites More sharing options...
jahlxx Posted March 19, 2018 Author Share Posted March 19, 2018 Sorry, don't understand. I need many frames, created as a predefines frame, and must be different frames. Link to comment Share on other sites More sharing options...
Oliver Morsch Posted March 19, 2018 Share Posted March 19, 2018 Every frame must have an unique name. xfrc.name := 'something unique'; example: xfrc.name := xfrc.name + IntToStr(Integer(xfrc)); Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now