-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoooEvents2.pas
67 lines (54 loc) · 1.73 KB
/
oooEvents2.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
unit oooEvents2;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj, ActiveX, AxCtrls, Classes, oooEvents_TLB, StdVcl;
type
TListener = class(TAutoObject, IConnectionPointContainer, IListener)
private
{ Private declarations }
FConnectionPoints: TConnectionPoints;
FConnectionPoint: TConnectionPoint;
FEvents: IListenerEvents;
{ note: FEvents maintains a *single* event sink. For access to more
than one event sink, use FConnectionPoint.SinkList, and iterate
through the list of sinks. }
public
procedure Initialize; override;
protected
{ Protected declarations }
property ConnectionPoints: TConnectionPoints read FConnectionPoints
implements IConnectionPointContainer;
procedure EventSinkChanged(const EventSink: IUnknown); override;
procedure disposing; safecall;
procedure notifyEvent(const event: IDispatch); safecall;
end;
implementation
uses ComServ, oooEvents1;
procedure TListener.EventSinkChanged(const EventSink: IUnknown);
begin
FEvents := EventSink as IListenerEvents;
end;
procedure TListener.Initialize;
begin
inherited Initialize;
FConnectionPoints := TConnectionPoints.Create(Self);
if AutoFactory.EventTypeInfo <> nil then
FConnectionPoint := FConnectionPoints.CreateConnectionPoint(
AutoFactory.EventIID, ckSingle, EventConnect)
else FConnectionPoint := nil;
end;
procedure TListener.disposing;
begin
end;
procedure TListener.notifyEvent(const event: IDispatch);
var
e: OleVariant;
begin
e:= event;
form1.Memo1.Lines.Add('Event: '+e.EventName);
end;
initialization
TAutoObjectFactory.Create(ComServer, TListener, Class_Listener,
ciMultiInstance, tmApartment);
end.