Author Topic: Pop Up Screens  (Read 1634 times)

DavidSr

  • Full Member
  • ***
  • Posts: 170
    • View Profile
Pop Up Screens
« on: March 23, 2022, 10:47:34 PM »
Hello all,

This forum has been super dead so I hope one of you former regulars visits from time to time...

I looked through the forum but don't think what I found is what I want - but maybe so I would like some guidance.
I would like to know if there is a way to have a new form/page open as a pop up screen in the middle of the main form when activated by a PLC bit. It will be used to show more information about a particular item such as motor detail, Run time, current etc. rather than putting it all on the motor start stop panel. then have a control to reset the bit.

I currently use bits to display panels and gauges on top of the main form so maybe that is the best or at least sufficient way of doing it. Adding a PLC VISIBLE to a Group BOX like for the Group Panel would help.  Would that be your recommendation to keep doing it that way? Rather not go to a different page, a Pop up would be perfect. I wish I had time to learn VB but I really don't but I don't mind editing and testing.
Thank you.
« Last Edit: March 23, 2022, 10:57:03 PM by DavidSr »
David

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Pop Up Screens
« Reply #1 on: March 24, 2022, 02:59:25 AM »
- In Solution Explorer, Right Click The AdvancedHMI project and select Add->Form (Windows Form)
- Name the form to something like Popup, then click Add
- Right click the form and slect View Code
- Copy this code:
Code: [Select]
    '*******************************************************************************
    '* Stop polling when the form is not visible in order to reduce communications
    '* Copy this section of code to every new form created
    '*******************************************************************************
    Private NotFirstShow As Boolean

    Private Sub Form_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.VisibleChanged
        '* Do not start comms on first show in case it was set to disable in design mode
        If NotFirstShow Then
            AdvancedHMIDrivers.Utilities.StopComsOnHidden(components, Me)
        Else
            NotFirstShow = True
        End If
    End Sub

- On the MainForm, add a DataSubscriber
- Set PLCAddressValue to the bit that will trigger the popup
- Double click the DataSubscriber
- Enter this code:
Code: [Select]
        If String.CompareOrdinal(e.Values(0), "True", True) = 0 Then
            Popup.Show()
        Else
            Popup.Hide()
        End If

DavidSr

  • Full Member
  • ***
  • Posts: 170
    • View Profile
Re: Pop Up Screens
« Reply #2 on: March 24, 2022, 05:11:00 AM »
Great to see "you Popping up" here Archie , and I didn't even have to write any code :-)   

Thank you! I will try this today hopefully,  DataSubscriber is the control I was looking at but was not sure how to use it. 

Thank you! Have blessed and restful day!David
« Last Edit: April 03, 2022, 06:07:52 PM by DavidSr »
David