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.
CodePudding user response:
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;