Author Topic: Prohibit Close Unless On Home Screen  (Read 2177 times)

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Prohibit Close Unless On Home Screen
« on: November 25, 2016, 07:56:42 PM »
If a multi-page AdvancedHMI is running and it is closed on any other screen except the MainForm screen it closes by the looks of it. However it is still running in the background, still communicating through the network, still using a good portion of the CPU resource (34%) and over 9MB of RAM locked up. I have to go to Task Manager, select it and click End Task to fully close it. I have tested this on different projects on various versions of Windows with similar results.

Is there any way to prevent AdvancedHMI from closing except on the Mainform? I searched the forum but nothing related came up.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Prohibit Close Unless On Home Screen
« Reply #1 on: November 25, 2016, 08:13:09 PM »
The method I use is to remove the border from all pages except the main form. This leaves only a method of exiting form the main form. In the properties for each page, set FormBorderStyle to None

AabeckControls

  • Full Member
  • ***
  • Posts: 193
    • View Profile
Re: Prohibit Close Unless On Home Screen
« Reply #2 on: November 26, 2016, 03:26:39 PM »
Archie,

Thanks - glad it's that simple too.

kay_gsr13

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Prohibit Close Unless On Home Screen
« Reply #3 on: November 30, 2016, 09:32:35 AM »
If a multi-page AdvancedHMI is running and it is closed on any other screen except the MainForm screen it closes by the looks of it. However it is still running in the background, still communicating through the network, still using a good portion of the CPU resource (34%) and over 9MB of RAM locked up. I have to go to Task Manager, select it and click End Task to fully close it. I have tested this on different projects on various versions of Windows with similar results.

Is there any way to prevent AdvancedHMI from closing except on the Mainform? I searched the forum but nothing related came up.

AabeckControls,

With multiple forms/pages, another option is to set behavior of the forms, such as the shutdown mode. Navigate to the My Project in the solution explorer, select application and there should be options to adjust which form is the startup or the shutdown mode. See image:

Hope this helps.

K

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Prohibit Close Unless On Home Screen
« Reply #4 on: November 30, 2016, 09:59:16 AM »
With multiple forms/pages, another option is to set behavior of the forms, such as the shutdown mode. Navigate to the My Project in the solution explorer, select application and there should be options to adjust which form is the startup or the shutdown mode. See image:
There will still be a problem with this if using FormChangeButtons because the forms are hidden and not closed. If a FormChangeButton is used to navigate to a second page, then someone X's that page, the previous form is still open, but hidden, leaving no way to access it other than Task Manager to close the application.

kay_gsr13

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Prohibit Close Unless On Home Screen
« Reply #5 on: November 30, 2016, 10:33:08 AM »
There will still be a problem with this if using FormChangeButtons because the forms are hidden and not closed. If a FormChangeButton is used to navigate to a second page, then someone X's that page, the previous form is still open, but hidden, leaving no way to access it other than Task Manager to close the application.
[/quote]

Yes I've experience that myself,  to prevent that, some of the apps that I've made for simple controls, usually stays on a single page (others pages are for engineering purposes only).

I use the all .close() method for each forms when the new form is opened. Though it take longer to load, the apps or pages are not changed often.


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Prohibit Close Unless On Home Screen
« Reply #6 on: November 30, 2016, 05:32:51 PM »
There will still be a problem with this if using FormChangeButtons because the forms are hidden and not closed. If a FormChangeButton is used to navigate to a second page, then someone X's that page, the previous form is still open, but hidden, leaving no way to access it other than Task Manager to close the application.
This problem is being addressed by the addition of a MainMenuButton in the next release. The idea is to use a form with menu buttons to change forms. The menu form will always be visible, stay docked, and position other forms to the right of it. The menu form will be the only form that can be used to close the application. When it closes, it also searches for hidden forms and disposes of them.

The disposal is important because VS does not dispose hidden forms when the application is closed, which in turn if using the AB Ethernet drivers, they will not properly close the connections.

kay_gsr13

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Prohibit Close Unless On Home Screen
« Reply #7 on: December 01, 2016, 09:05:40 AM »
This problem is being addressed by the addition of a MainMenuButton in the next release. The idea is to use a form with menu buttons to change forms. The menu form will always be visible, stay docked, and position other forms to the right of it. The menu form will be the only form that can be used to close the application. When it closes, it also searches for hidden forms and disposes of them.

The disposal is important because VS does not dispose hidden forms when the application is closed, which in turn if using the AB Ethernet drivers, they will not properly close the connections.
[/quote]

This would be an awesome addition!