4 Replies Latest reply on Jan 20, 2016 5:27 PM by sylpiette

    Opening display on top in Processbook


      Good afternoon everyone,


      In Processbook, I'm trying to open a display, in VBA. I have a button in a display, which VBA code is like this :


           Dim dis As Display


          Set dis = Application.Displays.Open("C:\SampleInfo.PDI", True)

          dis.SetCurrentContext "Some parameters"



      The display "SampleInfo.PDI" really has a sub "SetCurrentContext", which is used to pass a context to the display.


      When I hit the button to open the new display, it appears for few milliseconds, then it is sent to background, the calling display is back on top.


      Is there a way to force a display to be on top ?



      I've tried to minimize the calling display and maximize the new one, but it doesn't work. You also see that I'm calling the "Activate" method, without success.

        • Re: Opening display on top in Processbook

          Hi Sylvain,


          What does the SetCurrentContext subroutine look like? Do you pass the ERD context of SampleInfo.pdi to a parent display?

          • Re: Opening display on top in Processbook
            Rhys Kirk

            I had the same issue when remotely setting an Element Relative Context.

            In the end I had to fudge it...in the display being opened I had a hidden Text symbol that would either be "True" or "False". Symbol was named "JustOpened" and it would be set to "True" just after setting the context from the calling display. Then in the being opened display's DataUpdate Event, by default every 5 seconds, it would trigger the activate and set JustOpened to false to make sure it was the top most display. I never did find a better way to do it.





            Dim disp As Display
            Set disp = Application.Displays.Open(sDisplay, False)
                  disp.ContextHandlers("E").CurrentContext(disp) = sElement
                  disp.Symbols("JustOpened").Contents = "TRUE"


            Being opened ERD:

            Private Sub Display_DataUpdate()
                If Application.RunMode Then
                    If UCase(JustOpened.Contents) = "TRUE" Then
                        intFocus = intFocus + 1
                        If intFocus = 2 Then
                            intFocus = 0
                            JustOpened.Contents = "FALSE"
                        End If
                    End If
                End If
            End Sub


            Note: You don't have this issue in PI Coresight. I ended up moving the displays to PI Coresight and setting the Context via the PI Coresight URL parameters via a PB Button. Works much better.

            3 of 3 people found this helpful
            • Re: Opening display on top in Processbook

              Hello Sylvain,


              Have you find a solution to this ? Did Rhys answer helped you?


              As Anna said, that would be interesting to see what you are doing in the SetCurrentContext Sub.


              Keep us posted!

              • Re: Opening display on top in Processbook

                Sorry, I've not been able to test Rhys' solution until today.


                I've tried it and it works great. However, instead of using a hidden text field for the "JustOpened", I'm using a private boolean in each display. Also, in the "calling" display, I've added ThisDisplay.Minimize before opening the new display.


                About the SetCurrentContext sub, it dépends of the display : each of my displays have a SetCurrentContext sub, with different parameters. In the sub, I fill drop down menu, set text fields / labels, etc., according to the parameters passed. Parameters can be:


                - Which batch we want to see

                - From which production unit

                - Do we want to add a new sample lab or we want to edit an existing one


                Using AF context could have been a good idea, but the project is at its end and I have no time to rewrite everything. Like most projects, it started with very few simple displays, then the requirements started to change while users where testing the tool.

                1 of 1 people found this helpful