I am working on real-time video processing project.
During the real-time video i need to get mouse position when left clicked. To do that i have one button to send mouse position to text boxes. To see position of the cursor, i have two text boxes named as txt4 and txt5 for X and Y position seperately.
I have written the given code as shown the below. When i click the button it shows the current postion of the mouse (actually it is the position of the button) but then when i do left click position of the mouse is not shown in the text boxes. Position is shown when i press "Enter" while button is clicked.
What is wrong? and How can i correct it?
private void btnCursor_Click(object sender, EventArgs e)
{
if (device.IsRunning)
{
this.Cursor = new Cursor(Cursor.Current.Handle);
txt4.Text = string.Format("x={0:0000}", Cursor.Position.X);
txt5.Text = string.Format("y={0:0000}", Cursor.Position.Y);
}
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Click>0)
{
txt4.Text = MousePosition.X.ToString();
txt5.Text = MousePosition.Y.ToString();
}
}
I tried to get mouse position when i do left click.
What i get is mouse position when i pressed "Enter" instead of left clicked.
I have error in line "if(e.Click>0)".