2 Replies Latest reply on Dec 7, 2009 5:01 PM by dhollebeek

    Relative element assigned symbols




      I'm currently building some Element relative displays in processbook, and I am using some symbols to display some child elements of the selected context element. These symbols have child elements assigned to it, so users can browse the AF properties of this particular element by clicking on the displayed symbol.
      Now i'm searching for some code to update the assigned element in the background when a new element context is choosen.


      Can somebody help me with this?

        • Re: Relative element assigned symbols

          Hi Ben,


          I am assuming that you are trying to do this in VBA.


          In Processbook VBA, we can insert the following codes for Processbook to handle the event when user select a different element.

          'Declare a variable
          Dim WithEvents oContextHandler As ContextHandler

          ' Assuming that the display has already been configured for Element Relative (ERD)
          ' When display opens, goes through all contexthandlers and set oContextHandler as the Element Relative Context Handler
          Private Sub Display_Open()
              Dim oCH As ContextHandler
              For Each oCH In ThisDisplay.ContextHandlers
                  MsgBox "Name: " & oCH.Name & " Description: " & oCH.Description
                  If ("Element Relative Context Handler" = oCH.Description) Then
                      Set oContextHandler = oCH
                  Exit Sub
                  End If
              Next oCH
          ' Or just do this Set oContextHandler = ThisDisplay.ContextHandlers.Item(“ModuleContext Module Context Handler”)    
          End Sub

          Private Sub oContextHandler_ContextChanged(FromDisplay As Display, FromContextHAndler As ContextHandler)

              MsgBox (ThisDisplay.ContextHandlers.Item(1).Name)

          End Sub

          What I am still not aware of is how to access the currently selected element. What worked for Module Relative Display doesn't seem to work for Element Relative Display.


          I'll check out with the developers and get back with you on this. =)

            • Re: Relative element assigned symbols

              Here's some sample code for getting and setting the current context in ERD:

              ' Get the current context for this display and write it to the immediate window
              Sub get_currentcontext()
                  Dim ch As ContextHandler
                  Set ch = Application.ContextHandlers.Item("E")
                  Debug.Print (ch.CurrentContext(ThisDisplay))
              End Sub

              ' Set the current context for this display
              Sub set_currentcontext()
                  Dim ch As ContextHandler
                  Set ch = Application.ContextHandlers.Item("E")
                  ch.CurrentContext(ThisDisplay) = "\\dhollebeekt3400\database1\element2"
              End Sub

              ' List the current contexts for this display
              Sub list_contexts()
                  Dim ch As ContextHandler
                  Set ch = Application.ContextHandlers.Item("E")
                  Dim nv As PBNamedValue
                  For Each nv In ch.ContextData(ThisDisplay)
                      Debug.Print nv.Name & " = " & nv.Value
              End Sub