Author Topic: POPUP Entry Keypad Password Locked  (Read 2376 times)

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
POPUP Entry Keypad Password Locked
« 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.

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: POPUP Entry Keypad Password Locked
« Reply #1 on: November 01, 2016, 12:47:46 PM »
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
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: POPUP Entry Keypad Password Locked
« Reply #2 on: November 01, 2016, 07:43:54 PM »
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

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: POPUP Entry Keypad Password Locked
« Reply #3 on: November 01, 2016, 08:27:59 PM »
You are right!  Will a simple exit sub work?
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: POPUP Entry Keypad Password Locked
« Reply #4 on: November 01, 2016, 09:14:47 PM »
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.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: POPUP Entry Keypad Password Locked
« Reply #5 on: November 01, 2016, 09:34:07 PM »
A couple of new properties could also be created to allow enabling/disabling the passcode requirement and setting the passcode itself:

Code: [Select]
    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:

Code: [Select]
        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.
« Last Edit: November 01, 2016, 10:44:28 PM by Godra »