493 views
in GUI Development by
Hello,

       I have a scenario where I have a bunch of modal dialogs launched from one to another. If it's easier to understand, they're setup dialogs that the user traverses through to launch a command in the device. Once the command is launched, a new dialog is shown to show the status of the command that was launched. Once this command is stopped by the user, ideally we would like to go back to the initial root screens from which the setup dialgos were launched. All dialogs are launched through BeginModal()'s and works great. I tried to do a EndModal() by specifying the z-order but that didn't work. What would be the recommended method to remove modal dialogs from the stack? Do I need to store the Core::Groups that I would like removed on a stack to be removed, maybe?

Thanks!

1 Answer

+1 vote
by
 
Best answer

Hi,

if you want to close all currently existing modal dialogs, do it in a loop. For example:

var Core::Root  root       = GetRoot();
var Core::Group modalGroup = root.GetModalGroup();

while ( modalGroup != null )
{
  // Remove the dialog from its owner.
  modalGroup.Owner.Remove( modalGroup );

  // ... and end the modal state for this group
  root.EndModal( modalGroup );

  // Get the next modal group from the modal stack
  modalGroup = root.GetModalGroup();
}

Similarly, you can close several nested dialogs until you reach one particular stop dialog. You need to know the stop dialog and then you can test in the loop whether the dialog has been reached:

[...]

var Core::Group groupToStop = ...

while (( modalGroup != null ) && ( modalGroup != groupToStop ))
{
  [...]
}

Does it help you further?

Best regards

Paul Banach

by
Works perfectly, thank you!

Embedded Wizard Website | Privacy Policy | Imprint

...