parker4001
parker4001

Reputation: 73

Closing a message box via a timer control

I'm looking to find out that when a user, enters their pin and clicks enter a message box displays saying processing your details. How would i then close that message box using a timer control? I have all the code to proceed to the next form or display another message box saying you have entered the incorrect pin, just looking to close the message box via a time control.

Upvotes: 1

Views: 850

Answers (2)

Michel Keijzers
Michel Keijzers

Reputation: 15357

Try to avoid closing the message box from another location, but do the processing in the 'message box':

  • Create your own form with your message and OK button (for example). You cannot use ShowMessageBox.
  • Call your own created form as ShowDialog
  • Create a timer
  • Do the processing (inside the form)
  • When the timer reaches the wanted amount of time (or when processing is done), close the dialog

Upvotes: 1

JTeagle
JTeagle

Reputation: 2196

By design, message boxes are modal - they run their own little message pump and can't (or shouldn't) be closed from the outside. Pop up your own little form with the required label, buttons and icon and then you can simply set Visible = false when your timer expires. If you need other forms to not be actionable during this time, set their Enabled property to false until you hide the fake message box.

Upvotes: 1

Related Questions