custom cursor in metro app

2019-02-15 16:28发布

I am developing a paint like application. I want to change cursor at some instance. So, how can I use the custom cursor in metro app ?

I have found this

Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Custom, uint id);

In above method, there is one enum for "Custom" cursor and the second argument is for resource ID. So how can I get that ?

1条回答
\"骚年 ilove
2楼-- · 2019-02-15 16:48

The basic route to doing this:

Create your custom cursor and package it in a .res using a C++ Metro DLL Take a note of your resource id by peeking into the resource.h file in the C++ project In my project the resource number was 101 and I didn't adjust. Add the .res to a CSharp XAML Metro project Open your .csproj using a text editor Inside the first property group add a section that points to your .res file Switch out the cursor to the custom cursor using the function call you referenced, and the resource number you found by peeking at resource.h. Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Custom, 101);

I realize this is a lot. I posted a detailed step by step walk through on my blog at http://blogs.msdn.com/b/devfish/archive/2012/08/02/customcursors-in-windows-8-csharp-metro-applications.aspx . Hope this helps.

查看更多
登录 后发表回答