Jump to content

Sequential removal of the UniFrame together with UniTabSheet


artem_niko

Recommended Posts

Good afternoon!

In general, such a task.
On Pagecontrol , I dynamically create UniTabSheet1 .

image.png.18b3ba21a6a357b6a0933ba9a36b57c1.png
On the created UniTabSheet1, my UniFrame1 is dynamically loaded.
The essence of the task: according to a certain condition, using UniTimer1, delete both UniFrame1 and UniTabSheet1, and not just delete, but with the destruction of components so that there are no AV errors later.
Currently, so far, I'm going this way:
In the OnClick event in UniButton, it is written like this:

procedure TUniFrame1.Uni Button1Click(Sender: TObject);
begin
Free;
end;

I call the code above via UniTimer1:

procedure TUniFrame1.UniTimer1Timer(Sender: TObject);
begin
if N = 0 then
begin
UniButton1.OnClick(Sender);
end;
end;


As a result, my UniFrame1 disappears, I understand that it is deleted, but UniTabSheet1 remains.


Actually, the question is, how to also completely destroy UniTabSheet1? Or how to register the destruction code in the button event at once UniFrame1?

Link to comment
Share on other sites

15 minutes ago, artem_niko said:

In general, such a task.
On Pagecontrol , I dynamically create UniTabSheet1 .

image.png.18b3ba21a6a357b6a0933ba9a36b57c1.png
On the created UniTabSheet1, my UniFrame1 is dynamically loaded.
The essence of the task: according to a certain condition, using UniTimer1, delete both UniFrame1 and UniTabSheet1, and not just delete, but with the destruction of components so that there are no AV errors later.

Hello,

Just use the Close method, for example:

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniPageControl1.ActivePage.Close;
end;

 

Link to comment
Share on other sites

4 minutes ago, Sherzod said:

Hello,

Just use the Close method, for example:

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniPageControl1.ActivePage.Close;
end;

 

This won't work because UniPageControl isn't on my frame. It is the parent for UniTabSheet, which is the parent for UniFrame1 proper. 
Maybe there is some way to determine the parent of the component and delete it?

Link to comment
Share on other sites

1 hour ago, artem_niko said:

This won't work because UniPageControl isn't on my frame. It is the parent for UniTabSheet, which is the parent for UniFrame1 proper. Maybe there is some way to determine the parent of the component and delete it?

 

That's it, I figured it out myself already and made a decision.
That's how it's done:

procedure TUniFrame1.UniButton1Click(Sender: TObject);
begin
  (Parent as TUniTabSheet).Free;
end;

Also, I get this message:

Could not set cell position: row: [0], column:[1] :Cannot read properties of null (reading 'isModel')

image.png.45fe0ced6814034448806c00fe473209.png

What can this message be related to?
As such, there is no error, but maybe because of it, the closing code in the timer does not work the second time when I create the tab and frame dynamically again.

Link to comment
Share on other sites

15 minutes ago, bahry said:

если родительским элементом pagecontrol является основная форма

вы можете вызвать mainform.PageControl1.ActivePage.Закрыть;

Well, in general, yes, that's right. 
On the MainForm of the main application, I have UniPageControl1, on which UniTabSheet1 is created dynamically and immediately UniFrame1 is loaded dynamically to this tab. Therefore, I need, by clicking on the button on the loaded UniFrame1, to close its parent (UniTabSheet1), which has its parent (UniPageControl1).

Will it work?

mainform.PageControl1.ActivePage.Close;

After all, my UniFrame1 knows nothing about UniPageControl1, which is located on MainForm...

Here, I drew a diagram to make it clearer who is the parent of whom:

image.png.479ce7d14951c39d7005f851b40c969b.png

My code is in the button above - it works, everything closes as it should, but when I reconnect UniFrame1, the updated UniFrame1 does not load, because of this error, most likely:

image.png.45fe0ced6814034448806c00fe473209.png

Or because xxx.dll is not unloaded somehow.
Everything works only after restarting the server, which is not correct.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...