Daisetsu
Daisetsu

Reputation: 4976

Delphi hiding a form: Is there a difference between Form.Hide and Form.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.

Upvotes: 5

Views: 16719

Answers (2)

David Heffernan
David Heffernan

Reputation: 613461

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;

Upvotes: 16

MDV2000
MDV2000

Reputation: 812

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.

Upvotes: 5

Related Questions