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.
|
- [DUG]: Events in DLLS Jeremy Coulter
- RE: [DUG]: Events in DLLS Phil Middlemiss
- RE: [DUG]: Events in DLLS Jeremy Coulter