* fix from mantis #22156 to wholly implement iunknown or not.

TAbstractEventSink no longer descends from Tinterfacedobject.
   Patch by Ludo

git-svn-id: trunk@21652 -
This commit is contained in:
marco 2012-06-19 08:55:40 +00:00
parent e0b41141d2
commit 3ffa6bf2f3

View File

@ -41,7 +41,9 @@ type
const IID: TGUID; LocaleID: Integer; Flags: Word; const IID: TGUID; LocaleID: Integer; Flags: Word;
Params: TDispParams; VarResult, ExcepInfo, ArgErr: Pointer) of object; Params: TDispParams; VarResult, ExcepInfo, ArgErr: Pointer) of object;
TAbstractEventSink = class(TInterfacedObject, IDispatch) { TAbstractEventSink }
TAbstractEventSink = class(TObject, IDispatch,IUnknown) // see mantis #22156
private private
FDispatch: IDispatch; FDispatch: IDispatch;
FDispIntfIID: TGUID; FDispIntfIID: TGUID;
@ -49,7 +51,10 @@ type
FOwner: TComponent; FOwner: TComponent;
protected protected
{ IUnknown } { IUnknown }
frefcount : longint;
function QueryInterface(constref IID: TGUID; out Obj): HRESULT; stdcall; function QueryInterface(constref IID: TGUID; out Obj): HRESULT; stdcall;
function _AddRef : longint;stdcall;
function _Release : longint;stdcall;
{ IDispatch } { IDispatch }
function GetTypeInfoCount(out Count: Integer): HRESULT; stdcall; function GetTypeInfoCount(out Count: Integer): HRESULT; stdcall;
function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HRESULT; stdcall; function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HRESULT; stdcall;
@ -166,6 +171,20 @@ begin
Result := S_OK; Result := S_OK;
end; end;
function TAbstractEventSink._AddRef: longint; stdcall;
begin
frefcount:=frefcount+1;
_addref:=frefcount;
end;
function TAbstractEventSink._Release: longint; stdcall;
begin
frefcount:=frefcount-1;
_Release:=frefcount;
if frefcount=0 then
self.destroy;
end;
procedure TAbstractEventSink.Connect(AnAppDispatch: IDispatch; procedure TAbstractEventSink.Connect(AnAppDispatch: IDispatch;
const AnAppDispIntfIID: TGUID); const AnAppDispIntfIID: TGUID);
begin begin