how to make a transparent form inside Panel?

2019-08-07 13:30发布

问题:

I need to create at runtime a partial transparent Form inside a Panel.

How might I be able to achieve this?

回答1:

If your question is only related to the way to put the form in a TPanel then it's quite easy. You only need to call Windows.SetParent() with the handle of the newly created form.

MyNewForm := TMyNewForm.Create(Self); 
Windows.SetParent(MyNewForm.Handle,MyPanel.Handle);

This would also work by using the TForm Property ParentWindow. But it's (quite) possible that the transparency is not handled (I briefly tested with a semi opaque form and it's not drawn correctly, So if the transparency is mandatory it mights be impossible to reach your goal...)