1 unit HTMLDocumentEvent;
6 Windows, Classes, ActiveX, ComObj;
9 TDocumentContextMenuEvent = function(Sender: TObject): WordBool of object;
11 THTMLDocumentEventSink = class(TInterfacedObject,IUnknown,IDispatch)
14 FSimpleDisp: IDispatch;
17 FOnContextMenu: TDocumentContextMenuEvent;
18 FOnClick: TDocumentContextMenuEvent;
19 FOnMouseMove: TDocumentContextMenuEvent;
22 function QueryInterface(const IID:TGUID; out Obj): HRESULT; stdcall;
23 function _AddRef:Integer; stdcall;
24 function _Release:Integer; stdcall;
26 function GetTypeInfoCount(out Count: Integer): HRESULT; stdcall;
27 function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HRESULT; stdcall;
28 function GetIDsOfNames(const IID: TGUID; Names: Pointer;
29 NameCount, LocaleID: Integer; DispIDs: Pointer): HRESULT; stdcall;
30 function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
31 Flags: Word; var Params; VarResult, ExcepInfo, ArgErr:Pointer): HRESULT; stdcall;
33 constructor Create(AOwner: TObject; ADisp: IDispatch; const AIID: TGUID);
34 destructor Destroy; override;
35 property OnContextMenu: TDocumentContextMenuEvent read FOnContextMenu write FOnContextMenu;
36 property OnClick: TDocumentContextMenuEvent read FOnClick write FOnClick;
37 property OnMouseMove: TDocumentContextMenuEvent read FOnMouseMove write FOnMouseMove;
42 function THTMLDocumentEventSink._AddRef: Integer;
47 function THTMLDocumentEventSink._Release: Integer;
52 constructor THTMLDocumentEventSink.Create(AOwner: TObject; ADisp: IDispatch; const AIID: TGUID);
58 InterfaceConnect(FSimpleDisp, FSimpleIID, Self, FSimpleCon);
61 destructor THTMLDocumentEventSink.Destroy;
63 InterfaceDisconnect(FSimpleDisp,FSimpleIID,FSimpleCon);
67 function THTMLDocumentEventSink.GetIDsOfNames(const IID: TGUID; Names: Pointer;
68 NameCount, LocaleID: Integer; DispIDs: Pointer): HRESULT;
73 function THTMLDocumentEventSink.GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HRESULT;
78 function THTMLDocumentEventSink.GetTypeInfoCount(out Count: Integer): HRESULT;
84 function THTMLDocumentEventSink.Invoke(DispID: Integer; const IID: TGUID;
85 LocaleID: Integer; Flags: Word; var Params; VarResult, ExcepInfo,
86 ArgErr: Pointer): HRESULT;
90 if Assigned(FOnMouseMove) then begin
91 PVariant(VarResult)^ := FOnMouseMove(FOwner);
94 if Assigned(FOnClick) then begin
95 PVariant(VarResult)^ := FOnClick(FOwner);
98 if Assigned(FOnContextMenu) then begin
99 PVariant(VarResult)^ := FOnContextMenu(FOwner);
105 function THTMLDocumentEventSink.QueryInterface(const IID: TGUID; out Obj): HRESULT;
107 Result := E_NOINTERFACE;
108 if GetInterface(IID,Obj) then
110 if IsEqualGUID(IID,FSimpleIID) and GetInterface(IDispatch,Obj) then