فهرست منبع

* eventconnect/disconnect moved, Mantis #25888

git-svn-id: trunk@27302 -
marco 11 سال پیش
والد
کامیت
3311ef4d48
2فایلهای تغییر یافته به همراه32 افزوده شده و 30 حذف شده
  1. 32 0
      packages/winunits-base/src/comobj.pp
  2. 0 30
      packages/winunits-base/src/eventsink.pp

+ 32 - 0
packages/winunits-base/src/comobj.pp

@@ -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

+ 0 - 30
packages/winunits-base/src/eventsink.pp

@@ -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);