Recent

Author Topic: [SOLVED] Scrollbox Controlatpos  (Read 2080 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 848
[SOLVED] Scrollbox Controlatpos
« 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
« Last Edit: December 09, 2021, 09:42:55 am by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

zeljko

  • Hero Member
  • *****
  • Posts: 1206
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Scrollbox Controlatpos
« Reply #1 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.

pcurtis

  • Hero Member
  • *****
  • Posts: 848
Re: Scrollbox Controlatpos
« Reply #2 on: December 09, 2021, 09:41:53 am »
Thanks. It works.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

 

TinyPortal © 2005-2018