How to hide mouse cursor in SlimDX render form?

Started by
1 comment, last by KanoT 12 years, 5 months ago
Hi guys. I created simple mesh viewer using SlimDX for my research.

It has FPS-like camera control system. So I want to hide mouse cursor while controlling. How to hide or lock mouse cursor to center screen?
Advertisement
The System.Window.Forms.Cursor has some static methods like Hide() and Show(). So you could probably do something like this:

renderForm.MouseEnter+= (s,e) => Cursor.Hide();

renderForm.MouseLeave+= (s,e) => Cursor.Show();


The Cursor also has a Position property which takes in coordinates in full screen space. The PointToScreen method of the RenderForm helps you converting points from client to screen space.

Cursor.Position = renderForm.PointToScreen(new Point(renderForm.ClientSize.Width / 2, renderForm.ClientSize.Height / 2));
You could set the position right after you have updated your camera.

The System.Window.Forms.Cursor has some static methods like Hide() and Show(). So you could probably do something like this:

renderForm.MouseEnter+= (s,e) => Cursor.Hide();

renderForm.MouseLeave+= (s,e) => Cursor.Show();


The Cursor also has a Position property which takes in coordinates in full screen space. The PointToScreen method of the RenderForm helps you converting points from client to screen space.

Cursor.Position = renderForm.PointToScreen(new Point(renderForm.ClientSize.Width / 2, renderForm.ClientSize.Height / 2));
You could set the position right after you have updated your camera.


Thanks!

This topic is closed to new replies.

Advertisement