Results 1 to 2 of 2

Thread: How to close a MsgBox programmatically?

  1. #1
    UncleRonin's Avatar
    UncleRonin is offline VB.NET Forum Genius
    .NET Framework
    .NET 4.0
    Join Date
    Feb 2006
    Location
    South Africa
    Posts
    230
    Reputation
    141

    How to close a MsgBox programmatically?

    I lock my app after a certain idle period and hide all windows so that people can't fiddle or view restricted stuff. I display errors through a MsgBox. Now, if an error is displayed, the user goes to go get someone about the error and the program locks. All the necessary stuff is hidden but I have no idea how to go about closing that MsgBox! Is there a way to do this?

  2. #2
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,648
    Reputation
    2742
    The MessageBox displays modally, that is no other code of yours is executed until that dialog returns (and all code of that dialog is internal and unmodifyable). What you have to do is create your own MessageBox dialog and use the same lock mechanism inside that form (or auto-dismiss it) should it be displaying.

    There could be another solution too, launch the MessageBox on a separate thread and pause the main thread until MB returns or cancel it. I haven't thought that over and it could be too much fuzz.

Bookmarks

Posting Permissions

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