Employing GetScreen and ShowScreen methods.

Question:

How can I use the Viewer’s GetScreen and the Frame’s ShowScreen methods? What are they for?

Solution:

The GetScreen(ScreenName) method returns a Screen object, whose name must be set up at ScreenName parameter. This method’s return value can be used at the Frame’s ShowScreen method.

The ShowScreen(Screen, Zoom, Scrollbars[, Arg]) method loads a screen at the Frame, closing any screen or frame previously loaded on it. The Screen parameter only accepts objects returned by the Viewer’s GetScreen method, and will fail if a screen object returned by another method or property is used.

To illustrate these methods’ usefulness, imagine a situation where you need to open a screen and run a few scripts. Before these methods were developed, you needed a script to open the screen, and in this screen you needed another script (usually on OnPreShow event) to access its child objects.

The problem with this approach came when, for example, you needed to create libraries that depended on this script in the application, and which didn’t allow developing a library that could reduce coupling issues. With GetScreen and ShowScreen methods, you can open the screen via scripts, and before the screen opens, you can retrieve the Screen object and access its desired child objects.

The attached demo application illustrates how to use an indexed windowed screen, which attributes the path of the XObject linked to the XControl directly to the script in the object’s Click event, requiring no sending/receiving of the parameter on OnPreShow event.

Script employed in this example:

Sub Picture1_Click()

Arg = XCMotor.Source.PathName
Set newScreen = Application.GetFrame(“virtualFrame”)
newScreen.MoveFrame , , 250, 300
newScreen.SetFrameOptions XCMotor.Source.Name, 15+64+256+2048

Set screenObj = Application.GetScreen(“CommandScreen”)
newScreen.ShowScreen screenObj, 100, 0
screenObj.Item(“IndexedScreen1”).Source = Arg

End Sub

NOTE: The attached demo application was developed with Elipse E3 version 4.8 239.

 

Attachments:

Sample.zip

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *