Delphi隐藏表单:Form.Hide和Form.Visible:=False之间有区别吗?
我正在查看两份代码,其中一份有 myForm.Hide,另一份有 myForm.Visible := False。我不记得为什么要改变这个,如果是一个错误修复或者是否有任何区别。
I'm looking through two copies of code and in one I have myForm.Hide and another I have myForm.Visible := False. I can't remember why I changed this, if one was a bug fix or whether there is any difference at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
隐藏
没有区别。 VCL 代码是:但是
Show
有点不同:There is no difference for
Hide
. The VCL code is:But
Show
is a bit different:取决于您的 Delphi 代码有多旧以及可以追溯到多远。 Form.Hide 一次 (Win95/2000) 会隐藏窗体及其任务栏图标 - 另一种则不会。当然,有一些补丁等可以解决 Delphi 的问题,并且某些显卡/调色板需要您考虑如何隐藏表单。 (伙计,我暴露了我的年龄)。我见过将表单 Left 设置为一个大负数的代码,只是为了将表单隐藏在屏幕之外,这是硬件问题的原因(Delphi 1-3 确实对硬件敏感)
此外,在 Delphi 3/4 周围有一个内存在 MDI 应用程序中使用最小化而不是隐藏来泄漏(因此我们使用 PAgecontrol 与 MDI 表单上的表单对接)。因此,如果您正在查看非常旧的代码,那么这些事情很重要。如果您在 Delphi 6 或更高版本上进行编译,那么实际上没有什么区别。
Depends on how old your Delphi code is and how far back it goes. Form.Hide at one time (Win95/2000) would hide the form AND its taskbar icon - the other would not. Of course, there was some patches, etc to fix issues with Delphi and certain video cards/color palettes would require you to consider how you wanted to hide forms. (man I am showing my age). I've seen code that would set the form Left to a big negative number just to hide the form off the screen cause of issues with hardware (Delphi 1-3 was really hardware sensitive)
Also, around Delphi 3/4 there was a memory leak using minimize instead of hide in MDI applications (so we used PAgecontrol with form docking over MDI Forms). So, if you are looking at very old code, then those things matter. If you are compiling on Delphi 6 or better, then there is really no difference.