Delphi隐藏表单:Form.Hide和Form.Visible:=False之间有区别吗?

发布于 2024-10-27 08:21:07 字数 96 浏览 5 评论 0原文

我正在查看两份代码,其中一份有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人间☆小暴躁 2024-11-03 08:21:07

隐藏没有区别。 VCL 代码是:

procedure TCustomForm.Hide;
begin
  Visible := False;
end;

但是 Show 有点不同:

procedure TCustomForm.Show;
begin
  Visible := True;
  BringToFront;
end;

There is no difference for Hide. The VCL code is:

procedure TCustomForm.Hide;
begin
  Visible := False;
end;

But Show is a bit different:

procedure TCustomForm.Show;
begin
  Visible := True;
  BringToFront;
end;
-残月青衣踏尘吟 2024-11-03 08:21:07

取决于您的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文