What does the SetCurrentContext subroutine look like? Do you pass the ERD context of SampleInfo.pdi to a parent display?
3 of 3 people found this helpful
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 ThisDisplay.Maximize ThisDisplay.Activate 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.
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!
1 of 1 people found this helpful
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.