Recent

Author Topic: (SOLVED) TToolButton question  (Read 2629 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2261
    • Lazarus and Free Pascal italian community
(SOLVED) TToolButton question
« on: December 14, 2011, 03:17:44 pm »
Hello guys, I create a TToolBar at run time by creating some TToolButton and run-time check all the steps @ MyProcedure
How do I know in

procedure TForm1.MyProcedure(Sender: TObject);

TCoolButton which I hold?
« Last Edit: December 14, 2011, 04:49:22 pm by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: TToolButton question
« Reply #1 on: December 14, 2011, 03:59:08 pm »
(Sender as TControl).name

Edit: a more structured way of doing this is to assign a value to TControl.Tag when creating the control and then check (Sender as TControl).Tag. This avoids testing strings.
 
« Last Edit: December 14, 2011, 04:13:09 pm by ludob »

xinyiman

  • Hero Member
  • *****
  • Posts: 2261
    • Lazarus and Free Pascal italian community
Re: TToolButton question
« Reply #2 on: December 14, 2011, 04:49:10 pm »
Thank you. is perfect  :)
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018