Author Topic: Passcode for Keypad Call?  (Read 2213 times)

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Passcode for Keypad Call?
« on: July 08, 2015, 10:39:40 AM »
Trying to replicate an old (crashed) PanelmatePC project & so far AdvancedHMI has been better, with more options.

However, this morning I came across an entry - a BasicLabel showing the Program Number. When it's clicked on to access the keypad to change the program number a keypad appears asking for a Passcode before the entry keypad appears.

Is there any way to add a Passcode to a keypad call, short of creating a new page to change the program number & adding a passcode to that FormChangeButton?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Passcode for Keypad Call?
« Reply #1 on: July 08, 2015, 10:56:40 AM »
Here is a very quick solution (may not be the cleanest):

- In Solution Explorer, go to AdvancedHMIControls\Controls folder and look for BasicLabel.vb
- Copy that file and paste in the same Folder
- Rename the file to BasicLabelWithPasscode.vb
- Right click BasicLabelWithPasscode.vb and select View Code
- At the top of the file you will see "Public Class BasicLabel". Change that to "Public Class BasicLabelWithPasscode"
- Scroll down to line 651
- Insert the 8 lines shown here start with "'* Make a keypad popup asking for a passcode"
Code: [Select]
    Protected Overrides Sub OnClick(e As System.EventArgs)
        MyBase.OnClick(e)

        '* Make a keypad popup asking for a passcode
        Dim PassCodeKeypad As New MfgControl.AdvancedHMI.Controls.Keypad(m_KeypadWidth)
        PassCodeKeypad.ShowDialog()
        If PassCodeKeypad.ValidateChildren <> "1234" Then
            MsgBox("Invalid pass code")
            Exit Sub
        End If

        If m_PLCAddressKeypad IsNot Nothing AndAlso (String.Compare(m_PLCAddressKeypad, "") <> 0) And Enabled Then

- Build the project
- You should now have a BasicLabelWithPasscode in your ToolBox (it may be at the very bottom of the group)

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: Passcode for Keypad Call?
« Reply #2 on: July 08, 2015, 12:01:53 PM »
Created the new BasicLabelWithPasscode & tried it, but when it pops up the 1st keypad there's no label like "Enter Passcode" (tried in the () after ShowDIalog but crashed).

And no matter what number is entered (1234, 123, 0, 7, 9876, etc.) it continues on to the entry keypad & lets the integer be changed in the PLC.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Passcode for Keypad Call?
« Reply #3 on: July 08, 2015, 02:00:44 PM »
Try it like this:
Code: [Select]
Protected Overrides Sub OnClick(e As System.EventArgs)
        MyBase.OnClick(e)

        '* Make a keypad popup asking for a passcode
        Dim PassCodeKeypad As New MfgControl.AdvancedHMI.Controls.Keypad(m_KeypadWidth)
        PassCodeKeyPad.Text="Enter Pass Code"
        PassCodeKeypad.ShowDialog()
        If PassCodeKeypad.ValidateChildren <> "1234" Then
            MsgBox("Invalid pass code")
            Exit Sub
        End If

        If m_PLCAddressKeypad IsNot Nothing AndAlso (String.Compare(m_PLCAddressKeypad, "") <> 0) And Enabled Then

Vitor

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Passcode for Keypad Call?
« Reply #4 on: July 08, 2015, 02:27:45 PM »
Hi Archie

Thanks for your excelent work.

I notice the last code not work, i tried the follow code and seems to work.

 Dim PassCodeKeypad As New MfgControl.AdvancedHMI.Controls.Keypad(m_KeypadWidth)
        PassCodeKeypad.Text = "Enter Pass Code"
        PassCodeKeypad.ShowDialog()
        If PassCodeKeypad.Value <> "1234" Then
            MsgBox("Invalid pass code")
            Exit Sub
        End If

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Passcode for Keypad Call?
« Reply #5 on: July 08, 2015, 02:49:50 PM »
Vitor... You are correct. I did not notice that AutoComplete put "ValidateChildren" instead of "Value"