views:

259

answers:

2

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.

+1  A: 

You can override the protected TCustomForm.VisibleChanging.

utku_karatas
Yes it's works. It's the perfect place to insert additional code before a Form's Visible property is changed. (ps. I've seen the VisibleChanging but a little bit reluctant to touch it since I thought it's part of a TControl's show/hide mechanism while I only expect to override a TForm's descendant) Thanks. You've convinced me to go that way and it's works perfectly, rgds Hasan S.
Hasan S
A: 

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;
mj2008