Original Post
Hi, I'm trying to get the mouse coordinates from inside a window using DirectInput. As most of you probably know DirectInput only returns how much the mouse has moved since the last time it checked. I've tryed to use windows forms messaging to get the starting position of the mouse by binding a OnMouseMove event on the form and make it run this code: So it just gets the position once and then unbinds itself and then I let DirectInput update the values in xPos and yPos. This method does not work, first of all it's rather inaccurate most of the time and second DirectInput keeps feeding the program the mouse movement even when it's placed outside of the form. Does anyone know how to use DirectInput to get 'normal' mouse coordinates inside a window ( the top left corner should be position 0,0 ) ? Or should I just stick to windows events ? Thanks in advance.
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
xPos = e.X;
yPos = e.Y;
this.MouseMove -= new MouseEventHandler(Form1_MouseMove);
}