how to make a transparent form inside Panel?

2019-08-07 13:21发布

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

How might I be able to achieve this?

1条回答
Deceive 欺骗
2楼-- · 2019-08-07 13:27

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...)

查看更多
登录 后发表回答