覆盖 TForm 后代的默认显示行为/SetVisible (Delphi VCL)
我想更改 TForm 后代的显示默认行为(例如,我不想将其自身显示在屏幕上,而是将其作为新选项卡放置在页面控件上)。 如何实现这一目标? 我想使用标准方法(调用 Show 方法或设置 Visible 属性)来显示它,因此我尝试重写 SetVisible 方法。但我发现 SetVisible 无法被重写,因为它是私有方法。 有什么建议可以覆盖它吗?谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以覆盖受保护的 TCustomForm.VisibleChanging。
You can override the protected TCustomForm.VisibleChanging.
有两种方法可以完成我认为您所要求的事情,即将表单嵌入面板或类似的东西中。有一个 TForm.CreateParented(handle) 函数,但在我们的代码中我们倾向于不使用它。相反,我们使用此类代码创建表单:
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: