I am using this code in Update method in XNA RenderControl in Windows Forms:

Mouse.WindowHandle = renderControl1.Handle;
MouseState stat=Mouse.GetState();

Everything works fine but when I want to record it with Fraps I get this result: http://www.youtube.com/watch?v=oDmzAIx_wU0 mouse position is moved but in screen everything is OK. When first line is removed I have moved cursor on screen but not in video. Is posible to have same result in both cases?


1 Answer 1


I'm not sure if it will work in your specific problem but I also use Windows Forms with XNA and after trying many ways to get consistent mouse behavior across several different situations, I settled with this:

public Vector2 GetMousePosition()
    System.Drawing.Point point = this.PointToClient(Control.MousePosition);
    return new Vector2(point.X, point.Y);

This method returns the current mouse position relative to the control bounds. Put that inside your control class and see how it works for you. This solved a few problems I was having when I tried using the XNA Mouse API for reading the mouse position, in particular when placing my XNA rendering control inside of another control.

Your problem seems to be a different one, but I've just tried using Fraps on my application which uses the method described above, and it's working correctly, so I think it should probably solve your problem too.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .