I have a C# application with 2 simultaneous visible forms, and I need to hide mouse cursor when it is over only on one of them. If I use Cursor.Hide() it applies the change for both of them.
+1
A:
Did you try this.Cursor = Cursors.None
, instead of Cursor.Hide()
?
Paulo Santos
2010-03-18 17:26:52
Cursors.None don't exist as valid cursor
Santiago
2010-03-18 17:29:14
A:
You could use the Control.MouseEnter and Control.MouseLeave events to trigger hiding or displaying the cursor
Seb
2010-03-18 17:26:54
A:
You can make a "blank" cursor, and set myForm.Cursor = blankCursor;
This will make that specific form show a specific cursor, which could be completely transparent.
Reed Copsey
2010-03-18 17:28:31
+2
A:
You need to implement this logic by using the MouseEnter
and MouseLeave
events one each form something like:
private void frm1_MouseEnter(object sender, EventArgs e)
{
Cursor.Hide();
}
private void frm1_MouseLeave(object sender, EventArgs e)
{
Cursor.Show();
}
do the abobe on the form that should hide the cursor and add this to the form that should make the cursor visible:
private void frm2_MouseEnter(object sender, EventArgs e)
{
Cursor.Show();
}
Luiscencio
2010-03-18 17:29:01
I tried this thanks, but, the mouse pointer appear over controls inside the form
Santiago
2010-03-18 17:42:42
try removing the MouseLeave on frm1... but I dont know if cursor will be hidden even to other windows until it enters frm2
Luiscencio
2010-03-18 17:53:27
It seemed a good idea, but I don't know why sometimes the MouseEnter event don't run when mouse enter on the forms, so, dissapear and appear when windows want it.
Santiago
2010-03-18 19:34:16
A:
If you're hiding the cursor so that the user can't do anything on the form, consider using this.UseWaitCursor = true;
instead.
R. Bemrose
2010-03-18 19:02:52