On 15/07/14 20:56, rupert THURNER wrote:

var
   button: TSpeedButton;
begin
   button:=TSpeedButton.Create(self);
   button.OnClick:=SpeedButton1Click(button);
   // gives error:
   // unit1.pas(121,19) Error: Incompatible types: got "untyped" expected
"<procedure variable type of procedure(TObject) of object;Register>"

You are calling the function SpeedButton1Click here (with the parameter "button") and trying to assign its result to button.OnClick. Since SpeedButton1Click is a procedure, it does not return a value (= "void"), hence the error message.

What you want/need to do instead, is assign the address of the SpeedButton1Click procedure to button.OnClick. How this is done, depends on the syntax mode. In ObjFPC mode (the default in Lazarus), it's "button.OnClick:=@SpeedButton1Click;". In Delphi mode, it's "button.OnClick:=SpeedButton1Click;".


Jonas

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to