C# 如何在C中创建自定义游标#

C# 如何在C中创建自定义游标#,c#,image,resources,cursor,C#,Image,Resources,Cursor,请帮我解决自定义游标的错误好吗 表单设计器中的我的脚本: this.Cursor = new System.Windows.Forms.Cursor(global::testCursor.Properties.Resources.test); Error 4 Argument 1: cannot convert from 'System.Drawing.Bitmap' to 'System.IntPtr' G:\Programování\Projects\C#\testCursor\

请帮我解决自定义游标的错误好吗

表单设计器中的我的脚本:

this.Cursor = new System.Windows.Forms.Cursor(global::testCursor.Properties.Resources.test);
Error   4   Argument 1: cannot convert from 'System.Drawing.Bitmap' to 'System.IntPtr'  G:\Programování\Projects\C#\testCursor\testCursor\Login.Designer.cs 255 59  testCursor
Error   3   The best overloaded method match for 'System.Windows.Forms.Cursor.Cursor(System.IntPtr)' has some invalid arguments G:\Programování\Projects\C#\testCursor\testCursor\Login.Designer.cs 255 27  testCursor
编译错误:

this.Cursor = new System.Windows.Forms.Cursor(global::testCursor.Properties.Resources.test);
Error   4   Argument 1: cannot convert from 'System.Drawing.Bitmap' to 'System.IntPtr'  G:\Programování\Projects\C#\testCursor\testCursor\Login.Designer.cs 255 59  testCursor
Error   3   The best overloaded method match for 'System.Windows.Forms.Cursor.Cursor(System.IntPtr)' has some invalid arguments G:\Programování\Projects\C#\testCursor\testCursor\Login.Designer.cs 255 27  testCursor

我真的很想知道能对我有帮助的答案。

游标API要求图像具有
IntPtr
,但您提供的是
位图
值。使用
GetHbitmap
函数获取
IntPtr

Bitmap bitmap = global::testCursor.Properties.Resources.test;
this.Cursor = new System.Windows.Forms.Cursor(bitmap.GetHbitmap());

你已经查过了吗?您得到的错误应该足够清楚。它看起来不错,但这一行:form.designer.cs不支持位图。错误:@RadekTarant您已经发布的错误消息建议您在
参考资料中有位图。测试
。你那里到底有什么?