Lazarus

Programming => LCL => Topic started by: pcurtis on December 09, 2021, 04:03:57 am

Title: [SOLVED] Scrollbox Controlatpos
Post by: pcurtis on December 09, 2021, 04:03:57 am
How do I get TScrollbox.Controlatpos to work? See attachment.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   aPoint : TPoint;
  4. begin
  5.   aPoint.X := 20;
  6.   aPoint.Y := 20;
  7.   Caption := Scrollbox1.ControlAtPos(aPoint, True).ClassName;
  8. end;
  9.  

Gives a SIGSEGV

Test app attached
Title: Re: Scrollbox Controlatpos
Post by: zeljko on December 09, 2021, 09:33:00 am
Maybe you should call ControlAtPos(aPoint, True).ClassName; like ControlAtPos(aPoint, True, True).ClassName; if your child controls are TWinControls. SIGSEGV is because result of ControlAtPos() is Nil.
Title: Re: Scrollbox Controlatpos
Post by: pcurtis on December 09, 2021, 09:41:53 am
Thanks. It works.
TinyPortal © 2005-2018