How to close a MsgBox programmatically?

UncleRonin

Well-known member
Joined
Feb 28, 2006
Messages
230
Location
South Africa
Programming Experience
5-10
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?
 
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.
 
Back
Top