<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><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>
</HEAD>
<BODY text=#000000 bgColor=#ffffff>
<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><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Ross.</FONT></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=ross@stationplaylist.com href="mailto:ross@stationplaylist.com">Ross
Levis</A> </DIV>
<DIV style="FONT: 10pt arial"><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: 10pt arial"><B>Sent:</B> Monday, July 11, 2005 11:31
PM</DIV>
<DIV style="FONT: 10pt arial"><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><FONT face=Arial size=2></FONT> </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></BODY></HTML>