How do i close all the modal dialog boxes before i close the parent form, that causes my application to terminate...:rolleyes: :rolleyes: :rolleyes: :rolleyes:
Printable View
How do i close all the modal dialog boxes before i close the parent form, that causes my application to terminate...:rolleyes: :rolleyes: :rolleyes: :rolleyes:
Click on them one by one, maybe?
OK, can you elaborate your problem further? If a modal dialog box is visible, your app is not supposed to do anything till the user has dealt with the dialog box.
.
I know that u need to dispose by clicking it..but i need thru programatically....sir!!! ;) ;) ;) ;)Quote:
Originally posted by honeybee
Click on them one by one, maybe?
OK, can you elaborate your problem further? If a modal dialog box is visible, your app is not supposed to do anything till the user has dealt with the dialog box.
.
If you use the VB App Wizard, you will see that it creates a chunk of code in the unload event of the main form. That code unloads each form in the forms collection. It seems like that is what you are trying to achieve, with perhaps a modification or two.
If you want to close all forms except one, you can use that same loop with a line in it excluding the form you don't want to close. Where you put that loop is up to your design.
If the problem you are having is that unloading all the forms ends your program early, I would guess (and it's only a guess), that the first form you show is shown non-modally by the Main sub(). If that's the case, once all forms have been closed, Main has also ended, so the program is finished.
The problem with closing modal forms through code is that the only code that is running during the time a modal form is shown is the code belonging to that form. So you can only unload a modal form from that form.
With that said I must inform you that that is not 100% true... Timer events belonging to another form is still fired. However that will only happen if the app is compiled to native code, timers will not fire their events when you run the app from within VB or if you have compiled it to P-code.
Best regards
While that may work for modal forms, will it also work for dialog boxes?
.
Hmmm.... modal forms are usually dialog boxes. I guess you refer to things as MsgBox and Open, Save As dialogs, and if so yes Timer events will be fired in a compiled EXE while these dialogs are shown. You can actually use a timer to get the handle of a MsgBox and move it if you like. Just remember that that will not work while running the app from the VB IDE.Quote:
Originally posted by honeybee
While that may work for modal forms, will it also work for dialog boxes?
.