Results 1 to 7 of 7

Thread: Closing Modal Dialog Boxes

  1. #1

    Thread Starter
    Hyperactive Member nazeem_khan's Avatar
    Join Date
    Nov 2002
    Location
    India
    Posts
    305

    Closing Modal Dialog Boxes

    How do i close all the modal dialog boxes before i close the parent form, that causes my application to terminate...

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    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 am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3

    Thread Starter
    Hyperactive Member nazeem_khan's Avatar
    Join Date
    Nov 2002
    Location
    India
    Posts
    305

    Re: Well ...

    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.

    .
    I know that u need to dispose by clicking it..but i need thru programatically....sir!!!

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    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.

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    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

  6. #6
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    While that may work for modal forms, will it also work for dialog boxes?

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Well ...

    Originally posted by honeybee
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width