Question

We've noticed some strange Cursor behavior, which we suspect is a result of one of our Cursor canging methods. Just sometimes, our pc keeps showing the SizeAll cursor. Everywhere, in every application. Now, we never use the SizeAll cursor anywhere in our code, but we can "Unstuck" the cursor when following code is executed.

We suspect the problem to be something with the static Cursor Property, but cannot identify the error.

What's wrong with the code?

Thanks everyone though.

static class GlobalVars
{

    private static Cursor handOpenCursor;

    public static Cursor HandOpenCursor
    {

        get 
        {
            if (handOpenCursor == null)
            {
                string cursorPath = System.IO.Path.Combine( ApplicatiePaths.ImagePath, @"hand_open.cur" );
                handOpenCursor = new Cursor(cursorPath);
                return handOpenCursor;
            }
            else
            {
                return handOpenCursor;
            }
        }
        set 
        {
            handOpenCursor = value;
        }
    }
}


.....



private static void panel_MouseUp(object sender, MouseEventArgs e)
{
    ((Control)sender).Cursor = GlobalVars.HandOpenCursor;
}
Was it helpful?

Solution 2

Well after 3 months I finally identiefied the problem. it wasn't .NET or XP, but I have a Logitech G9 Mouse with custom software.

When the cursor is stuck, and I go to Control Panel -> Mouse -> Pointer schemes, the right scheme is selcted (windows default), but ALL CURSORS of the scheme are the same SizeAll cursor?!?!

I suspect the G9 driver causes this crazy behavior. Selecting another scheme and then again "Windows Default" solves the problem.

OTHER TIPS

Don't know what wrong with this static class, except that it is thread unsafe. Other thing that if you set custom cursor for some action you then need to reset cursor to normal state. For example in this case:

  this.Cursor = Cursor.Wait;
  throw new Exception();
  this.Cursor = Cursor.Default;

Cursor will not be reset.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top