<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace;font-size:large"><span style="font-family:arial,sans-serif;font-size:small">2015-03-10 0:33 GMT+08:00 OBones </span><span dir="ltr" style="font-family:arial,sans-serif;font-size:small"><<a href="mailto:obones@free.fr" target="_blank">obones@free.fr</a>></span><span style="font-family:arial,sans-serif;font-size:small">:</span><br></div><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><span style="color:rgb(34,34,34)">How about using TMethod?</span><br></div></div>
<br>
procedure DataHandler(DummySelf: Pointer; data: Pointer);<br>
begin<br>
// do what you want to do, DummySelf is always nil.<br>
end;<br>
<br>
var<br>
Method: TMethod;<br>
begin<br>
Method.Data := nil;<br>
Method.Code := @DataHandler;<br>
<br>
SetHandler(TDataHandler(<u></u>Method));<br>
end;<br></blockquote><div><br></div><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large;display:inline">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. </div></div><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large;display:inline"><br></div></div><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large;display:inline">If I define the interfact of DataHandler like this:</div></div><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large;display:inline"><br></div></div><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">TDataHandler = procedure(data: Pointer); cdecl;</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">It is very easy to use in an so, no matter it is written in C or pascal.</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">But the problem is, I want to do this:</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">SetHandler(h); </div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">where h is a METHOD, not a normal procedure.<br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">Because I want to use the handler wrapped in my Class.</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">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?</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large">Thanks!</div><br></div><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large;display:inline"><br></div></div><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large;display:inline"></div> </div></div></div></div>