Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Determine if a control is showing

Lets say I have a pagecontrol with two tabsheet. There is a button on the first sheet but the active sheet is the second. In this case how can I determine if that button is showing (e.g. visible for the user) or not?
I tried the button’s Showing property, but for some reason its always True.

update: for the clarification I don’t mind if the control is outside of the desktop’s visible area or covered by any other application’s window.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can simply go up in the VCL tree until you find an element which isn’t visible, or you have no other parent to check.

function IsVisible(Obj:TWinControl):boolean;
begin
  Result:=Obj.Visible;
  if not Obj.Visible then Exit;

  while Obj.HasParent do
  begin
    Obj:=Obj.Parent;
    Result:=Obj.Visible;
    if not Result then Exit;
  end;
end;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading