Well, you'd think that should be something that's exposed in the ProcessBook object model, but it hasn't turned up in any of my poking around on the Application, Displays or Display object properties and methods.
Maybe someone else will be able to help you, but if you really need this and don't want to wait (if it's NOT in the object model, you could have a long wait..) then you'll probably have to create a way to keep track of that.
You could start with a VBA FIFO stack class - a net search should turn up a bunch of them. You'll also need a ProcessBook Application events class - see the ProcessBook help file for 'Example for Application ModeChange Events' for how to set one up - here's another go-by:
Code:
Public WithEvents test As Application
Private Sub test_AfterModeChange(ByVal bRunMode As Boolean)
Debug.Print "AfterModeChanged"
End Sub
Private Sub test_BeforeModeChange(bCancel As Boolean)
Debug.Print "BeforeModeChanged"
End Sub
Private Sub test_DisplayActivate(ByVal aDisplay As Display)
Debug.Print "Activated: ", aDisplay.Path
End Sub
Private Sub test_DisplayDeactivate(ByVal aDisplay As Display)
Debug.Print "Deactivated: ", aDisplay.Path
End Sub
'This code is in the Display Object:
'
'Dim app As cApp
'
'
'Private Sub Display_Open()
'
' Set app = New cApp
'
' Set app.test = Application
'
'End Sub
Set that up and play with first two .pdi files and then more to get an understanding of how the events occur (you'll get a Deactivate followed by an Activate if you just click on different .pdi's - and don't forget to check what happens when you open a new .pdi and select, then close a .pdi that's already open).
When you get all that down, then you can start figuring out when to do the Poke and/or Pop to your FIFO stack. Peek will let you see the next .pdi down in the stack, and that will be (as I understand it) what you are looking for.
There are going to be some fun complications that could arise from programmatically closing a .pdi - that might correspond to needing to remove a .pdi from somewhere other than the top of the stack. Either you'll need a stack that allows that, or you might get by with doing a double pop if the topmost .pdi in the stack isn't among the .pdi files that are in the Displays collection.
Sure hope someone comes up with an object model solution or something more elegant than what I described.
If you do roll your own, please post back here what you came up with!
James