Figure 1   Getting a Control's IUnknown


 void CUseinvisctlDlg::OnDoitqi() 
 {
     UpdateData(TRUE);
     IInvisCtl* pInvisCtl = 0;
     IUnknown* pUnk = 0;
 
     pUnk = m_invisCtl.GetControlUnknown();
 
     if(pUnk) {
         pUnk->QueryInterface(IID_IInvisCtl, (void**)&pInvisCtl);
         if(pInvisCtl) {
             double d = m_invisCtl.SquareRoot(m_lNumber);
             m_strSquareRoot.Format("%f" , d);
             pInvisCtl->Release();
         }
     }
     UpdateData(FALSE);
 }

Figure 2   The ODL File for the Client Application


 [
 uuid(93BC134B-065C-11D2-ABCD-A5273A388638),
 helpstring("_IInvisCtlEvents Interface")
 ]
 
 dispinterface _IInvisCtlEvents
 {
 
     properties:
     // NOTE - ClassWizard will maintain property information here.
     //    Use extreme caution when editing this section.
     //{{AFX_ODL_PROP(InvisCtlEvents)
     //}}AFX_ODL_PROP
     
     methods:
     // NOTE - ClassWizard will maintain method information here.
     //    Use extreme caution when editing this section.
     //{{AFX_ODL_METHOD(InvisCtlEvents)
         [id(1)] void CalculatedSquareRoot(double d);
         [id(2)] void HadAGoodTime();
 
     //}}AFX_ODL_METHOD
 
 };

Figure 3   Connecting Up the Event Sink


 if(m_pInvisCtl) {
     IConnectionPointContainer* pCPC = 0;
     m_pInvisCtl->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPC);
 
     if(pCPC) {
         IProvideClassInfo2* pPCI = 0;
         m_pInvisCtl->QueryInterface(IID_IProvideClassInfo2, (void**)&pPCI);
  
         if(pPCI) {
             IID iidEventSet;
             HRESULT hr =
                 pPCI->GetGUID(GUIDKIND_DEFAULT_SOURCE_DISP_IID,
                               &iidEventSet);
 
             if(SUCCEEDED(hr)) {
                 IConnectionPoint* pCP = 0;
                 pCPC->FindConnectionPoint(iidEventSet, &pCP);
 
                 if(pCP) {
                     pCP->Advise(m_invisCtlEvents.GetIDispatch(TRUE),
                                 &m_dwEventCookie); 
                     pCP->Release();
                 }
             }
 
             pPCI->Release();
         }
 
         pCPC->Release();
     }
 }