locked
How do I set the mouse cursor in WinRT

    Question

  • How to I change the mouse cursor programmaticly in WinRT.  Under Windows, I would use 'SetCursor(...)'.  What is the WinRT equivalent?

    Thanks.

     
    Wednesday, January 09, 2013 4:50 PM

Answers

  • Hi John,

    The only way to create a custom cursor is from a resource. You can mimic one by setting the cursor to nullptr and drawing your own bitmap at the cursor position. If you are using Xaml this will always lag behind the cursor a bit since the updates are separate from the rendering. If you are using Direct3D then it should be able to keep up.

    --Rob

    • Marked as answer by John Gaby Friday, January 11, 2013 5:43 AM
    Thursday, January 10, 2013 11:14 PM
    Owner

All replies

  • You need to set your CoreWindow's PointerCursor property .

    --Rob

    Wednesday, January 09, 2013 9:26 PM
    Owner
  • Wednesday, January 09, 2013 9:27 PM
  • Thanks for the link, I had missed that topic.  However, it is not quite what I am looking for.  I would like to create the CoreCursor from a bitmap file (e.g. PNG) rather than load it from the resource file.  Is this not possible?

    Thanks.

    Thursday, January 10, 2013 10:55 PM
  • Hi John,

    The only way to create a custom cursor is from a resource. You can mimic one by setting the cursor to nullptr and drawing your own bitmap at the cursor position. If you are using Xaml this will always lag behind the cursor a bit since the updates are separate from the rendering. If you are using Direct3D then it should be able to keep up.

    --Rob

    • Marked as answer by John Gaby Friday, January 11, 2013 5:43 AM
    Thursday, January 10, 2013 11:14 PM
    Owner
  • Thanks for the info.  I tried drawing the cursor myself as you suggested, and you are right that it is pretty laggy.  I suppose that I am going to have to live with it though as Microsoft is not providing a proper way to do it.  I must confess that the more I work with WinRT, the more I feel that it is only about 90% finished.

    Thanks again for your help.

    Friday, January 11, 2013 5:43 AM
  • When I have a two monitor setup and launch my app. The cursor, with the stylus, shows up as a text cursor in my app which is on the other monitor. (I'm assuming because VS set it that way.) 

    It doesn't become the dot (which is what I want) until I move the mouse onto my app.

    How can I trick the app into switching to the right stylus cursor without needing the mouse? It's kind of an edge case, but it would be nice if it always behaved correctly.

    • Edited by Steven.A.S Saturday, October 12, 2013 6:44 AM
    Saturday, October 12, 2013 6:36 AM