Override default Show behaviour / SetVisible of TForm's descendant (Delphi VCL)

1.8k views Asked by At

I would like to alter the Show default behaviour of a TForm's descendant (for eg. instead of showing itself on the screen, I would like to place it on a page control as a new tabsheet). How to achive that ? I'd like to show it using a standard method (call Show method or set Visible property) so I tried to override the SetVisible method. But I found that the SetVisible cannot be overriden since it is a private method. Any suggestions where to override it ? Thanks.

2

There are 2 answers

1
utku_karatas On BEST ANSWER

You can override the protected TCustomForm.VisibleChanging.

0
mj2008 On

There are two ways to do what I think you are asking, which is embedding a form in a panel or similar. There is a TForm.CreateParented(handle) function, but in our code we tend not to use that. Instead, we create the form with this sort of code:

MyForm := TMyForm.Create(Self);
MyForm.Parent := MyTabSheet;
MyForm.Border := bsNone;
MyForm.Align := alClient;
MyForm.Show;