[fpc-pascal] how do I get Run Time info from a published method?
Flávio Etrusco
flavio.etrusco at gmail.com
Wed Oct 1 17:55:02 CEST 2014
On Mon, Sep 29, 2014 at 11:54 PM, Dennis Poon <dennis at avidsoft.com.hk> wrote:
> say for example:
>
> type
> TmyClass = class
> published
> procedure Something (sender : Tobject);virtual;
> end;
>
> var
> myClass : TmyClass;
>
> then somewhere
>
> AddMethodToQueue(@myclass.Something);
>
>
> Is it possible within AddMethodToQueue, I can query the Run Time Type Info
> of the method passed in ?
>
>
>
> procedure AddMethodToQueue(const TheEvent : TNotifyEvent);
> var aMethodObjectname : String;
> begin
> //I can already do this
> aMethodObjectName := TObject(TMethod(TheEvent).Data).ToString;
>
> //how do I check the RTTI of TheEvent and get the name of the method
> i.e. 'Something'?
> //since it is published, it should be possible, right?
>
> end;
>
> Thanks in advance.
>
> Dennis
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Simply:
vObj := TObject(TMethod(TheEvent).Data);
vMethodName := vObj.MethodName(TMethod(TheEvent).Code);
?
Regards,
Flávio
More information about the fpc-pascal
mailing list