4 Replies Latest reply on Mar 7, 2013 7:41 PM by opelosi

    Create an event handler in ActiveX control to the DataUpdate event

      Hi everyone

       

       

       

      I'm developing a ActiveX control for ProcessBook that acts like any other symbol. It must retreive a point's snapshot value and display it. But I can't find any documentation that explain how to attach an event handler to the DataUpdate event. I'm aware that I can create a function which can be called by Display's DataUpdate event using VBA but this is the worse case for me since the control must act like a symbol (place and let the PB update it).

       

      So, there is any way to connect my ActiveX control event handler to the PB's DataUpdate event?

       

       

       

      Thanks for the help

        • Re: Create an event handler in ActiveX control to the DataUpdate event
          Asle Frantzen

          Hi Orlando

           

          From my object browser in Visual Studio I can read this:

           

           

           

          public virtual event

           

          PBSymLib.EValue_DataUpdateEventHandler DataUpdate

           

              Member of

           

          PBSymLib.ValueClass

           

           

           

          which is part of the file C:\Program Files (x86)\PIPC\Procbook\PublicAssemblies\OSIsoft.PBSymLib.dll, so just add a reference to that and you'll be on your way.

            • Re: Create an event handler in ActiveX control to the DataUpdate event

              Thanks for the help

               

              I can't use this delegate because the control is being developed using C++ (unmanaged). But, if I create an event with this delegate, will PB trigger it?

               

              I created an event using COM API and I can attach event handlers to it using PB's VBA, but it is not triggered by PB.

               

              What I really want is: when the PB updates the display's data, updade my control's data too.

                • Re: Create an event handler in ActiveX control to the DataUpdate event
                  Asle Frantzen

                  In my C# RegressionLine Addin I'm subscribing to ContextChanged events from ProcessBook, and that works flawlessly, so I don't see any obstacles with symbols and data updates.

                   

                  It's been a while since I used C++ so I can't really give any recommendations or experiences there.

                   

                   

                   

                  For another addin I had to create quickly I just added a value symbol to my display, set the Visible property to false, hooked on to the data update event using VBA, and relayed the updated value to my addin from there.

                    • Re: Create an event handler in ActiveX control to the DataUpdate event

                      I found a solution for my problem. The site support.microsoft.com/.../en-us shows how to create a sink class which can be used as an event handler.

                       

                      To work with Display's DataUpdate event, the user must create a class like the one demonstred on the link above but with a few changes like create the dispatch function with ID 11 (DataUpdate DISPID) and call AfxConnectionAdvise using the display as source with PBObjLib::EDisplay interface ID.

                       

                      The following code is the changes that I made to work with PB:

                       
                      BEGIN_DISPATCH_MAP(CDisplayEventsImpl, CCmdTarget)
                           DISP_FUNCTION_ID(CDisplayEventsImpl, "DataUpdate", 11, UpdateControlData, VT_EMPTY, VTS_NONE)
                      END_DISPATCH_MAP()
                      
                      BEGIN_INTERFACE_MAP(CDisplayEventsImpl, CCmdTarget)
                           INTERFACE_PART(CDisplayEventsImpl, __uuidof(PBObjLib::EDisplay), Dispatch)
                      END_INTERFACE_MAP()
                      
                      AfxConnectionAdvise(this->display, __uuidof(PBObjLib::EDisplay), this->displayEvents->GetIDispatch(FALSE), FALSE, &this->cookie);