On Thu, 27 Aug 2009, Pritpal Bedi wrote:

Hi,

> > error is 0x80040200 (CONNECT_E_NOCONNECTION), MSDN says:
> > "CONNECT_E_NOCONNECTION Error
> > The CONNECT_E_NOCONNECTION error is returned when AtlAdvise() calls the 
> > IConnectionPointContainer::FindConnectionPoint() method and fails. The ATL 
> > implementation of the IConnectionPointContainerImpl::FindConnectionPoint() 
> > function looks in the connection point map for the event interface and
> > returns 
> > this error if it doesn't find it."
> Now I remember why I used another appproach to detect the 
> Connection Point in GTWVG. I believe some OLE's are misaligned 
> ( I have few ) which do not confirm to FindConnectionPoint() method.
> I had to enumerate all entry points and then Advise() if one is matching.
> I struggled onto this point so many days.
> Mindaugas is the right person to extend on this subject.

Looking at the code I see one important difference between our new AX
code and GTWVG/HWGUI.
New AX code calls

   lOleError = HB_VTBL( pCPC )->FindConnectionPoint( HB_THIS_( pCPC )
                                       HB_ID_REF( IID_IDispatch ), &pCP );

to take connection point but GTWVG and HWGUI use different method.
They make sth like:

   IEnumConnectionPoints* pEnumCPs = NULL;
   IID                    rriid = IID_IUnknown;

   lOleError = HB_VTBL( pCPC )->EnumConnectionPoints( HB_THIS_( pCPC )
                                                      &pEnumCPs );
   if( lOleError == S_OK )
   {
      do
      {
         lOleError = HB_VTBL( pEnumCPs )->Next( HB_THIS_( pEnumCPs ) 1,
                                                &pCP, NULL );
         if( lOleError == S_OK )
         {
            lOleError = HB_VTBL( pCP )->GetConnectionInterface(
                                                   HB_THIS_( pCP ) &rriid );
            if( lOleError == S_OK )
               break;
         }
      }
      while( lOleError == S_OK );
      HB_VTBL( pEnumCPs )->Release( HB_THIS( pEnumCPs ) );
   }

and they store rriid inside own OLE structure so it cean be used in
QueryInterface() method, i.e.:

   static HRESULT STDMETHODCALLTYPE QueryInterface( IDispatch* lpThis,
                                                REFIID riid, void** ppRet )
   {
      if( IsEqualIID( riid, HB_ID_REF( IID_IUnknown ) ) ||
          IsEqualIID( riid, HB_ID_REF( IID_IDispatch ) ) ||
          IsEqualIID( riid, HB_ID_REF( ( ( ISink* ) lpThis )->rriid ) ) )
      {
         *ppRet = ( void* ) lpThis;
         HB_VTBL( lpThis )->AddRef( HB_THIS( lpThis ) );
         return S_OK;
      }
      *ppRet = NULL;
      return E_NOINTERFACE;
   }

I can add such method to our new AX code if FindConnectionPoint() fails.
Anyhow I would like to ask Mindaugas to accept it and you and Alex to make
tests.

best regards,
Przemek
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to