<!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&nbsp;which I'll await Rob to 
fix it.&nbsp; The Result value of any functions being called is not being 
returned to the caller (DLL).&nbsp; Perhaps this is&nbsp;due to the parameters 
being shifted one position.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</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.&nbsp; Below are Rob's instructions 
  for use.&nbsp; 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>&nbsp;</DIV>
  <DIV>To use it, start by declaring data types for your function and method 
  <BR>pointers:<BR><BR>type<BR>&nbsp;&nbsp; TConfigFunction = 
  procedure(ParentWindow: HWnd); cdecl;<BR>&nbsp;&nbsp; TConfigMethod = 
  procedure(ParentWindow: HWnd) of object; stdcall;<BR><BR>&nbsp;&nbsp; 
  TCanWriteFunction = function: Integer; cdecl;<BR>&nbsp;&nbsp; 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>&nbsp;&nbsp; TWinampPlugIn = 
  class<BR>&nbsp;&nbsp; private<BR>&nbsp;&nbsp;&nbsp;&nbsp; FConfig: 
  TConfigFunction;<BR>&nbsp;&nbsp;&nbsp;&nbsp; FCanWrite: 
  TCanWriteFunction;<BR>&nbsp;&nbsp;&nbsp;&nbsp; procedure Config(ParentWindow: 
  HWnd); stdcall;<BR>&nbsp;&nbsp;&nbsp;&nbsp; function CanWrite: Integer; 
  stdcall;<BR>&nbsp;&nbsp; public<BR>&nbsp;&nbsp;&nbsp;&nbsp; constructor 
  Create;<BR>&nbsp;&nbsp;&nbsp;&nbsp; destructor Destroy; 
  override;<BR>&nbsp;&nbsp; end;<BR><BR>constructor 
  TWinampPlugIn.Create;<BR>var<BR>&nbsp;&nbsp; Method: TMethod;<BR>&nbsp;&nbsp; 
  ConfigMethod: TConfigMethod;<BR>&nbsp;&nbsp; CanWriteMethod: 
  TCanWriteMethod;<BR>begin<BR>&nbsp;&nbsp; inherited;<BR>&nbsp;&nbsp; 
  ConfigMethod := Config;<BR>&nbsp;&nbsp; Method := 
  TMethod(ConfigMethod);<BR>&nbsp;&nbsp; FConfig := MakeCdeclInstance(Method, 
  SizeOf(HWnd));<BR>&nbsp;&nbsp; CanWriteMethod := CanWrite;<BR>&nbsp;&nbsp; 
  Method := TMethod(CanWriteMethod);<BR>&nbsp;&nbsp; FCanWrite := 
  MakeCdeclInstance(Method, 0);<BR>end;<BR><BR>destructor 
  TWinampPlugIn.Destroy;<BR>begin<BR>&nbsp;&nbsp; 
  FreeCdeclInstance(@FCanWrite);<BR>&nbsp;&nbsp; 
  FreeCdeclInstance(@FConfig);<BR>&nbsp;&nbsp; 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>