KB-31241: Enabling/disabling buttons according to the user logged in.

Question:

In an application with multiple users, how can I make sure only the logged-in user’s button is enabled, while the others remain disabled?

Solution:

To do so, you can create a script at the application’s OnUserLogin event to enable only the logged-in user’s button. Then, you will need to create two more scripts to disable the other users’ buttons at the application’s OnUserLogout and OnStopRunning events, that is, scripts that pass Enable property’s value to zero.

Sample scripts:

OnUserLogin event:

If Application.userName == ‘a’
ButtonA.enabled = 1
ButtonB.enabled = 0
ButtonC.enabled = 0
ButtonD.enabled = 0
ELSEIF Application.userName == ‘b’
ButtonA.enabled = 0
ButtonB.enabled = 1
ButtonC.enabled = 0
ButtonD.enabled = 0
ELSEIF Application.userName == ‘c’
ButtonA.enabled = 0
ButtonB.enabled = 0
ButtonC.enabled = 1
ButtonD.enabled = 0
ELSEIF Application.userName == ‘d’
ButtonA.enabled = 0
ButtonB.enabled = 0
ButtonC.enabled = 0
ButtonD.enabled = 1
EndIf

OnUserLogout and OnStopRunning events:

ButtonA.enabled = 0
ButtonB.enabled = 0
ButtonC.enabled = 0
ButtonD.enabled = 0

NOTE: Attached to this article is a demo application developed with Elipse SCADA v. 2.29 b. 92.

Attachments:

EnableOnLogin

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 *