If a modal window gets stuck behind the main form, it looks like you are not setting its owner. When you call showDialog(), you need to pass the main form as follows:
modalWin.showDialog(mainForm);
Each time you call showDialog(), and your program has a different form, which should be at the bottom, it is better to transfer it as the owner. If you show a modal window when there is already a modal window up, then pass the first modal window as the owner.
source
share