When you are creating components at run time, and want to assign a procedure to an event handler of a component, like in the following code:

procedure ButtonClick(Sender:TObject) ;
begin
//whatever
end;
 
procedure SomeProcedure...
var aButton:TButton;
begin
   aButton := TButton.Create(nil) ;
   aButton.OnClick = ButtonClick
...
end;

You will get the next error: Incompatible type: 'method pointer and regular procedure'.

The problem is that a method pointer (OnClick) needs to be a procedure of an object (like TForm), not a regular procedure. One way around is to create an object to define the procedure. You can start by creating a dummy class...

interface
type
   TEventHandlers = class // create a dummy class
       procedure ButtonClick(Sender: TObject) ;
   end;
 
...
 
var EvHandler:TEventHandlers;
 
implementation
 
procedure TEventHandlers.ButtonClick(Sender: TObject) ;
begin
   // your code here
end;
 
...
procedure SomeProcedure...
var aButton:TButton;
begin
   aButton := TButton.Create(nil) ;
   aButton.OnClick = ButtonClick;
...
end;

Notice: Undefined variable: browserName in /var/www/taziomirandola.it/lib/Visitors.php on line 86

Notice: Undefined variable: browserName in /var/www/taziomirandola.it/lib/Visitors.php on line 96

Deprecated: strripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /var/www/taziomirandola.it/lib/Visitors.php on line 96

Notice: Undefined index: HTTP_ACCEPT_LANGUAGE in /var/www/taziomirandola.it/lib/Visitors.php on line 39

Fatal error: Uncaught TypeError: Argument 1 passed to safe_text() must be of the type string, null given, called in /var/www/taziomirandola.it/lib/Visitors.php on line 39 and defined in /var/www/taziomirandola.it/lib/Visitors.php:162 Stack trace: #0 /var/www/taziomirandola.it/lib/Visitors.php(39): safe_text() #1 /var/www/taziomirandola.it/lib/Visitors.php(124): Visitors::getData() #2 [internal function]: Visitors::log() #3 {main} thrown in /var/www/taziomirandola.it/lib/Visitors.php on line 162