Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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: 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?

share|improve this question
Can you take a look at my classes? How did you get the mouse to work? My keyboard works, but mouse input isn't updating:… – ChocoMan Aug 19 '13 at 19:01
up vote 4 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.