OnClick must be set to the address of a TNotifyEvent compatible method:
ie: TNotifyEvent is defined as:
TNotifyEvent = procedure(Sender: TObject) of object;
Therefore your method must be: (Note: The method name can be changed)
procedure Tfrm_addnew.ButtonClick(Sender: TObject);
begin
end;
Then link the OnClick event to the TButton using:
btns.OnClick := @ButtonClick;
// Or, for Delphi mode, use: (Note: In Delphi mode the @ isn't required)
btns.OnClick := ButtonClick;
http://wiki.freepascal.org/TButtonThere are a lot of different event types, so its common practice to use the popupmenu tool"Find declaration of ???? ...", and then copy/paste the event prototype into your class.
** EDIT **
TButtons have a Tag property which you can use to store the Index (Which must me set in your for loop).
You can get the button that was clicked using (Sender as TButton), and therefore you can get the Index of the button using (Sender as TButton).Tag.