I think you'd better
  TOnProgressEvent=procedure (x:integer) of object;
And instead of proc1 have a method that belongs to an object (say to your
Tform-descendent form) as the handler

Although it's not classic event handling style, I don't see why your code
shouldn't work, apart from the fact that you declare it as a property and
maybe FPC requires in that case that you use only a method pointer. Maybe
Delphi is more clever and allows Procedure and Function pointer types there
too. You could file it as an FPC bug if so. In the mean time, remove the
property and make the private field fOnProgress:TOnProgressEvent a public
one (maybe rename it to OnProgress too) and talk to it directly

If you want to use this with the Lazarus IDE, you have to use the "of
object" that I say above and not use "proc1" (a procedure) but
"SomeClass.proc1" (a method) as the event handler

> A short example:
>
> type
>
>    TOnProgressEvent=procedure (x:integer);
>
>    TObj=class(TObject)
>    private
>      FOnProgress:TOnProgressEvent;
>    public
>      property OnProgress:TOnProgressEvent read FOnProgress
> write FOnProgress;
>    end;
>
> procedure proc1(x:integer);
> begin
> end;
>
> var
>    Obj:TObj;
>
> begin
>    Obj:=TObj.Create;
>    Obj.OnProgress:=proc1;
> end.
>
> My problem is: I get an "Error: Wrong number of parameters specified"
> error message on "Obj.OnProgress:=proc1;" line.
>
> My question is why? I tried this with Delphi and working.




  _____  

avast! Antivirus <http://www.avast.com> : Outbound message clean. 


Virus Database (VPS): 0626-3, 29/06/2006
Tested on: 30/6/2006 11:29:22 p?
avast! - copyright (c) 1988-2006 ALWIL Software.



_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to