rather than supporting events, support callbacks. Almost the same thing, but slightly different way of going about it.
 
For example, in your DLL you can have an Setup routine that is passed a record with the addresses of the routines that you want to handle an event. The DLL can store those addresses so that when the event should take place, it's actually calling a procedure.
 
eg (with just a single event):
 
unit ComonUnit
...
Type
  TMyProc = procedure(SomeParameter : SomeType....);
...
end;
_______________________
unit MyDLL
 
uses CommonUnit
...
var
  dllcallback : Pointer;
 
procedure Setup(aCallBack : Pointer);
begin
  dllcallback := aCallBack;
end;
 
procedure SomeProc;
begin
  ...
  if Assigned(dllcallback) then TMyProc(dllcallback)(parameters...);
end;
 
exports
   Setup .....
...
 
end.
__________________
unit MyApp
 
interface
uses CommonUnit;
procedure Setup(blah blah); stdcall; external 'MyDLL';
...
impementation
....
procedure MyRealProc(same parameter types as TMyProc);
begin
...
end;
 
procedure SomeKindOfSetupProcedure;
begin
  Setup(MyRealProc);    //or maybe Setup(@MyProc) can't remember which
end;
 
____________________
This is more or less it. You'll have to shake out the bugs.
 
Phil.
----- Original Message -----
Sent: Sunday, February 11, 2001 4:21 PM
Subject: [DUG]: Events in DLLS

HI all....another DLL question.
 
The DLL I am using can raise events when something happens,
i.e    function incomingevent: Smallint; stdcall; external 'mydll';
 
how do I code for this ? do I do something like,
 
property OnEventHappeing : Integer read incomingevent   ??
 
Cheers, Jeremy Coulter

Reply via email to