Search code examples
c#.netmessagebox

Message box block the mouseLeftButtonUp event


I'm having a problem with release a captured mouse. My application demand that I make a sequence of actions (means that they will run automatically one after another). The sequences are: _ Select an object _ Enter a value on a message box for the object to rotate according to the entered value.

At run time: I click on the object, it activate the MouseLeftButtonDown event of the selected object. Then the message box appears. This message box blocks my mouse to activate MouseLeftButtonUp event of that object. So I have to click the object one more time to activate the MouseLeftButtonUp event or my application cannot continue running.

Can anyone helps me with this?


Solution

  • That's why a lot of controls only take action on the MouseUp event. They use the MouseDown event to do something like indicating state or selection. And use mouse capture (Capture property in Winforms) to ensure that they'll get the MouseUp event even if the mouse is moved outside of the window. Try it in your browser right now, press and hold the right mouse button, nothing happens, let it go. Exact same behavior when you left-click a link or button.

    Sounds like that's what you want to do as well.