[ Solved ] howto set onmousemove handler after image.create lazarus / 21-General ---------------------------------------------------------------------- Jumbo · 2023-10-01 11:52 Cant find a solution for this: After creating an image on runtime, howto create the onmousmove handler.   Image1 := TImage.Create(Form1);   Image1.Parent := Form1;   ==>?  Image1.OnMouseMove:= ... ?<== I expect somting to write like: procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,   Y: Integer); begin   doing something ... end; But that just does not work ... ---------------------------------------------------------------------- Fibonacci · 2023-10-01 12:08 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);    procedure yourhandler(Sender: TObject; Shift: TShiftState; X, Y: Integer);  private  public  end; var  Form1: TForm1; implementation {$R *.lfm} procedure TForm1.yourhandler(Sender: TObject; Shift: TShiftState; X, Y: Integer);begin  Form1.Caption := IntToStr(X)+' x '+IntToStr(Y)+' -- your handler';end; procedure TForm1.Button1Click(Sender: TObject);var  Image1: TImage;begin  Image1 := TImage.Create(Form1);  Image1.Parent := Form1;   with Image1 do begin    Left := 0;    Top := 0;    Width := Form1.Width;    Height := Form1.Height;  end;   // this  //Image1.OnMouseMove := procedure(Sender: TObject; Shift: TShiftState; X, Y: Integer)  //begin  //  Form1.Caption := IntToStr(X)+' x '+IntToStr(Y)+' -- anon proc';  //end;   // or this  Image1.OnMouseMove := @yourhandler;end; For anonymouse functions you need {$modeswitch anonymousfunctions} and FPC trunk. I had to lower the FPS for the GIF to 9 to fit in allowed attachment max size of 500 kB ---------------------------------------------------------------------- Jumbo · 2023-10-01 12:57 Unbelievable simple....  Works as expected. Thanks a lot.