* eventconnect/disconnect moved, Mantis #25888

git-svn-id: trunk@27302 -
This commit is contained in:
marco 2014-03-27 19:05:38 +00:00
parent ec394b2495
commit 3311ef4d48
2 changed files with 32 additions and 30 deletions

View File

@ -290,6 +290,9 @@ unit comobj;
function StringToLPOLESTR(const Source: string): POLEStr;
procedure InterfaceConnect(const Source: IUnknown; const IID: TIID; const Sink: IUnknown; var Connection: DWORD);
procedure InterfaceDisconnect(const Source: IUnknown; const IID: TIID; var Connection: DWORD);
procedure DispatchInvoke(const Dispatch: IDispatch; CallDesc: PCallDesc;
DispIDs: PDispIDList; Params: Pointer; Result: PVariant);
procedure DispatchInvokeError(Status: HRESULT; const ExceptInfo: TExcepInfo);
@ -586,6 +589,35 @@ implementation
end;
procedure InterfaceConnect(const Source: IUnknown; const IID: TIID; const Sink: IUnknown; var Connection: DWORD);
var
CPC: IConnectionPointContainer;
CP: IConnectionPoint;
i: hresult;
begin
Connection := 0;
if Succeeded(Source.QueryInterface(IConnectionPointContainer, CPC)) then
if Succeeded(CPC.FindConnectionPoint(IID, CP)) then
i:=CP.Advise(Sink, Connection);
end;
procedure InterfaceDisconnect(const Source: IUnknown; const IID: TIID; var Connection: DWORD);
var
CPC: IConnectionPointContainer;
CP: IConnectionPoint;
i: hresult;
begin
if Connection <> 0 then
if Succeeded(Source.QueryInterface(IConnectionPointContainer, CPC)) then
if Succeeded(CPC.FindConnectionPoint(IID, CP)) then
begin
i:=CP.Unadvise(Connection);
if Succeeded(i) then Connection := 0;
end;
end;
procedure SafeCallErrorHandler(err : HResult;addr : pointer);
{$ifndef wince}
var

View File

@ -91,36 +91,6 @@ implementation
uses
ComObj;
procedure InterfaceConnect(const Source: IUnknown; const IID: TIID;
const Sink: IUnknown; var Connection: DWORD);
var
CPC: IConnectionPointContainer;
CP: IConnectionPoint;
i:hresult;
begin
Connection := 0;
if Succeeded(Source.QueryInterface(IConnectionPointContainer, CPC)) then
if Succeeded(CPC.FindConnectionPoint(IID, CP)) then
i:=CP.Advise(Sink, Connection);
end;
procedure InterfaceDisconnect(const Source: IUnknown; const IID: TIID;
var Connection: DWORD);
var
CPC: IConnectionPointContainer;
CP: IConnectionPoint;
i:hresult;
begin
if Connection <> 0 then
if Succeeded(Source.QueryInterface(IConnectionPointContainer, CPC)) then
if Succeeded(CPC.FindConnectionPoint(IID, CP)) then
begin
i:=CP.Unadvise(Connection);
if Succeeded(i) then Connection := 0;
end;
end;
{ TAbstractEventSink }
constructor TAbstractEventSink.Create(AOwner: TComponent);