地铁应用程序中的自定义光标自定义、光标、应用程序、地铁

2023-09-06 06:29:52 作者:未婚男人

我正在开发一个类似油漆的应用程序.我想在某些情况下更改光标.那么,如何在 Metro 应用程序中使用自定义光标?

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 ?

我找到了这个

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

在上述方法中,自定义"光标有一个枚举,第二个参数是资源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 ?

推荐答案

做到这一点的基本途径:

The basic route to doing this:

创建您的自定义光标并使用 C++ Metro DLL 将其打包为 .res通过查看 C++ 项目中的 resource.h 文件记下您的资源 ID在我的项目中,资源号是 101,我没有调整.将 .res 添加到 CSharp XAML Metro 项目使用文本编辑器打开您的 .csproj在第一个属性组中添加一个指向 .res 文件的部分使用您引用的函数调用和通过查看 resource.h 找到的资源编号将光标切换到自定义光标.Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Custom, 101);

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);

我意识到这很多.我在我的博客 http://blogs.msdn.com/b/devfish/archive/2012/08/02/customcursors-in-windows-8-csharp-metro-applications.aspx .希望这会有所帮助.

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.