AdvancedHMI Software
General Category => Open Discussion => Topic started by: aquilmustafa on November 01, 2016, 03:46:58 AM
-
Hey Archie,
Can i just have a password protection for Keypad popup of Digital-Panel Meter and Basic Label.
-
You can try add a click event , and add the code:
Dim kpd As New MfgControl.AdvancedHMI.Controls.Keypad
kpd.ShowDialog()
If kpd.Value <> "1234" Then
e.Cancel = True
End If
-
Standard Click event has "e" declared as EventArgs and doesn't contain "Cancel" as an option.
Some time ago somebody else asked similar question about password in this topic:
http://advancedhmi.com/forum/index.php?PHPSESSID=9d9ee151c540a4e4516c0bffdf69234d&topic=855.0
-
You are right! Will a simple exit sub work?
-
It would work but the code as you suggested would have to be placed inside the OnClick sub.
That would be exactly the solution provided by Archie in the topic mentioned in my previous post.
-
A couple of new properties could also be created to allow enabling/disabling the passcode requirement and setting the passcode itself:
Private m_KeypadRequestPasscode As Boolean
Public Property KeypadRequestPasscode As Boolean
Get
Return m_KeypadRequestPasscode
End Get
Set(value As Boolean)
m_KeypadRequestPasscode = value
End Set
End Property
Private m_KeypadPasscode As String = "1234"
Public Property KeypadPasscode() As String
Get
Return m_KeypadPasscode
End Get
Set(ByVal value As String)
m_KeypadPasscode = value
End Set
End Property
and then also modify Archie's code in the OnClick sub to:
If m_KeypadRequestPasscode Then
'* Make a keypad popup asking for a passcode
Dim PassCodeKeypad As New MfgControl.AdvancedHMI.Controls.Keypad(m_KeypadWidth)
PassCodeKeypad.StartPosition = Windows.Forms.FormStartPosition.CenterScreen
PassCodeKeypad.ForeColor = Color.Red
PassCodeKeypad.Text = "P A S S C O D E"
PassCodeKeypad.ShowDialog()
If PassCodeKeypad.DialogResult = DialogResult.Cancel Then
Exit Sub
End If
If PassCodeKeypad.Value <> m_KeypadPasscode Then
MsgBox("Invalid pass code!")
Exit Sub
End If
End If
These modifications could be added to any control that has Keypad.