WPF - How to detect if mouse has stopped moving - wpf

In a WPF application, how can you detect if the mouse pointer has stopped moving?
I have a canvas and there is a circle(Ellipse) inside. User can move the mouse over the circle. I want see if the mouse is moving over the circle or it has stopped moving? MouseEnter even of the Ellipse object won't help cos it would be fired even if the mouse is not stopped over the Ellipse.
Any ideas on how to achieve this?
Thanks in advance.
Regards,
Rukshan

Try to look at the ToolTipOpening event, you can use it as a marker of the mouse stopped on your element.

Related

How to get the last position when drag/drop cursor mouse out canvas

In WPF, I dont still get the last position when my cursor drag/drop out of canvas.
Please tell me the solution ?
You can get the last position with MouseMouve event. If you still want to get the MousePosition even the mouse is not on the canvas anymore, then you have to subscripe the MouseMove event from the parent control/window.

WPF drag rectangle with touch

I have a WPF app with a canvas inside a ScrollViewer. On the canvas I have some rectangles that I drag along a timeline (left-right). This works fine with a mouse, but on a touch screen I get weird behavior if the canvas is wider than the main form. First, when you begin to drag the rectangle, the canvas pans until it has scrolled to the limit, then the rectangle starts to move. I doesn't do this when using a mouse.
Another strange this is that if I pan/drag the canvas (using touch) to the limit of the scrollviewer, the main form compresses by 20-50 pixels on the side opposite of the pan direction. It springs back to shape as soon as you stop dragging. What's going on here and how do I disable this?
It seems that this has to do with ManipulationBoundaryFeedback, but I don't understand exactly how...
EDIT:
So I was able to get a little further by setting the scrollviewer panningmode to PanningMode.None in the rectangle TouchDown handler and then setting it back to PanningMode.Both in the TouchUp handler. This solved the problem of the canvas panning to the limit before the rectangle would move.
Well, I finally got my app to work with touch. As I mentioned above, setting the PanningMode to None on the TouchDown event eliminated the problem with the ScrollViewer. Setting it back to Both in the TouchUp event re-enabled it. What this means is that I can't drag the rectangle past the point where the ScrollViewer would start panning, but in my case this was not a problem.
I also had some issues with the MouseLeftButtonDown event firing during the TouchMove event so I removed it during TouchDown
-= new MouseButtonEventHandler(drag_start)
and re-added it back during TouchUp to eliminate the glitchy behavior.
+= new MouseButtonEventHandler(drag_start)
Maybe this will help someone in the future...

How to capture mouse coordinates from another program

I'm trying to write a WinForms program that will capture mouse coordinates upon pressing and (more importantly) releasing the middle mouse button.
My form has topmost set to true (so that text in it can always be visible even when it doesn't have focus).
What I'm aiming for is being able to hover the mouse over a game window after my program starts, hit the middle mouse button, and have it record the mouse position for later use.
I can get it to detect when the middle mouse button is clicked inside the form using the MouseUp event (bound to the form itself) but have no clue what I need to do to have it detect when the mid mouse is clicked outside my form.
Thanks for any help guys.
I believe what you are after are called low level hooks. A quick google brings up this: Erroneous Mouse Coordinates Returned from Low Level Mouse Hook C#
A microsoft example of how to do can be found here: http://support.microsoft.com/kb/318804

Get view position in window

Is it possible to get the absolute position of a View in a Titanium Window? I'm trying to overlay a rectangle on an ImageView, and I need to do a bounds check to see if the rectangle is exiting the bounds of the view.(I've registered a touchmove event handler to the window, as it doesn't seem to fire the event on the ImageView itself).
Thanks in advance.
Nevermind, I solved my own problem by overlaying a normal view and checking the touchmove event on that instead. That gave me coordinates relative to the overlayed view(and the ImageView) which was what I needed.

WinAPI mouse move notification for full desktop

In WinAPI is there a mouse move notification for the full desktop (full screen) and not for a window only?
I would like to receive mouse screen coordinates in my main window procedure.
Edit:
What I try to do is getting the coordinates from the mouse when dragging from a button in my window to outside that window.
Not as such, no. If you wanted to do something anywhere on the desktop from within your program, e.g. point somewhere or draw something anywhere, you could capture the mouse and then follow the movement until the mouse button is released. See SetCapture for this.
For an example, see this article on MSDN: Drawing Lines with the Mouse
Otherwise you can always use Windows hooks to follow mouse movements anywhere.
You can set a mouse hook to be notified about all mouse events.
You can use GetCursorPos, or GetMessagePos that contains coordinate of the last message

Resources