Author Topic: MDIParent Form Model  (Read 5225 times)

timryder

  • Jr. Member
  • **
  • Posts: 84
  • Still trying to figure it out
    • View Profile
MDIParent Form Model
« on: September 11, 2017, 11:36:28 AM »
I've used AHMI on several HMI Applications already but I didn't like the way that change the pages worked so I made my own MDI-Parent/Child form control and I've adapted it to work quite smoothly.  Having used this on several machines already I can say that I'm pretty happy with it.

This particular application is servicing a Micro850 PLC from Allen-Bradley over Ethernet and which has 2 Servo Linear stages for positioning parts directly under a laser marker.  There is also a built in Keyence camera which is being controlled by this application over Winsock TCP/IP.  This app has the ability to build custom part configurations for differing setups as well as store and open previously saved ones.  The HMI will synchronize with the PLC the coordinates for each of the parts programmed.

It also logs machine activity and Part data including Serial Number and Camera Pass/Fail to an excel spreadsheet per the customers request.

I have disabled the PLC coms so when you download the sample make sure to re-enable them if you plan on using this. AdvancedHMIControls project and then in the Subscriptionhandler.vb un-comment the SubscribeToComDriver method.











https://drive.google.com/drive/folders/0B8Vb3TS6SQwxTEROWWR0X1RwcTg?usp=sharing

Just click on the drop down above the files list and there will be an option to download it.
Still just trying to figure out this thing called Life.

Phrog30

  • Guest
Re: MDIParent Form Model
« Reply #1 on: September 11, 2017, 04:05:41 PM »
I use MDIParent as well.  The only issue I have is the form borders will flash on occasion when changing forms.  I haven't quite figured that one out yet.  You were the one that gave me the idea... thanks by the way.

James

Noe

  • Full Member
  • ***
  • Posts: 205
    • View Profile
Re: MDIParent Form Model
« Reply #2 on: September 12, 2017, 09:28:07 AM »
Kudos! Great graphic design and clear organization, what every HMI should!

timryder

  • Jr. Member
  • **
  • Posts: 84
  • Still trying to figure it out
    • View Profile
Re: MDIParent Form Model
« Reply #3 on: September 12, 2017, 11:18:05 AM »
I have the solution for you Phrog,
From the main MDIParent Form, Open each of the child forms during the Form_Load event.

Code: [Select]
childFormMain.MdiParent = Me                                                      'Sets all of the application forms as MDI Children
        childFormAlarms.MdiParent = Me
        childFormManual.MdiParent = Me
        childFormMachineSetup.MdiParent = Me
        childFormPartSetup.MdiParent = Me

        childFormMain.Show()                                                              'Show all of the children initially to load them in memory
        childFormAlarms.Show()
        childFormManual.Show()
        childFormMachineSetup.Show()
        childFormPartSetup.Show()

        childFormMain.BringToFront()                                                      'The children are displayed using the BringToFront method, so here we show the first page.
        childFormMain.Focus()

Then on the button click method (which doesn't have to be an AHMI "FormChangeButton" btw), use the following logic

Code: [Select]
If Me.HasChildren = True Then
            For Each frm As Form In Me.MdiChildren
                If TypeOf (frm) Is frmManual Then
                    CType(frm, frmManual).BringToFront()
                    CType(frm, frmManual).Focus()
                    Me.Refresh()
                    Exit Sub
                End If
            Next
        End If

Just change the "frmManual" to whatever form Name you're trying to show.  Make sure to set each forms "Name" property as that's how we're calling them.

So the basic idea is to open them all up ahead of time and then just bring to front the form you want to see.
No flashy at all.
Still just trying to figure out this thing called Life.

Phrog30

  • Guest
Re: MDIParent Form Model
« Reply #4 on: September 14, 2017, 06:07:15 PM »
I have the solution for you Phrog,
From the main MDIParent Form, Open each of the child forms during the Form_Load event.

Code: [Select]
childFormMain.MdiParent = Me                                                      'Sets all of the application forms as MDI Children
        childFormAlarms.MdiParent = Me
        childFormManual.MdiParent = Me
        childFormMachineSetup.MdiParent = Me
        childFormPartSetup.MdiParent = Me

        childFormMain.Show()                                                              'Show all of the children initially to load them in memory
        childFormAlarms.Show()
        childFormManual.Show()
        childFormMachineSetup.Show()
        childFormPartSetup.Show()

        childFormMain.BringToFront()                                                      'The children are displayed using the BringToFront method, so here we show the first page.
        childFormMain.Focus()

Then on the button click method (which doesn't have to be an AHMI "FormChangeButton" btw), use the following logic

Code: [Select]
If Me.HasChildren = True Then
            For Each frm As Form In Me.MdiChildren
                If TypeOf (frm) Is frmManual Then
                    CType(frm, frmManual).BringToFront()
                    CType(frm, frmManual).Focus()
                    Me.Refresh()
                    Exit Sub
                End If
            Next
        End If

Just change the "frmManual" to whatever form Name you're trying to show.  Make sure to set each forms "Name" property as that's how we're calling them.

So the basic idea is to open them all up ahead of time and then just bring to front the form you want to see.
No flashy at all.

My goal is to create objects that don't require any code writing, so what you described doesn't fit my needs. Also, I hide displays to stop polling. Thanks though.

Phrog30

  • Guest
Re: MDIParent Form Model
« Reply #5 on: October 16, 2017, 09:51:59 AM »
I use MDIParent as well.  The only issue I have is the form borders will flash on occasion when changing forms.  I haven't quite figured that one out yet.  You were the one that gave me the idea... thanks by the way.

James

I found a solution for the border flash, saw this online and it worked for me. Before showing the form, minimize, after the show, do normal.  It sounds silly but it was the only thing that worked for me.  Double buffer and the reduce flicker code didn't have an impact.

Code: [Select]
                        frm.WindowState = FormWindowState.Minimized
                        frm.Show()
                        frm.WindowState = FormWindowState.Normal