I am creating Windows Presentation Foundation Control with Microsoft Blend.
When I leave my control, pressing the left-mouse-button, mouse-pick-event has not been raised. why not?
This behavior is intended: when you are on mousedown
Control control and control still "captures" on the mouse, which means that the control mouse move-event
will be removed from the mouse-leisure program instead of releasing the mouse button outside the control are given.
To avoid this, you can simply tell your control that the mouse is not to be captured at all:
Private Zero ControlMouseDown (System.Object Sender, System.Windows.Forms.MouseEventArgs e) {Control Control = (Control) Sender; Control. Capture = false; // Release Capture}
Now the mouse lev event is pressed a button, while also on exit, it will be removed.
If you need to capture in control, you should try more:
-
Start tracking the mouse keeping manually, when the mouse is pressed
-
Contrast the status with
,left
andsize
in question Features. -
Decide whether you need to stop or control your mouse.
Public Partial Category Form 1: Form {Private point point; Personal Boolean myCapture = false; Public Form 1 () {Initialization (); } Private Zero Button 1_MouseDown (Object Sender, MouseEventArgs e) {myCapture = true; } Private Zero Button 1_MouseMove (Object Sender, MouseEventArgs E) {If (myCapture) {point = Cursor.Position; If (! (Dot.x> button 1. laugh & amp; amp; point; x & lt; button1 .Let + button 1. Size width & amp;; point; y & gt; button 1. & amp; amp; amp; amp;; Point; Y & lt; Button 1. Top + Button 1. Size. Height)) {button.1. Capture = false; // This will release the capture and the mouseclub will trigger the event immediately MyCapture = false; }}} Private Zero Button 1_MouseLeave (Object Sender, EventArgs e) {MessageBox.Show ("leaving the mouse"); }
You must stop your tracking ( myCapture = false;
) Forgotten that one :)
Comments
Post a Comment