artem_niko Posted November 6, 2022 Share Posted November 6, 2022 Good afternoon! I solve this problem: I need to create a form dynamically and load my frame on it, and if the form already exists, then close it (destroy it), along with all the contents, and create it again with a frame. Simply put, recreate an already existing and previously created dynamically form. Everything should be done with one button. Here is the form creation code that creates the form dynamically initially: TestForm:=TUniForm.Create(UniApplication); TestForm.Height:=500; TestForm.Width:=500; TestForm.Parent:=MainForm; TestForm.Name:='test'; TestForm.BorderIcons:=[biSystemMenu,biMaximize]; TestForm.BorderStyle:=bsSizeable; TestForm.Caption:='test'; TestForm.Show; Before the form creation code, I tried to add such a code to search for and delete a previously created form: for i:=Screen.FormCount-1 downto 0 do begin if Screen.Forms[i].Name = 'test' then Screen.Forms[i].Free; end; The first time the form is created: Without closing this form, I try to recreate it, but I get an error: I ask for help in solving my problem Initially, I thought that maybe you can create an empty form in the usual way and use it already for my frames, because I need to upload different frames to separate instances of the form, but it seems to me that this will not work... Quote Link to comment Share on other sites More sharing options...
artem_niko Posted November 6, 2022 Author Share Posted November 6, 2022 8 hours ago, artem_niko said: Good afternoon! I solve this problem: I need to create a form dynamically and load my frame on it, and if the form already exists, then close it (destroy it), along with all the contents, and create it again with a frame. Simply put, recreate an already existing and previously created dynamically form. Everything should be done with one button. Here is the form creation code that creates the form dynamically initially: TestForm:=TUniForm.Create(UniApplication); TestForm.Height:=500; TestForm.Width:=500; TestForm.Parent:=MainForm; TestForm.Name:='test'; TestForm.BorderIcons:=[biSystemMenu,biMaximize]; TestForm.BorderStyle:=bsSizeable; TestForm.Caption:='test'; TestForm.Show; Before the form creation code, I tried to add such a code to search for and delete a previously created form: for i:=Screen.FormCount-1 downto 0 do begin if Screen.Forms[i].Name = 'test' then Screen.Forms[i].Free; end; The first time the form is created: Without closing this form, I try to recreate it, but I get an error: I ask for help in solving my problem Initially, I thought that maybe you can create an empty form in the usual way and use it already for my frames, because I need to upload different frames to separate instances of the form, but it seems to me that this will not work... In general, I figured out my question myself and it's not relevant. But, I have another question. Is it possible to make the created form on top of windows, for example, so that I can move it around the screen outside of the main application? For example, let's say I have 2 monitors on one computer. I want to run the project on one monitor, and move the created form to the second monitor. Is it possible to do this? Quote Link to comment Share on other sites More sharing options...
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.