Data Sharing

Overview

The io.Connect Channels are enabled by default when registering a VBA window as an io.Connect Window. You have to provide handler implementations for the Channel related events that will be raised due to interaction with the io.Connect Window instance - changing Channels and handling Channel data updates. When the io.Connect Channels are enabled, a Channel Selector box is available in the window title bar.

To check whether the Channel Selector is visible, use the GetChannelSupport method of a GlueWindow instance. To hide or show the Channel Selector, use the SetChannelSupport method.

⚠️ Note that currently the SetChannelSupport method only hides or shows the Channel Selector, but doesn't enable or disable the Channel support. This can be done only during window registration.

' Hiding the Channel selector.
GlueWin.SetChannelSupport False

Handling Channel Change

The HandleChannelChanged event is raised when the user changes the Channel using the Channel selection box in the window title bar. Use its handler to enable your app to react to Channel changes:

Private Sub GlueWin_HandleChannelChanged(ByVal GlueWindow As IGlueWindow, ByVal ChannelContext As IGlueContext, ByVal PrevChannelName As String)
    On Error GoTo HandleErrors

    Dim ChannelDataDynValue
    Dim NewData
    Dim NewChannelName As String

    If channel Is Nothing Then
        ' Do something when the user deselects a Channel.
        ...
    Else
        ChannelDataDynValue = ChannelContext.GetReflectData("")
        NewChannelName = ChannelDataDynValue("name")
        NewData = ChannelDataDynValue("data")
        ' Do something when the user selects a new Channel.
        ...
    End If
    Exit Sub

    HandleErrors:
    ' Handle exceptions.

End Sub

Subscribing for Channel Updates

To subscribe for Channel data updates, use the HandleChannelData event which is raised in two cases:

  • when the data in the currently selected Channel is updated;
  • after the HandleChannelChanged event, when the user switches to another Channel;
Private Sub GlueWin_HandleChannelData(ByVal GlueWindow As IGlueWindow, ByVal ChannelUpdate As IGlueContextUpdate)
    On Error GoTo HandleErrors

    Dim ChannelDataDynValue
    Dim Data
    Dim ChannelName As String

    ChannelDataDynValue = ChannelUpdate.GetContext.GetReflectData("")
    ChannelName = ChannelDataDynValue("name")
    Data = ChannelDataDynValue("data")
    ' Do something with the new data.
    ...
    Exit Sub

    HandleErrors:
    ' Handle exceptions.

End Sub

Publishing Data

To publish data to a Channel, you must update the shared context object dedicated the respective Channel. For details on how to update a shared context object, see the Shared Contexts > Updating a Context section.

⚠️ Note that you must only update the value of the "data" property of the context object. The "name" and "meta" properties must not be modified, because they are specifically set for each Channel.