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;
20 FOnMouseDown: TDocumentContextMenuEvent;
23 function QueryInterface(const IID:TGUID; out Obj): HRESULT; stdcall;
24 function _AddRef:Integer; stdcall;
25 function _Release:Integer; stdcall;
27 function GetTypeInfoCount(out Count: Integer): HRESULT; stdcall;
28 function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HRESULT; stdcall;
29 function GetIDsOfNames(const IID: TGUID; Names: Pointer;
30 NameCount, LocaleID: Integer; DispIDs: Pointer): HRESULT; stdcall;
31 function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
32 Flags: Word; var Params; VarResult, ExcepInfo, ArgErr:Pointer): HRESULT; stdcall;
34 constructor Create(AOwner: TObject; ADisp: IDispatch; const AIID: TGUID);
35 destructor Destroy; override;
36 property OnContextMenu: TDocumentContextMenuEvent read FOnContextMenu write FOnContextMenu;
37 property OnClick: TDocumentContextMenuEvent read FOnClick write FOnClick;
38 property OnMouseMove: TDocumentContextMenuEvent read FOnMouseMove write FOnMouseMove;
39 property OnMouseDown: TDocumentContextMenuEvent read FOnMouseDown write FOnMouseDown;
44 function THTMLDocumentEventSink._AddRef: Integer;
49 function THTMLDocumentEventSink._Release: Integer;
54 constructor THTMLDocumentEventSink.Create(AOwner: TObject; ADisp: IDispatch; const AIID: TGUID);
60 InterfaceConnect(FSimpleDisp, FSimpleIID, Self, FSimpleCon);
63 destructor THTMLDocumentEventSink.Destroy;
65 InterfaceDisconnect(FSimpleDisp,FSimpleIID,FSimpleCon);
69 function THTMLDocumentEventSink.GetIDsOfNames(const IID: TGUID; Names: Pointer;
70 NameCount, LocaleID: Integer; DispIDs: Pointer): HRESULT;
75 function THTMLDocumentEventSink.GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HRESULT;
80 function THTMLDocumentEventSink.GetTypeInfoCount(out Count: Integer): HRESULT;
86 function THTMLDocumentEventSink.Invoke(DispID: Integer; const IID: TGUID;
87 LocaleID: Integer; Flags: Word; var Params; VarResult, ExcepInfo,
88 ArgErr: Pointer): HRESULT;
92 if Assigned(FOnMouseDown) then begin
93 PVariant(VarResult)^ := FOnMouseDown(FOwner);
96 if Assigned(FOnMouseMove) then begin
97 PVariant(VarResult)^ := FOnMouseMove(FOwner);
100 if Assigned(FOnClick) then begin
101 PVariant(VarResult)^ := FOnClick(FOwner);
104 if Assigned(FOnContextMenu) then begin
105 PVariant(VarResult)^ := FOnContextMenu(FOwner);
111 function THTMLDocumentEventSink.QueryInterface(const IID: TGUID; out Obj): HRESULT;
113 Result := E_NOINTERFACE;
114 if GetInterface(IID,Obj) then
116 if IsEqualGUID(IID,FSimpleIID) and GetInterface(IDispatch,Obj) then