2015-03-10 0:33 GMT+08:00 OBones <obo...@free.fr>:
> How about using TMethod? > > procedure DataHandler(DummySelf: Pointer; data: Pointer); > begin > // do what you want to do, DummySelf is always nil. > end; > > var > Method: TMethod; > begin > Method.Data := nil; > Method.Code := @DataHandler; > > SetHandler(TDataHandler(Method)); > end; > I'm not sure how this works, but it seems that you are deliberately converting a normal procedure to a method. What I want is exactly opposite - I want to convert a method to a normal procedure. If I define the interfact of DataHandler like this: TDataHandler = procedure(data: Pointer); cdecl; It is very easy to use in an so, no matter it is written in C or pascal. But the problem is, I want to do this: SetHandler(h); where h is a METHOD, not a normal procedure. Because I want to use the handler wrapped in my Class. However, like in my first mail, if I define THandler a procedure of object, it makes easier to SetHandler(AMethod); but how can I use that "procedure of object" pointer in the so? Thanks!
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal