How do I hide the mouse cursor and set its position in gtk3? - c

I am trying to make a game where you move the mouse to change your view but you cannot see the mouse and the mouse needs to be stuck in the center, similar to in minecraft. In fact, this IS for my own personal knockoff of Minecraft. I need to hide cursor, and constantly setting the position of the cursor to the center. BUT I still need to track mouse movement, so I can change the view accordingly. These are my codes for how to find the center of the window.
int CenterY = gtk_widget_get_allocated_height(Window)/2;
int CenterX = gtk_widget_get_allocated_Width(Window)/2;
How shall I proceed?

Related

Resize of SVG element mouse losing "grip" on edge

I am trying to construct some SVG shapes which should be resize-able along one or more edges.
The way I do this is by creating an additional shape on top of the shape which I want to be able to resize. I use this shape to indicate to the user that an edge can be clicked on and dragged. This shape tends to be a line that lights up once the user moves their mouse over it and I change it's position while resizing the main shape.
Using a combination of the mousedown, mousemove and mouseup events, I get the mouse's current position and adjust the shape accordingly.
All seems to work. However, what I can't seem to figure out is that should I move my mouse a little bit too quickly, while dragging the edge, it seems as though the mouse looses track of the event and the dragging of the edge fails. At this point I am have to find the edge again and restart the process.
Any idea how to either stop the mouse from losing the edge while dragging? Or perhaps slow down the event so as not to allow the mouse to jerk into any one direction too fast?
I have created a a sandbox here to demonstrate the issue.

Cursor change in Runtime

I am new to C# and WPF. I need to change the mouse cursor to a Rectangular type cursor in runtime.
The cursor should show when the custom cursor should show when mouse move out of the window. and it should change to mouse cursor when mouse moves into the window.
Any help is appreciated.

How to record and replay control movement in WPF?

The question is that, e.g. I have a rectangle on the canvas, and I drag it with mouse (since in a physics engine, so both position and orientation will change). I want to record the movement of the rectangle as sth. like ControlAction or what else, and I have a replay button on the canvas, when I hit it, I can choose the corresponding ControlAction to replay the movement.
How can I do above work? Thank you in advance.

How to Change the Position of a Canvas'es Origin Point

I'm working on a project that allows users to drawing something, and save it in the database.
Basically, the user draws on a canvas, the canvas is 5 time bigger than the screen size, and the canvas is still in the center of the screen (or the screen is in the center of the canvas).
In order to make it flexible for the canvas size (we want to change the size of the canvas in the future), we want to set the center of the canvas as the Origin Point, that is, (0, 0) is in the center of the canvas. So when the mouse clicks somewhere, the point I get is measured based on the center of the canvas.
Maybe you would say:
Canvas.RenderTransformOrigin = (.5,.5). But I'm not asking the rotating center, so it's not the solution.
Canvas.RenderTransform = TranslateTransform (Canvas.Width/2.0, Canvas.Height/2.0). But this just move all the objects on the canvas to the center.
You may also say that, why don't we just translate the MouseClick points with an offset Canvas.Width/2.0, Canvas.Height/2.0, and then translate them back when rendering. We could do that, but too much effort, because we have a lot of other operations to be implemented, so every time we have to translate back and forth.
It looks like you have thought of almost every possible approach to this problem, however, I will see if I can add just one more!
The Canvas properties, Left and Top, which dictate an elements position are attached properties. You could create your own attached properties, OffsetLeft, OffsetTop which allow you to position elements based on the origin you require. These would be simple to implement, when they are get / set, just handle their change event to set the respective Canvas attached properties.

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

Resources