在Winform中添加自定义光标 [英] Adding Custom Cursor in Winform

查看:272
本文介绍了在Winform中添加自定义光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< b>
我已经创建了自己的光标文件(.cur/.ani.如何将其添加到Winform中.
我已经尝试过这些followig方法.却无法解决</b>
以下内容从嵌入式资源中生成一个游标.
要添加自定义光标,请创建或使用现有的16x16位图
1.将一个新的光标文件添加到您的项目中:
文件->添加新项目->本地项目项目->光标文件
2.选择16x16图像类型:
图像->当前图标图像类型-> 16x16
---使自定义光标成为嵌入式资源---
在Visual Studio中:
1.在解决方案资源管理器中选择光标文件
2.选择查看->属性.
3.在属性窗口中,将构建操作"切换为嵌入式"
在命令行上:
添加以下标志:
/res:CursorFileName.Cur,Namespace.CursorFileName.Cur

其中名称空间"是您要在其中使用的名称空间
光标,"CursorFileName.Cur"是光标文件名.
下一行使用传入类型
中的名称空间 并在程序集清单中查找CustomCursor.MyCursor.Cur.
注意:游标名称区分大小写.
this.Cursor = new Cursor(GetType(),"MyCursor.Cur");


谁能帮我解决这个问题.

<b>hi pals,
i have created my own cursor file(.cur /.ani. how can i add that into my winform.
i have tried these followig methods. but it doesnt work out</b>
The following generates a cursor from an embedded resource.
To add a custom cursor, create or use an existing 16x16 bitmap
1. Add a new cursor file to your project:
File->Add New Item->Local Project Items->Cursor File
2. Select 16x16 image type:
Image->Current Icon Image Types->16x16
--- To make the custom cursor an embedded resource ---
In Visual Studio:
1. Select the cursor file in the Solution Explorer
2. Choose View->Properties.
3. In the properties window switch "Build Action" to "Embedded"
On the command line:
Add the following flag:
/res:CursorFileName.Cur,Namespace.CursorFileName.Cur

Where "Namespace" is the namespace in which you want to use
the cursor and "CursorFileName.Cur" is the cursor filename.
The following line uses the namespace from the passed-in type
and looks for CustomCursor.MyCursor.Cur in the assemblies manifest.
NOTE: The cursor name is case sensitive.
this.Cursor = new Cursor(GetType(), "MyCursor.Cur");


can anyone please help me to overcome this issue.

推荐答案

System.Windows.Forms.Cursor确实支持自定义光标,但不着色也不动画.这是在MSDN文档中明确指定的:

http://msdn.microsoft.com/zh-cn/library/system.windows.forms.cursor%28v = vs.100%29.aspx [ http://stackoverflow.com/questions/4305800/using- custom-colored-cursors-in-ac-sharp-windows-application [
The class System.Windows.Forms.Cursor does support custom cursors, but not colored and not animated. This is explicitly specified in MSDN documentation:

http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor%28v=vs.100%29.aspx[^].

This is a workaround based on raw Windows API, P/Invoked:

http://stackoverflow.com/questions/4305800/using-custom-colored-cursors-in-a-c-sharp-windows-application[^].

—SA


这篇关于在Winform中添加自定义光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆