There are two modes you can use to open the Viewer in Elipse E3: Viewer Control or Viewer Only. So, you can alternate between both Viewer modes (Control and Only) according to the user logged to the session.
In order to enable this, follow the steps below:
- Firstly, create a Login screen where you can pass username and password parameters via SetPoints. On this screen, configure a command button to execute the script below. Set up the screen to be the Viewer’s initial screen.
- To create the password’s setpoint, use an MSForm’s TextBox; at PasswordChar property, add any chosen character, such as an asterisk (*).
- Then, at Login button’s script, use:
- Viewer’s LoginUser() method: performs the login by passing the setpoints’ Value property.
- Viewer’s User property: checks the logged in user.
- Viewer’s ExecuteExternalApp() method: opens a new Viewer in Control or Only mode.
- Parameters at Viewer executable file: pass the name of the server, the screen to be opened in the new Viewer, and the parameters used for login (user and password).
- Viewer’s Exit() method: closes the Viewer with Login screen.
With these, we can create this example of script:
Sub CommandButton1_Click() Viewer = "C:\Program Files (x86)\Elipse Software\Elipse Power\Bin\Viewer.exe" pServer = "\\." pOnly = " -ReadOnly" pScreen = " -screen ScreenOperation" User = Screen.Item("spUser").Value Pwd = Screen.Item("spPwd").Value pLogin = " -PARAMS p1=" & User & " p2=" & Pwd IF Application.LoginUser(User, Pwd) THEN IF Application.User = "Admin" THEN 'Viewer Control Application.ExecuteExternalApp Viewer, pServer & pScreen & pLogin, "", 3 ELSE 'Viewer Only Application.ExecuteExternalApp Viewer, pServer & pOnly & pScreen & pLogin, "", 3 END IF Application.Exit() END IF End Sub
Finally, we will once again perform the login of the screen to be opened, reusing the parameters previously used on the login screen. Example:
Sub ScreenOperation_OnStartRunning() 'Login Application.LoginUser Application.Params("p1"), Application.Params("p2") End Sub
Therefore, we will be able to alternate the Viewer object between Control and Only modes, according to the user logged to the application.
- KB-89210: Alternating the Viewer between Full and Only modes at runtime.
- KB-29704: Opening Viewer in a screen not set up as its initial screen.
- KB-29791: Using parameters passed to the Viewer during opening command.