<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
It is certainly an interesting method of bypass and rerouting a method.
Reminds me of heart surgery triple bypass performed by an icing chef ;)<br>
<br>
Ross Levis wrote:
<blockquote cite="mid013601c5860e$c4bc8340$5100a8c0@levis4" type="cite">
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2668" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">I just noticed a bug which I'll
await Rob to fix it. The Result value of any functions being called is
not being returned to the caller (DLL). Perhaps this is due to the
parameters being shifted one position.</font></div>
<div> </div>
<div><font face="Arial" size="2">Ross.</font></div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;"
dir="ltr">
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">-----
Original Message ----- </div>
<div
style="background: rgb(228, 228, 228) none repeat scroll 0%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>From:</b>
<a title="ross@stationplaylist.com"
href="mailto:ross@stationplaylist.com">Ross Levis</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>To:</b>
<a title="delphi@ns3.123.co.nz" href="mailto:delphi@ns3.123.co.nz">NZ
Borland Developers Group - Delphi List</a> </div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Sent:</b>
Monday, July 11, 2005 11:31 PM</div>
<div
style="font-family: arial; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"><b>Subject:</b>
Re: [DUG] call a method function from outside object</div>
<div><br>
</div>
<div><font face="Arial" size="2">It's attached. Below are Rob's
instructions for use. I found I had to add a dummy parameter in the
method declarations otherwise the parameter values were shifted one to
the right.</font></div>
<div> </div>
<div>To use it, start by declaring data types for your function and
method <br>
pointers:<br>
<br>
type<br>
TConfigFunction = procedure(ParentWindow: HWnd); cdecl;<br>
TConfigMethod = procedure(ParentWindow: HWnd) of object; stdcall;<br>
<br>
TCanWriteFunction = function: Integer; cdecl;<br>
TCanWriteMethod = function: Integer of object; stdcall;<br>
<br>
The calling conventions differ on purpose. It just makes things a lot <br>
easier that way.<br>
<br>
When you instantiate your object, call my MakeCdeclInstance function to
<br>
create a wrapper for your method.<br>
<br>
type<br>
TWinampPlugIn = class<br>
private<br>
FConfig: TConfigFunction;<br>
FCanWrite: TCanWriteFunction;<br>
procedure Config(ParentWindow: HWnd); stdcall;<br>
function CanWrite: Integer; stdcall;<br>
public<br>
constructor Create;<br>
destructor Destroy; override;<br>
end;<br>
<br>
constructor TWinampPlugIn.Create;<br>
var<br>
Method: TMethod;<br>
ConfigMethod: TConfigMethod;<br>
CanWriteMethod: TCanWriteMethod;<br>
begin<br>
inherited;<br>
ConfigMethod := Config;<br>
Method := TMethod(ConfigMethod);<br>
FConfig := MakeCdeclInstance(Method, SizeOf(HWnd));<br>
CanWriteMethod := CanWrite;<br>
Method := TMethod(CanWriteMethod);<br>
FCanWrite := MakeCdeclInstance(Method, 0);<br>
end;<br>
<br>
destructor TWinampPlugIn.Destroy;<br>
begin<br>
FreeCdeclInstance(@FCanWrite);<br>
FreeCdeclInstance(@FConfig);<br>
inherited;<br>
end;<br>
<br>
After that, FConfig and FCanWrite are regular standalone-function <br>
pointers. When you or the DLL call them, though, they will call the <br>
corresponding method on a specific instance of the TWinampPlugIn class.</div>
</blockquote>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Delphi mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a>
<a class="moz-txt-link-freetext" href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</a>
</pre>
</blockquote>
</body>
</html>