Hi,
No, this is not a bug. Phil is right that is because the framework sets the
capture whenever the mouse left button is pressed down. And I believe this
is good because in 99% of the casses we want to set the capture(normaly it
is used for dragging).
What is bad is that the capture is released when a button is released. It
doesn't matter which one. It could be the left or the right or even maybe
the middle one (the case with the middle one I have not tested). So a
problem may arise if the user presses the left button, start draging
(everything is fine so far) then presses the right mouse button and
released the right one. At this point the capture is lost. Which is bad
because I don't really care of the right mouse button and react only on the
left one. So I have to handle releasing any button and if it is not the left
one just cancel the operation.
But your problem has a cure. In the MouseDown event just set the Capture
property of your control to *false* and you will get rid of the capture and
will receive the MouseLeave event when the mouse leaves the control and
won't receive any mouse events afterwards.
HTH
B\rgds
100
Phil Da Lick! said:
Workaround for MS's lack of MouseLeave event is to detrect the MouseMove
coordinates and if they are larger than the control or negative, fire the
MouseLeave event youreself if MS dont do it.
Will this be fired in later versions because I dont like having cludge code
in there to workaround lack of features.
No it wont be fixed because it is not a bug. This is just the way windows
works unfortunately. It is common practice for the window to capture the
cursor while the button is pressed. If you *really* need to determine where
the cursor is try [this is a raw api version, you will need to convert to
the .net equiv]
POINT pt;
GetCursorPos(&pt);
if(GetWindowFromPoint(pt)==hWnd)
{
// we're in out window
}
else
{
// we're not in our window
};